📄 xmlelement.java
字号:
* @deprecated Use {@link #getStringAttribute(java.lang.String, * java.lang.String) getStringAttribute} instead. */ public String getProperty(String name, String defaultValue) { return this.getStringAttribute(name, defaultValue); } /** * Returns an attribute. * * @deprecated Use {@link #getIntAttribute(java.lang.String, int) * getIntAttribute} instead. */ public int getProperty(String name, int defaultValue) { return this.getIntAttribute(name, defaultValue); } /** * Returns an attribute. * * @deprecated Use {@link #getDoubleAttribute(java.lang.String, double) * getDoubleAttribute} instead. */ public double getProperty(String name, double defaultValue) { return this.getDoubleAttribute(name, defaultValue); } /** * Returns an attribute. * * @deprecated Use {@link #getBooleanAttribute(java.lang.String, * java.lang.String, java.lang.String, boolean) * getBooleanAttribute} instead. */ public boolean getProperty(String key, String trueValue, String falseValue, boolean defaultValue) { return this.getBooleanAttribute(key, trueValue, falseValue, defaultValue); } /** * Returns an attribute by looking up a key in a hashtable. * * @deprecated Use {@link #getAttribute(java.lang.String, * java.util.Hashtable, java.lang.String, boolean) * getAttribute} instead. */ public Object getProperty(String name, Hashtable valueSet, String defaultKey) { return this.getAttribute(name, valueSet, defaultKey, false); } /** * Returns an attribute by looking up a key in a hashtable. * * @deprecated Use {@link #getStringAttribute(java.lang.String, * java.util.Hashtable, java.lang.String, boolean) * getStringAttribute} instead. */ public String getStringProperty(String name, Hashtable valueSet, String defaultKey) { return this.getStringAttribute(name, valueSet, defaultKey, false); } /** * Returns an attribute by looking up a key in a hashtable. * * @deprecated Use {@link #getIntAttribute(java.lang.String, * java.util.Hashtable, java.lang.String, boolean) * getIntAttribute} instead. */ public int getSpecialIntProperty(String name, Hashtable valueSet, String defaultKey) { return this.getIntAttribute(name, valueSet, defaultKey, true); } /** * Returns an attribute by looking up a key in a hashtable. * * @deprecated Use {@link #getDoubleAttribute(java.lang.String, * java.util.Hashtable, java.lang.String, boolean) * getDoubleAttribute} instead. */ public double getSpecialDoubleProperty(String name, Hashtable valueSet, String defaultKey) { return this.getDoubleAttribute(name, valueSet, defaultKey, true); } /** * Returns the name of the element. * * @see nanoxml.XMLElement#setName(java.lang.String) setName(String) */ public String getName() { return this.name; } /** * Returns the name of the element. * * @deprecated Use {@link #getName() getName} instead. */ public String getTagName() { return this.getName(); } /** * Reads one XML element from a java.io.Reader and parses it. * * @param reader * The reader from which to retrieve the XML data. * * </dl><dl><dt><b>Preconditions:</b></dt><dd> * <ul><li><code>reader != null</code> * <li><code>reader</code> is not closed * </ul></dd></dl> * * <dl><dt><b>Postconditions:</b></dt><dd> * <ul><li>the state of the receiver is updated to reflect the XML element * parsed from the reader * <li>the reader points to the first character following the last * '>' character of the XML element * </ul></dd></dl><dl> * * @throws java.io.IOException * If an error occured while reading the input. * @throws nanoxml.XMLParseException * If an error occured while parsing the read data. */ public void parseFromReader(Reader reader) throws IOException, XMLParseException { this.parseFromReader(reader, /*startingLineNr*/ 1); } /** * Reads one XML element from a java.io.Reader and parses it. * * @param reader * The reader from which to retrieve the XML data. * @param startingLineNr * The line number of the first line in the data. * * </dl><dl><dt><b>Preconditions:</b></dt><dd> * <ul><li><code>reader != null</code> * <li><code>reader</code> is not closed * </ul></dd></dl> * * <dl><dt><b>Postconditions:</b></dt><dd> * <ul><li>the state of the receiver is updated to reflect the XML element * parsed from the reader * <li>the reader points to the first character following the last * '>' character of the XML element * </ul></dd></dl><dl> * * @throws java.io.IOException * If an error occured while reading the input. * @throws nanoxml.XMLParseException * If an error occured while parsing the read data. */ public void parseFromReader(Reader reader, int startingLineNr) throws IOException, XMLParseException { this.charReadTooMuch = '\0'; this.reader = reader; this.parserLineNr = startingLineNr; for (;;) { char ch = this.scanWhitespace(); if (ch != '<') { throw this.expectedInput("<"); } ch = this.readChar(); if ((ch == '!') || (ch == '?')) { this.skipSpecialTag(0); } else { this.unreadChar(ch); this.scanElement(this); return; } } } /** * Reads one XML element from a String and parses it. * * @param reader * The reader from which to retrieve the XML data. * * </dl><dl><dt><b>Preconditions:</b></dt><dd> * <ul><li><code>string != null</code> * <li><code>string.length() > 0</code> * </ul></dd></dl> * * <dl><dt><b>Postconditions:</b></dt><dd> * <ul><li>the state of the receiver is updated to reflect the XML element * parsed from the reader * </ul></dd></dl><dl> * * @throws nanoxml.XMLParseException * If an error occured while parsing the string. */ public void parseString(String string) throws XMLParseException { try { this.parseFromReader(new StringReader(string), /*startingLineNr*/ 1); } catch (IOException e) { // Java exception handling suxx } } /** * Reads one XML element from a String and parses it. * * @param reader * The reader from which to retrieve the XML data. * @param offset * The first character in <code>string</code> to scan. * * </dl><dl><dt><b>Preconditions:</b></dt><dd> * <ul><li><code>string != null</code> * <li><code>offset < string.length()</code> * <li><code>offset >= 0</code> * </ul></dd></dl> * * <dl><dt><b>Postconditions:</b></dt><dd> * <ul><li>the state of the receiver is updated to reflect the XML element * parsed from the reader * </ul></dd></dl><dl> * * @throws nanoxml.XMLParseException * If an error occured while parsing the string. */ public void parseString(String string, int offset) throws XMLParseException { this.parseString(string.substring(offset)); } /** * Reads one XML element from a String and parses it. * * @param reader * The reader from which to retrieve the XML data. * @param offset * The first character in <code>string</code> to scan. * @param end * The character where to stop scanning. * This character is not scanned. * * </dl><dl><dt><b>Preconditions:</b></dt><dd> * <ul><li><code>string != null</code> * <li><code>end <= string.length()</code> * <li><code>offset < end</code> * <li><code>offset >= 0</code> * </ul></dd></dl> * * <dl><dt><b>Postconditions:</b></dt><dd> * <ul><li>the state of the receiver is updated to reflect the XML element * parsed from the reader * </ul></dd></dl><dl> * * @throws nanoxml.XMLParseException * If an error occured while parsing the string. */ public void parseString(String string, int offset, int end) throws XMLParseException { this.parseString(string.substring(offset, end)); } /** * Reads one XML element from a String and parses it. * * @param reader * The reader from which to retrieve the XML data. * @param offset * The first character in <code>string</code> to scan. * @param end * The character where to stop scanning. * This character is not scanned. * @param startingLineNr * The line number of the first line in the data. * * </dl><dl><dt><b>Preconditions:</b></dt><dd> * <ul><li><code>string != null</code> * <li><code>end <= string.length()</code> * <li><code>offset < end</code> * <li><code>offset >= 0</code> * </ul></dd></dl> * * <dl><dt><b>Postconditions:</b></dt><dd> * <ul><li>the state of the receiver is updated to reflect the XML element * parsed from the reader * </ul></dd></dl><dl> * * @throws nanoxml.XMLParseException * If an error occured while parsing the string. */ public void parseString(String string, int offset, int end, int startingLineNr) throws XMLParseException { string = string.substring(offset, end); try { this.parseFromReader(new StringReader(string), startingLineNr); } catch (IOException e) { // Java exception handling suxx } } /** * Reads one XML element from a char array and parses it. * * @param reader * The reader from which to retrieve the XML data. * @param offset * The first character in <code>string</code> to scan. * @param end * The character where to stop scanning. * This character is not scanned. * * </dl><dl><dt><b>Preconditions:</b></dt><dd>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -