📄 xmlparam.java
字号:
} return null; } private static class XMLReader extends DefaultHandler { private static boolean DEBUG = false; private Locator locator; private Technology tech = new Technology(); private Layer curLayer; private ArcProto curArc; private PrimitiveNode curNode; private NodeLayer curNodeLayer; private PrimitivePort curPort; private int curSpecialValueIndex; private ArrayList<Object> curMenuBox; private MenuNodeInst curMenuNodeInst; private MenuCell curMenuCell; private Distance curDistance; private SpiceHeader curSpiceHeader; private DisplayStyle curDisplayStyle; private int curTransparent = 0; private int curR; private int curG; private int curB; private LayerDisplayStyle curLayerDisplayStyle; 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 RuleSet curRuleSet; private Map<Layer,Distance> curLayerRule; 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. * * <p>By default, do nothing. Application writers may override this * method in a subclass if they wish to store the locator for use * with other document events.</p> * * @param locator A locator for all SAX document events. * @see org.xml.sax.ContentHandler#setDocumentLocator * @see org.xml.sax.Locator */ public void setDocumentLocator(Locator locator) { this.locator = locator; } private void printLocator() { System.out.println("publicId=" + locator.getPublicId() + " systemId=" + locator.getSystemId() + " line=" + locator.getLineNumber() + " column=" + locator.getColumnNumber()); } /** * Receive notification of the beginning of the document. * * <p>By default, do nothing. Application writers may override this * method in a subclass to take specific actions at the beginning * of a document (such as allocating the root node of a tree or * creating an output file).</p> * * @exception org.xml.sax.SAXException Any SAX exception, possibly * wrapping another exception. * @see org.xml.sax.ContentHandler#startDocument */ public void startDocument() throws SAXException { if (DEBUG) { System.out.println("startDocument"); } } /** * Receive notification of the end of the document. * * <p>By default, do nothing. Application writers may override this * method in a subclass to take specific actions at the end * of a document (such as finalising a tree or closing an output * file).</p> * * @exception org.xml.sax.SAXException Any SAX exception, possibly * wrapping another exception. * @see org.xml.sax.ContentHandler#endDocument */ public void endDocument() throws SAXException { if (DEBUG) { System.out.println("endDocument"); } } /** * Receive notification of the start of a Namespace mapping. * * <p>By default, do nothing. Application writers may override this * method in a subclass to take specific actions at the start of * each Namespace prefix scope (such as storing the prefix mapping).</p> * * @param prefix The Namespace prefix being declared. * @param uri The Namespace URI mapped to the prefix. * @exception org.xml.sax.SAXException Any SAX exception, possibly * wrapping another exception. * @see org.xml.sax.ContentHandler#startPrefixMapping */ public void startPrefixMapping(String prefix, String uri) throws SAXException { if (DEBUG) { System.out.println("startPrefixMapping prefix=" + prefix + " uri=" + uri); } } /** * Receive notification of the end of a Namespace mapping. * * <p>By default, do nothing. Application writers may override this * method in a subclass to take specific actions at the end of * each prefix mapping.</p> * * @param prefix The Namespace prefix being declared. * @exception org.xml.sax.SAXException Any SAX exception, possibly * wrapping another exception. * @see org.xml.sax.ContentHandler#endPrefixMapping */ public void endPrefixMapping(String prefix) throws SAXException { if (DEBUG) { System.out.println("endPrefixMapping prefix=" + prefix); } } /** * Receive notification of the start of an element. * * <p>By default, do nothing. Application writers may override this * method in a subclass to take specific actions at the start of * each element (such as allocating a new tree node or writing * output to a file).</p> * * @param uri The Namespace URI, or the empty string if the * element has no Namespace URI or if Namespace * processing is not being performed. * @param localName The local name (without prefix), or the * empty string if Namespace processing is not being * performed. * @param qName The qualified name (with prefix), or the * empty string if qualified names are not available. * @param attributes The attributes attached to the element. If * there are no attributes, it shall be an empty * Attributes object. * @exception org.xml.sax.SAXException Any SAX exception, possibly * wrapping another exception. * @see org.xml.sax.ContentHandler#startElement */ public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { boolean dump = false; XmlKeyword key = xmlKeywords.get(localName);// System.out.print("<" + key.name()); this.attributes = attributes; switch (key) { case technology: tech.techName = a("name"); tech.className = a_("class");// dump = true; break; case numMetals: tech.minNumMetals = Integer.parseInt(a("min")); tech.maxNumMetals = Integer.parseInt(a("max")); tech.defaultNumMetals = Integer.parseInt(a("default")); break; case scale: tech.scaleValue = Double.parseDouble(a("value")); tech.scaleRelevant = Boolean.parseBoolean(a("relevant")); break; case defaultFoundry: tech.defaultFoundry = a("value"); break; case minResistance: tech.minResistance = Double.parseDouble(a("value")); break; case minCapacitance: tech.minCapacitance = Double.parseDouble(a("value")); break; case layer: if (curDisplayStyle != null) { curLayerDisplayStyle = curDisplayStyle.newLayer(tech.findLayer(a("name"))); curTransparent = 0; curR = curG = curB = 0; patternedOnDisplay = false; patternedOnPrinter = false; Arrays.fill(pattern, 0); curPatternIndex = 0;// EGraphics.Outline outline = null; } else if (curLayerRule != null) { curDistance = new Distance(); Distance old = curLayerRule.put(tech.findLayer(a("name")), curDistance); if (old == null) throw new IllegalArgumentException("Duplicate layer " + a("name")); } else { curLayer = tech.newLayer(a("name")); curLayer.function = com.sun.electric.technology.Layer.Function.valueOf(a("fun")); String extraFunStr = a_("extraFun"); if (extraFunStr != null) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -