📄 xml807.java
字号:
cifLayer, skillLayer, parasitics, pureLayerNode, arcProto, oldName(true), wipable, curvable, special, notUsed, skipSizeInPalette, extended(true), fixedAngle(true), angleIncrement(true), antennaRatio(true), diskOffset, defaultWidth, arcLayer, primitiveNode, //oldName(true), shrinkArcs, square, canBeZeroSize, wipes, lockable, edgeSelect,// skipSizeInPalette,// notUsed, lowVt, highVt, nativeBit, od18, od25, od33, // defaultWidth, defaultHeight, sizeOffset, nodeLayer, box, multicutbox, serpbox, lambdaBox, points, techPoint, primitivePort, portAngle, portTopology(true),// techPoint, portArc(true), polygonal, serpTrans, specialValue(true), minSizeRule, spiceTemplate, spiceHeader, spiceLine, menuPalette, menuBox, menuArc(true), menuNode(true), menuText(true), menuNodeInst, menuNodeText, lambda(true), Foundry, layerGds, LayerRule, LayersRule, NodeLayersRule, NodeRule; private final boolean hasText; private XmlKeyword() { hasText = false; }; private XmlKeyword(boolean hasText) { this.hasText = hasText; } }; private static final HashMap<String,XmlKeyword> xmlKeywords = new HashMap<String,XmlKeyword>(); static { for (XmlKeyword k: XmlKeyword.class.getEnumConstants()) xmlKeywords.put(k.name(), k); } private static Schema schema = null; private static synchronized void loadTechnologySchema() throws SAXException { if (schema != null) return; SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); URL technologySchemaUrl = Technology.class.getResource("Technology.xsd"); if (technologySchemaUrl != null) schema = schemaFactory.newSchema(technologySchemaUrl); else { System.err.println("Schema file Technology.xsd, working without XML schema"); System.out.println("Schema file Technology.xsd, working without XML schema"); } } public static Technology parseTechnology(URL fileURL) {// System.out.println("Memory usage " + Main.getMemoryUsage() + " bytes"); SAXParserFactory factory = SAXParserFactory.newInstance(); factory.setNamespaceAware(true); try { if (schema == null) loadTechnologySchema(); factory.setSchema(schema); // factory.setValidating(true); // System.out.println("Memory usage " + Main.getMemoryUsage() + " bytes"); // create the parser long startTime = System.currentTimeMillis(); SAXParser parser = factory.newSAXParser(); URLConnection urlCon = fileURL.openConnection(); InputStream inputStream = urlCon.getInputStream(); XMLReader handler = new XMLReader(); parser.parse(inputStream, handler); if (Job.getDebug()) { long stopTime = System.currentTimeMillis(); System.out.println("Loading technology " + fileURL + " ... " + (stopTime - startTime) + " msec"); } return handler.tech; } catch (SAXParseException e) { String msg = "Error parsing Xml technology:\n" + e.getMessage() + "\n" + " Line " + e.getLineNumber() + " column " + e.getColumnNumber() + " of " + fileURL; msg = msg.replaceAll("\"http://electric.sun.com/Technology\":", ""); System.out.println(msg); Job.getUserInterface().showErrorMessage(msg, "Error parsing Xml technology"); } catch (Exception e) { String msg = "Error loading Xml technology " + fileURL + " :\n" + e.getMessage() + "\n"; System.out.println(msg); Job.getUserInterface().showErrorMessage(msg, "Error loading Xml technology"); } return null; } /** * Method to parse a string of XML that describes the component menu in a Technology Editing context. * Normal parsing of XML returns objects in the Xml class, but * this method returns objects in a given Technology-Editor world. * @param xml the XML string * @param nodes the PrimitiveNode objects describing nodes in the technology. * @param arcs the ArcProto objects describing arcs in the technology. * @return the MenuPalette describing the component menu. */ public static MenuPalette parseComponentMenuXMLTechEdit(String xml, List<PrimitiveNode> nodes, List<ArcProto> arcs) { SAXParserFactory factory = SAXParserFactory.newInstance(); factory.setNamespaceAware(true); try { SAXParser parser = factory.newSAXParser(); InputSource is = new InputSource(new StringReader(xml)); XMLReader handler = new XMLReader(nodes, arcs); parser.parse(is, handler); return handler.tech.menuPalette; } catch (Exception e) { System.out.println("Error parsing XML component menu data"); e.printStackTrace(); } return null; } private static class XMLReader extends DefaultHandler { private static boolean DEBUG = false; private Locator locator; private Xml807.Technology tech = new Xml807.Technology(); private int curTransparent = 0; private int curR; private int curG; private int curB; private Layer curLayer; private boolean patternedOnDisplay; private boolean patternedOnPrinter; private final int[] pattern = new int[16]; private int curPatternIndex; private EGraphics.Outline outline; private double opacity; private boolean foreground; private ArcProto curArc; private PrimitiveNode curNode; private NodeLayer curNodeLayer; private PrimitivePort curPort; private int curSpecialValueIndex; private ArrayList<Object> curMenuBox; private MenuNodeInst curMenuNodeInst; private Distance curDistance; private SpiceHeader curSpiceHeader; private Foundry curFoundry; private boolean acceptCharacters; private StringBuilder charBuffer = new StringBuilder(); private Attributes attributes; XMLReader() { } XMLReader(List<PrimitiveNode> nodes, List<ArcProto> arcs) { for(ArcProto xap : arcs) tech.arcs.add(xap); for(PrimitiveNode xnp : nodes) tech.nodes.add(xnp); } private void beginCharacters() { assert !acceptCharacters; acceptCharacters = true; assert charBuffer.length() == 0; } private String endCharacters() { assert acceptCharacters; String s = charBuffer.toString(); charBuffer.setLength(0); acceptCharacters = false; return s; } //////////////////////////////////////////////////////////////////// // Default implementation of the EntityResolver interface. //////////////////////////////////////////////////////////////////// /** * Resolve an external entity. * * <p>Always return null, so that the parser will use the system * identifier provided in the XML document. This method implements * the SAX default behaviour: application writers can override it * in a subclass to do special translations such as catalog lookups * or URI redirection.</p> * * @param publicId The public identifier, or null if none is * available. * @param systemId The system identifier provided in the XML * document. * @return The new input source, or null to require the * default behaviour. * @exception java.io.IOException If there is an error setting * up the new input source. * @exception org.xml.sax.SAXException Any SAX exception, possibly * wrapping another exception. * @see org.xml.sax.EntityResolver#resolveEntity */ public InputSource resolveEntity(String publicId, String systemId) throws IOException, SAXException { return null; } //////////////////////////////////////////////////////////////////// // Default implementation of DTDHandler interface. //////////////////////////////////////////////////////////////////// /** * Receive notification of a notation declaration. * * <p>By default, do nothing. Application writers may override this * method in a subclass if they wish to keep track of the notations * declared in a document.</p> * * @param name The notation name. * @param publicId The notation public identifier, or null if not * available. * @param systemId The notation system identifier. * @exception org.xml.sax.SAXException Any SAX exception, possibly * wrapping another exception. * @see org.xml.sax.DTDHandler#notationDecl */ public void notationDecl(String name, String publicId, String systemId) throws SAXException {// int x = 0; } /** * Receive notification of an unparsed entity declaration. * * <p>By default, do nothing. Application writers may override this * method in a subclass to keep track of the unparsed entities * declared in a document.</p> * * @param name The entity name. * @param publicId The entity public identifier, or null if not * available. * @param systemId The entity system identifier. * @param notationName The name of the associated notation. * @exception org.xml.sax.SAXException Any SAX exception, possibly * wrapping another exception. * @see org.xml.sax.DTDHandler#unparsedEntityDecl */ public void unparsedEntityDecl(String name, String publicId, String systemId, String notationName) throws SAXException {// int x = 0; } //////////////////////////////////////////////////////////////////// // Default implementation of ContentHandler interface. //////////////////////////////////////////////////////////////////// /** * Receive a Locator object for document events. *
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -