58, close, ContentReader, JHotDraw741 jhotdraw7/src/main/java/net/n3/nanoxml/ContentReader.java, 177, 208 6 /** * Skips remaining data and closes the stream. * * @throws java.io.IOException * if an error occurred reading the data */ 28 public void close() throws IOException { try { int bufferLength = this.buffer.length(); for (;;) { String str = ""; char ch; if (this.bufferIndex >= bufferLength) { str = XMLUtil.read(this.reader, '&'); ch = str.charAt(0); } else { ch = this.buffer.charAt(this.bufferIndex); this.bufferIndex++; continue; // don't interprete chars in the buffer } if (ch == '<') { this.reader.unread(ch); break; } if ((ch == '&') && (str.length() > 1)) { if (str.charAt(1) != '#') { XMLUtil.processEntity(str, this.reader, this.resolver); } } } } catch (XMLParseException e) { throw new IOException(e.getMessage()); ### 59, ContentReader, ContentReader, JHotDraw741 jhotdraw7/src/main/java/net/n3/nanoxml/ContentReader.java, 78, 85 7 /** * Creates the reader. * * @param reader the encapsulated reader * @param resolver the entity resolver * @param buffer data that has already been read from reader */ 8 ContentReader(IXMLReader reader, IXMLEntityResolver resolver, String buffer) { this.reader = reader; this.resolver = resolver; this.buffer = buffer; this.bufferIndex = 0; ### 60, read, ContentReader, JHotDraw741 jhotdraw7/src/main/java/net/n3/nanoxml/ContentReader.java, 114, 166 12 /** * Reads a block of data. * * @param outputBuffer where to put the read data * @param offset first position in buffer to put the data * @param size maximum number of chars to read * * @return the number of chars read, or -1 if at EOF * * @throws java.io.IOException * if an error occurred reading the data */ 45 public int read(char[] outputBuffer, int offset, int size) throws IOException { try { int charsRead = 0; int bufferLength = this.buffer.length(); if ((offset + size) > outputBuffer.length) { size = outputBuffer.length - offset; } while (charsRead < size) { String str = ""; char ch; if (this.bufferIndex >= bufferLength) { str = XMLUtil.read(this.reader, '&'); ch = str.charAt(0); } else { ch = this.buffer.charAt(this.bufferIndex); this.bufferIndex++; outputBuffer[charsRead] = ch; charsRead++; continue; // don't interprete chars in the buffer } if (ch == '<') { this.reader.unread(ch); break; } if ((ch == '&') && (str.length() > 1)) { if (str.charAt(1) == '#') { ch = XMLUtil.processCharLiteral(str); } else { XMLUtil.processEntity(str, this.reader, this.resolver); continue; } } outputBuffer[charsRead] = ch; charsRead++; } if (charsRead == 0) { charsRead = -1; } return charsRead; } catch (XMLParseException e) { throw new IOException(e.getMessage()); ### 61, finalize, ContentReader, JHotDraw741 jhotdraw7/src/main/java/net/n3/nanoxml/ContentReader.java, 92, 98 3 /** * Cleans up the object when it's destroyed. */ 7 protected void finalize() throws Throwable { this.reader = null; this.resolver = null; this.buffer = null; super.finalize(); ### 62, finalize, PIReader, JHotDraw741 jhotdraw7/src/main/java/net/n3/nanoxml/PIReader.java, 74, 78 3 /** * Cleans up the object when it's destroyed. */ 5 protected void finalize() throws Throwable { this.reader = null; super.finalize(); ### 63, read, PIReader, JHotDraw741 jhotdraw7/src/main/java/net/n3/nanoxml/PIReader.java, 94, 131 12 /** * Reads a block of data. * * @param buffer where to put the read data * @param offset first position in buffer to put the data * @param size maximum number of chars to read * * @return the number of chars read, or -1 if at EOF * * @throws java.io.IOException * if an error occurred reading the data */ 29 public int read(char[] buffer, int offset, int size) throws IOException { if (this.atEndOfData) { return -1; } int charsRead = 0; if ((offset + size) > buffer.length) { size = buffer.length - offset; } while (charsRead < size) { char ch = this.reader.read(); if (ch == '?') { char ch2 = this.reader.read(); if (ch2 == '>') { this.atEndOfData = true; break; } this.reader.unread(ch2); } buffer[charsRead] = ch; charsRead++; } if (charsRead == 0) { charsRead = -1; } return charsRead; ### 64, PIReader, PIReader, JHotDraw741 jhotdraw7/src/main/java/net/n3/nanoxml/PIReader.java, 64, 67 5 /** * Creates the reader. * * @param reader the encapsulated reader */ 4 PIReader(IXMLReader reader) { this.reader = reader; this.atEndOfData = false; ### 77, getParameterEntityResolver, NonValidator, JHotDraw741 jhotdraw7/src/main/java/net/n3/nanoxml/NonValidator.java, 115, 117 5 /** * Returns the parameter entity resolver. * * @return the entity resolver. */ 3 public IXMLEntityResolver getParameterEntityResolver() { return this.parameterEntityResolver; ### 78, attributeAdded, NonValidator, JHotDraw741 jhotdraw7/src/main/java/net/n3/nanoxml/NonValidator.java, 608, 616 8 /** * Indicates that an attribute has been added to the current element. * * @param key the name of the attribute. * @param value the value of the attribute. * @param systemId the system ID of the XML data of the element. * @param lineNr the line number in the XML data of the element. */ 8 public void attributeAdded(String key, String value, String systemId, int lineNr) { Properties props = (Properties) this.currentElements.peek(); if (props.containsKey(key)) { props.remove(key); ### 79, processElement, NonValidator, JHotDraw741 jhotdraw7/src/main/java/net/n3/nanoxml/NonValidator.java, 184, 217 9 /** * Processes an element in the DTD. * * @param reader the reader to read data from. * @param entityResolver the entity resolver. * * @throws java.lang.Exception * If something went wrong. */ 27 protected void processElement(IXMLReader reader, IXMLEntityResolver entityResolver) throws Exception { String str = XMLUtil.read(reader, '%'); char ch = str.charAt(0); if (ch != '!') { XMLUtil.skipTag(reader); return; } str = XMLUtil.read(reader, '%'); ch = str.charAt(0); switch (ch) { case '-': XMLUtil.skipComment(reader); break; case '[': this.processConditionalSection(reader, entityResolver); break; case 'E': this.processEntity(reader, entityResolver); break; case 'A': this.processAttList(reader, entityResolver); break; default: XMLUtil.skipTag(reader); ### 80, NonValidator, NonValidator, JHotDraw741 jhotdraw7/src/main/java/net/n3/nanoxml/NonValidator.java, 76, 80 3 /** * Creates the "validator". */ 5 public NonValidator() { this.attributeDefaultValues = new Hashtable(); this.currentElements = new Stack(); this.parameterEntityResolver = new XMLEntityResolver(); ### 81, processEntity, NonValidator, JHotDraw741 jhotdraw7/src/main/java/net/n3/nanoxml/NonValidator.java, 460, 530 9 /** * Processes an ENTITY element. * * @param reader the reader to read data from. * @param entityResolver the entity resolver. * * @throws java.lang.Exception * If something went wrong. */ 61 protected void processEntity(IXMLReader reader, IXMLEntityResolver entityResolver) throws Exception { if (! XMLUtil.checkLiteral(reader, "NTITY")) { XMLUtil.skipTag(reader); return; } XMLUtil.skipWhitespace(reader, null); char ch = XMLUtil.readChar(reader, '\0'); if (ch == '%') { XMLUtil.skipWhitespace(reader, null); entityResolver = this.parameterEntityResolver; } else { reader.unread(ch); } String key = XMLUtil.scanIdentifier(reader); XMLUtil.skipWhitespace(reader, null); ch = XMLUtil.readChar(reader, '%'); String systemID = null; String publicID = null; switch (ch) { case 'P': if (! XMLUtil.checkLiteral(reader, "UBLIC")) { XMLUtil.skipTag(reader); return; } XMLUtil.skipWhitespace(reader, null); publicID = XMLUtil.scanString(reader, '%', this.parameterEntityResolver); XMLUtil.skipWhitespace(reader, null); systemID = XMLUtil.scanString(reader, '%', this.parameterEntityResolver); XMLUtil.skipWhitespace(reader, null); XMLUtil.readChar(reader, '%'); break; case 'S': if (! XMLUtil.checkLiteral(reader, "YSTEM")) { XMLUtil.skipTag(reader); return; } XMLUtil.skipWhitespace(reader, null); systemID = XMLUtil.scanString(reader, '%', this.parameterEntityResolver); XMLUtil.skipWhitespace(reader, null); XMLUtil.readChar(reader, '%'); break; case '"': case '\'': reader.unread(ch); String value = XMLUtil.scanString(reader, '%', this.parameterEntityResolver); entityResolver.addInternalEntity(key, value); XMLUtil.skipWhitespace(reader, null); XMLUtil.readChar(reader, '%'); break; default: XMLUtil.skipTag(reader); } if (systemID != null) { entityResolver.addExternalEntity(key, publicID, systemID); ### 83, parseDTD, NonValidator, JHotDraw741 jhotdraw7/src/main/java/net/n3/nanoxml/NonValidator.java, 133, 170 12 /** * Parses the DTD. The validator object is responsible for reading the * full DTD. * * @param publicID the public ID, which may be null. * @param reader the reader to read the DTD from. * @param entityResolver the entity resolver. * @param external true if the DTD is external. * * @throws java.lang.Exception * If something went wrong. */ 33 public void parseDTD(String publicID, IXMLReader reader, IXMLEntityResolver entityResolver, boolean external) throws Exception { XMLUtil.skipWhitespace(reader, null); int origLevel = reader.getStreamLevel(); for (;;) { String str = XMLUtil.read(reader, '%'); char ch = str.charAt(0); if (ch == '%') { XMLUtil.processEntity(str, reader, this.parameterEntityResolver); continue; } else if (ch == '<') { this.processElement(reader, entityResolver); } else if (ch == ']') { return; // end internal DTD } else { XMLUtil.errorInvalidInput(reader.getSystemID(), reader.getLineNr(), str); } do { ch = reader.read(); if (external && (reader.getStreamLevel() < origLevel)) { reader.unread(ch); return; // end external DTD } } while ((ch == ' ') || (ch == '\t') || (ch == '\n') || (ch == '\r')); reader.unread(ch); ### 84, elementStarted, NonValidator, JHotDraw741 jhotdraw7/src/main/java/net/n3/nanoxml/NonValidator.java, 542, 555 7 /** * Indicates that an element has been started. * * @param name the name of the element. * @param systemId the system ID of the XML data of the element. * @param lineNr the line number in the XML data of the element. */ 12 public void elementStarted(String name, String systemId, int lineNr) { Properties attribs = (Properties) this.attributeDefaultValues.get(name); if (attribs == null) { attribs = new Properties(); } else { attribs = (Properties) attribs.clone(); } this.currentElements.push(attribs); ### 85, elementAttributesProcessed, NonValidator, JHotDraw741 jhotdraw7/src/main/java/net/n3/nanoxml/NonValidator.java, 585, 595 14 /** * This method is called when the attributes of an XML element have been * processed. * If there are attributes with a default value which have not been * specified yet, they have to be put into extraAttributes. * * @param name the name of the element. * @param extraAttributes where to put extra attributes. * @param systemId the system ID of the XML data of the element. * @param lineNr the line number in the XML data of the element. */ -------------- // nothing to do -------------- 10 public void elementAttributesProcessed(String name, Properties extraAttributes, String systemId, int lineNr) { Properties props = (Properties) this.currentElements.pop(); Enumeration enm = props.keys(); while (enm.hasMoreElements()) { String key = (String) enm.nextElement(); extraAttributes.put(key, props.get(key)); ### 86, processIgnoreSection, NonValidator, JHotDraw741 jhotdraw7/src/main/java/net/n3/nanoxml/NonValidator.java, 303, 323 9 /** * Processes an ignore section. * * @param reader the reader to read data from. * @param entityResolver the entity resolver. * * @throws java.lang.Exception * If something went wrong. */ 17 protected void processIgnoreSection(IXMLReader reader, IXMLEntityResolver entityResolver) throws Exception { if (! XMLUtil.checkLiteral(reader, "NORE")) { XMLUtil.skipTag(reader); return; } XMLUtil.skipWhitespace(reader, null); String str = XMLUtil.read(reader, '%'); char ch = str.charAt(0); if (ch != '[') { XMLUtil.skipTag(reader); return; } Reader subreader = new CDATAReader(reader); subreader.close(); ### 87, processConditionalSection, NonValidator, JHotDraw741 jhotdraw7/src/main/java/net/n3/nanoxml/NonValidator.java, 231, 290 9 /** * Processes a conditional section. * * @param reader the reader to read data from. * @param entityResolver the entity resolver. * * @throws java.lang.Exception * If something went wrong. */ 45 protected void processConditionalSection(IXMLReader reader, IXMLEntityResolver entityResolver) throws Exception { XMLUtil.skipWhitespace(reader, null); String str = XMLUtil.read(reader, '%'); char ch = str.charAt(0); if (ch != 'I') { XMLUtil.skipTag(reader); return; } str = XMLUtil.read(reader, '%'); ch = str.charAt(0); switch (ch) { case 'G': this.processIgnoreSection(reader, entityResolver); return; case 'N': break; default: XMLUtil.skipTag(reader); return; } if (! XMLUtil.checkLiteral(reader, "CLUDE")) { XMLUtil.skipTag(reader); return; } XMLUtil.skipWhitespace(reader, null); str = XMLUtil.read(reader, '%'); ch = str.charAt(0); if (ch != '[') { XMLUtil.skipTag(reader); return; } Reader subreader = new CDATAReader(reader); StringBuffer buf = new StringBuffer(1024); for (;;) { int ch2 = subreader.read(); if (ch2 < 0) { break; } buf.append((char) ch2); } subreader.close(); reader.startNewStream(new StringReader(buf.toString())); ### 88, setParameterEntityResolver, NonValidator, JHotDraw741 jhotdraw7/src/main/java/net/n3/nanoxml/NonValidator.java, 104, 106 5 /** * Sets the parameter entity resolver. * * @param resolver the entity resolver. */ 3 public void setParameterEntityResolver(IXMLEntityResolver resolver) { this.parameterEntityResolver = resolver; ### 89, processAttList, NonValidator, JHotDraw741 jhotdraw7/src/main/java/net/n3/nanoxml/NonValidator.java, 336, 446 9 /** * Processes an ATTLIST element. * * @param reader the reader to read data from. * @param entityResolver the entity resolver. * * @throws java.lang.Exception * If something went wrong. */ 100 protected void processAttList(IXMLReader reader, IXMLEntityResolver entityResolver) throws Exception { if (! XMLUtil.checkLiteral(reader, "TTLIST")) { XMLUtil.skipTag(reader); return; } XMLUtil.skipWhitespace(reader, null); String str = XMLUtil.read(reader, '%'); char ch = str.charAt(0); while (ch == '%') { XMLUtil.processEntity(str, reader, this.parameterEntityResolver); str = XMLUtil.read(reader, '%'); ch = str.charAt(0); } reader.unread(ch); String elementName = XMLUtil.scanIdentifier(reader); XMLUtil.skipWhitespace(reader, null); str = XMLUtil.read(reader, '%'); ch = str.charAt(0); while (ch == '%') { XMLUtil.processEntity(str, reader, this.parameterEntityResolver); str = XMLUtil.read(reader, '%'); ch = str.charAt(0); } Properties props = new Properties(); while (ch != '>') { reader.unread(ch); String attName = XMLUtil.scanIdentifier(reader); XMLUtil.skipWhitespace(reader, null); str = XMLUtil.read(reader, '%'); ch = str.charAt(0); while (ch == '%') { XMLUtil.processEntity(str, reader, this.parameterEntityResolver); str = XMLUtil.read(reader, '%'); ch = str.charAt(0); } if (ch == '(') { while (ch != ')') { str = XMLUtil.read(reader, '%'); ch = str.charAt(0); while (ch == '%') { XMLUtil.processEntity(str, reader, this.parameterEntityResolver); str = XMLUtil.read(reader, '%'); ch = str.charAt(0); } } } else { reader.unread(ch); XMLUtil.scanIdentifier(reader); } XMLUtil.skipWhitespace(reader, null); str = XMLUtil.read(reader, '%'); ch = str.charAt(0); while (ch == '%') { XMLUtil.processEntity(str, reader, this.parameterEntityResolver); str = XMLUtil.read(reader, '%'); ch = str.charAt(0); } if (ch == '#') { str = XMLUtil.scanIdentifier(reader); XMLUtil.skipWhitespace(reader, null); if (! str.equals("FIXED")) { XMLUtil.skipWhitespace(reader, null); str = XMLUtil.read(reader, '%'); ch = str.charAt(0); while (ch == '%') { XMLUtil.processEntity(str, reader, this.parameterEntityResolver); str = XMLUtil.read(reader, '%'); ch = str.charAt(0); } continue; } } else { reader.unread(ch); } String value = XMLUtil.scanString(reader, '%', this.parameterEntityResolver); props.put(attName, value); XMLUtil.skipWhitespace(reader, null); str = XMLUtil.read(reader, '%'); ch = str.charAt(0); while (ch == '%') { XMLUtil.processEntity(str, reader, this.parameterEntityResolver); str = XMLUtil.read(reader, '%'); ch = str.charAt(0); } } if (! props.isEmpty()) { this.attributeDefaultValues.put(elementName, props); ### 90, finalize, NonValidator, JHotDraw741 jhotdraw7/src/main/java/net/n3/nanoxml/NonValidator.java, 87, 95 3 /** * Cleans up the object when it's destroyed. */ 9 protected void finalize() throws Throwable { this.parameterEntityResolver = null; this.attributeDefaultValues.clear(); this.attributeDefaultValues = null; this.currentElements.clear(); this.currentElements = null; super.finalize(); ### 149, CDATAReader, CDATAReader, JHotDraw741 jhotdraw7/src/main/java/net/n3/nanoxml/CDATAReader.java, 70, 74 5 /** * Creates the reader. * * @param reader the encapsulated reader */ 5 CDATAReader(IXMLReader reader) { this.reader = reader; this.savedChar = 0; this.atEndOfData = false; ### 150, finalize, CDATAReader, JHotDraw741 jhotdraw7/src/main/java/net/n3/nanoxml/CDATAReader.java, 81, 85 3 /** * Cleans up the object when it's destroyed. */ 5 protected void finalize() throws Throwable { this.reader = null; super.finalize(); ### 151, read, CDATAReader, JHotDraw741 jhotdraw7/src/main/java/net/n3/nanoxml/CDATAReader.java, 101, 150 12 /** * Reads a block of data. * * @param buffer where to put the read data * @param offset first position in buffer to put the data * @param size maximum number of chars to read * * @return the number of chars read, or -1 if at EOF * * @throws java.io.IOException * if an error occurred reading the data */ 41 public int read(char[] buffer, int offset, int size) throws IOException { int charsRead = 0; if (this.atEndOfData) { return -1; } if ((offset + size) > buffer.length) { size = buffer.length - offset; } while (charsRead < size) { char ch = this.savedChar; if (ch == 0) { ch = this.reader.read(); } else { this.savedChar = 0; } if (ch == ']') { char ch2 = this.reader.read(); if (ch2 == ']') { char ch3 = this.reader.read(); if (ch3 == '>') { this.atEndOfData = true; break; } this.savedChar = ch2; this.reader.unread(ch3); } else { this.reader.unread(ch2); } } buffer[charsRead] = ch; charsRead++; } if (charsRead == 0) { charsRead = -1; } return charsRead; ### 215, getElementName, XMLValidationException, JHotDraw741 jhotdraw7/src/main/java/net/n3/nanoxml/XMLValidationException.java, 165, 167 4 /** * Returns the name of the element in which the validation is violated. * If there is no current element, null is returned. */ 3 public String getElementName() { return this.elementName; ### 216, getAttributeName, XMLValidationException, JHotDraw741 jhotdraw7/src/main/java/net/n3/nanoxml/XMLValidationException.java, 175, 177 4 /** * Returns the name of the attribute in which the validation is violated. * If there is no current attribute, null is returned. */ 3 public String getAttributeName() { return this.attributeName; ### 217, XMLValidationException, XMLValidationException, JHotDraw741 jhotdraw7/src/main/java/net/n3/nanoxml/XMLValidationException.java, 127, 144 12 /** * Creates a new exception. * * @param errorType the type of validity error * @param systemID the system ID from where the data came * @param lineNr the line number in the XML data where the * exception occurred. * @param elementName the name of the offending element * @param attributeName the name of the offending attribute * @param attributeValue the value of the offending attribute * @param msg the message of the exception. */ 18 public XMLValidationException(int errorType, String systemID, int lineNr, String elementName, String attributeName, String attributeValue, String msg) { super(systemID, lineNr, null, msg + ((elementName == null) ? "" : (", element=" + elementName)) + ((attributeName == null) ? "" : (", attribute=" + attributeName)) + ((attributeValue == null) ? "" : (", value='" + attributeValue + "'")), false); this.elementName = elementName; this.attributeName = attributeName; this.attributeValue = attributeValue; ### 218, finalize, XMLValidationException, JHotDraw741 jhotdraw7/src/main/java/net/n3/nanoxml/XMLValidationException.java, 151, 157 3 /** * Cleans up the object when it's destroyed. */ 7 protected void finalize() throws Throwable { this.elementName = null; this.attributeName = null; this.attributeValue = null; super.finalize(); ### 219, errorClosingTagNotEmpty, XMLUtil, JHotDraw741 jhotdraw7/src/main/java/net/n3/nanoxml/XMLUtil.java, 552, 557 7 /** * Throws an XMLParseException to indicate that extra data is encountered * in a closing tag. * * @param systemID the system ID of the data source * @param lineNr the line number in the data source */ 6 static void errorClosingTagNotEmpty(String systemID, int lineNr) throws XMLParseException { throw new XMLParseException(systemID, lineNr, "Closing tag must be empty"); ### 221, errorUnexpectedPCData, XMLUtil, JHotDraw741 jhotdraw7/src/main/java/net/n3/nanoxml/XMLUtil.java, 722, 733 8 /** * Throws an XMLValidationException to indicate that a #PCDATA element was * unexpected. * * @param systemID the system ID of the data source * @param lineNr the line number in the data source * @param parentElementName the name of the parent element */ 12 static void errorUnexpectedPCData(String systemID, int lineNr, String parentElementName) throws XMLValidationException { throw new XMLValidationException( XMLValidationException.UNEXPECTED_PCDATA, systemID, lineNr, /*elementName*/ null, /*attributeName*/ null, /*attributeValue*/ null, "Unexpected #PCDATA in element " + parentElementName); ### 223, errorUnexpectedCDATA, XMLUtil, JHotDraw741 jhotdraw7/src/main/java/net/n3/nanoxml/XMLUtil.java, 496, 501 7 /** * Throws an XMLParseException to indicate that a CDATA section is * unexpected at this point. * * @param systemID the system ID of the data source * @param lineNr the line number in the data source */ 6 static void errorUnexpectedCDATA(String systemID, int lineNr) throws XMLParseException { throw new XMLParseException(systemID, lineNr, "No CDATA section is expected here"); ### 225, errorInvalidAttributeValue, XMLUtil, JHotDraw741 jhotdraw7/src/main/java/net/n3/nanoxml/XMLUtil.java, 674, 687 10 /** * Throws an XMLValidationException to indicate that an attribute has an * invalid value. * * @param systemID the system ID of the data source * @param lineNr the line number in the data source * @param elementName the name of the element * @param attributeName the name of the attribute * @param attributeValue the value of that attribute */ 14 static void errorInvalidAttributeValue(String systemID, int lineNr, String elementName, String attributeName, String attributeValue) throws XMLValidationException { throw new XMLValidationException( XMLValidationException.ATTRIBUTE_WITH_INVALID_VALUE, systemID, lineNr, elementName, attributeName, attributeValue, "Invalid value for attribute " + attributeName); ### 227, errorUnexpectedAttribute, XMLUtil, JHotDraw741 jhotdraw7/src/main/java/net/n3/nanoxml/XMLUtil.java, 647, 660 9 /** * Throws an XMLValidationException to indicate that an attribute is * unexpected. * * @param systemID the system ID of the data source * @param lineNr the line number in the data source * @param elementName the name of the element * @param attributeName the name of the unexpected attribute */ 14 static void errorUnexpectedAttribute(String systemID, int lineNr, String elementName, String attributeName) throws XMLValidationException { throw new XMLValidationException( XMLValidationException.UNEXPECTED_ATTRIBUTE, systemID, lineNr, elementName, attributeName, /*attributeValue*/ null, "Element " + elementName + " did not expect an attribute " + "named " + attributeName); ### 230, scanPublicID, XMLUtil, JHotDraw741 jhotdraw7/src/main/java/net/n3/nanoxml/XMLUtil.java, 128, 140 11 /** * Scans a public ID. * * @param publicID will contain the public ID * @param reader the reader * * @return the system ID * * @throws java.io.IOException * if an error occurred reading the data */ 12 static String scanPublicID(StringBuffer publicID, IXMLReader reader) throws IOException, XMLParseException { if (! XMLUtil.checkLiteral(reader, "UBLIC")) { return null; } XMLUtil.skipWhitespace(reader, null); publicID.append(XMLUtil.scanString(reader, '\0', null)); XMLUtil.skipWhitespace(reader, null); return XMLUtil.scanString(reader, '\0', null); ### 231, errorWrongClosingTag, XMLUtil, JHotDraw741 jhotdraw7/src/main/java/net/n3/nanoxml/XMLUtil.java, 532, 541 9 /** * Throws an XMLParseException to indicate that the closing tag of an * element does not match the opening tag. * * @param systemID the system ID of the data source * @param lineNr the line number in the data source * @param expectedName the name of the opening tag * @param wrongName the name of the closing tag */ 10 static void errorWrongClosingTag(String systemID, int lineNr, String expectedName, String wrongName) throws XMLParseException { throw new XMLParseException(systemID, lineNr, "Closing tag does not match opening tag: `" + wrongName + "' != `" + expectedName + "'"); ### 232, readChar, XMLUtil, JHotDraw741 jhotdraw7/src/main/java/net/n3/nanoxml/XMLUtil.java, 391, 405 7 /** * Reads a character from the reader disallowing entities. * * @param reader the reader * @param entityChar the escape character (& or %) used to indicate * an entity */ 13 static char readChar(IXMLReader reader, char entityChar) throws IOException, XMLParseException { String str = XMLUtil.read(reader, entityChar); char ch = str.charAt(0); if (ch == entityChar) { XMLUtil.errorUnexpectedEntity(reader.getSystemID(), reader.getLineNr(), str); } return ch; ### 233, updateApplicationEnabled, AbstractApplicationAction, JHotDraw741 jhotdraw7/src/main/java/org/jhotdraw/app/action/AbstractApplicationAction.java, 91, 94 4 /** * Updates the enabled state of this action depending on the new enabled * state of the application. */ 4 protected void updateApplicationEnabled() { firePropertyChange("enabled", Boolean.valueOf(!isEnabled()), Boolean.valueOf(isEnabled())); ### 234, checkLiteral, XMLUtil, JHotDraw741 jhotdraw7/src/main/java/net/n3/nanoxml/XMLUtil.java, 419, 430 10 /** * Returns true if the data starts with literal. * Enough chars are read to determine this result. * * @param reader the reader * @param literal the literal to check * * @throws java.io.IOException * if an error occurred reading the data */ 11 static boolean checkLiteral(IXMLReader reader, String literal) throws IOException, XMLParseException { for (int i = 0; i < literal.length(); i++) { if (reader.read() != literal.charAt(i)) { return false; } } return true; ### 235, isEnabled, AbstractApplicationAction, JHotDraw741 jhotdraw7/src/main/java/org/jhotdraw/app/action/AbstractApplicationAction.java, 105, 107 8 /** * Returns true if the action is enabled. * The enabled state of the action depends on the state that has been set * using setEnabled() and on the enabled state of the application. * * @return true if the action is enabled, false otherwise * @see Action#isEnabled */ 3 @Override public boolean isEnabled() { return app != null && app.isEnabled() && enabled; ### 236, installApplicationListeners, AbstractApplicationAction, JHotDraw741 jhotdraw7/src/main/java/org/jhotdraw/app/action/AbstractApplicationAction.java, 58, 62 3 /* * Installs listeners on the application object. */ 5 protected void installApplicationListeners(Application app) { if (applicationListener == null) { applicationListener = createApplicationListener(); } app.addPropertyChangeListener(new WeakPropertyChangeListener(applicationListener)); ### 237, scanString, XMLUtil, JHotDraw741 jhotdraw7/src/main/java/net/n3/nanoxml/XMLUtil.java, 209, 256 10 /** * Retrieves a delimited string from the data. * * @param reader the reader * @param entityChar the escape character (& or %) * @param entityResolver the entity resolver * * @throws java.io.IOException * if an error occurred reading the data */ 44 static String scanString(IXMLReader reader, char entityChar, IXMLEntityResolver entityResolver) throws IOException, XMLParseException { StringBuffer result = new StringBuffer(); int startingLevel = reader.getStreamLevel(); char delim = reader.read(); if ((delim != '\'') && (delim != '"')) { XMLUtil.errorExpectedInput(reader.getSystemID(), reader.getLineNr(), "delimited string"); } for (;;) { String str = XMLUtil.read(reader, entityChar); char ch = str.charAt(0); if (ch == entityChar) { if (str.charAt(1) == '#') { result.append(XMLUtil.processCharLiteral(str)); } else { XMLUtil.processEntity(str, reader, entityResolver); } } else if (ch == '&') { reader.unread(ch); str = XMLUtil.read(reader, '&'); if (str.charAt(1) == '#') { result.append(XMLUtil.processCharLiteral(str)); } else { result.append(str); } } else if (reader.getStreamLevel() == startingLevel) { if (ch == delim) { break; } else if ((ch == 9) || (ch == 10) || (ch == 13)) { result.append(' '); } else { result.append(ch); } } else { result.append(ch); } } return result.toString(); ### 238, uninstallApplicationListeners, AbstractApplicationAction, JHotDraw741 jhotdraw7/src/main/java/org/jhotdraw/app/action/AbstractApplicationAction.java, 68, 69 3 /** * Installs listeners on the application object. */ 2 protected void uninstallApplicationListeners(Application app) { app.removePropertyChangeListener(applicationListener); ### 239, AbstractApplicationAction, AbstractApplicationAction, JHotDraw741 jhotdraw7/src/main/java/org/jhotdraw/app/action/AbstractApplicationAction.java, 49, 52 1 /** Creates a new instance. */ 4 public AbstractApplicationAction(Application app) { this.app = app; installApplicationListeners(app); updateApplicationEnabled(); ### 240, errorMissingAttribute, XMLUtil, JHotDraw741 jhotdraw7/src/main/java/net/n3/nanoxml/XMLUtil.java, 621, 634 9 /** * Throws an XMLValidationException to indicate that an attribute is * missing. * * @param systemID the system ID of the data source * @param lineNr the line number in the data source * @param elementName the name of the element * @param attributeName the name of the missing attribute */ 14 static void errorMissingAttribute(String systemID, int lineNr, String elementName, String attributeName) throws XMLValidationException { throw new XMLValidationException( XMLValidationException.MISSING_ATTRIBUTE, systemID, lineNr, elementName, attributeName, /*attributeValue*/ null, "Element " + elementName + " expects an attribute named " + attributeName); ### 241, scanSystemID, XMLUtil, JHotDraw741 jhotdraw7/src/main/java/net/n3/nanoxml/XMLUtil.java, 154, 163 10 /** * Scans a system ID. * * @param reader the reader * * @return the system ID * * @throws java.io.IOException * if an error occurred reading the data */ 9 static String scanSystemID(IXMLReader reader) throws IOException, XMLParseException { if (! XMLUtil.checkLiteral(reader, "YSTEM")) { return null; } XMLUtil.skipWhitespace(reader, null); return XMLUtil.scanString(reader, '\0', null); ### 242, skipComment, XMLUtil, JHotDraw741 jhotdraw7/src/main/java/net/n3/nanoxml/XMLUtil.java, 55, 81 9 /** * Skips the remainder of a comment. * It is assumed that <!- is already read. * * @param reader the reader * * @throws java.io.IOException * if an error occurred reading the data */ 23 static void skipComment(IXMLReader reader) throws IOException, XMLParseException { if (reader.read() != '-') { XMLUtil.errorExpectedInput(reader.getSystemID(), reader.getLineNr(), "