| java.lang.Object com.jidesoft.plaf.aqua.XMLElement
XMLElement | class XMLElement (Code) | | XMLElement is a representation of an XML object. The object is able to parse
XML code.
- Parsing XML Data
-
You can parse XML data using the following code:
XMLElement xml = new XMLElement();
FileReader reader = new FileReader("filename.xml");
xml.parseFromReader(reader);
- Retrieving Attributes
-
You can enumerate the attributes of an element using the method
XMLElement.enumerateAttributeNames() enumerateAttributeNames .
The attribute values can be retrieved using the method
XMLElement.getStringAttribute(String) getStringAttribute .
The following example shows how to list the attributes of an element:
XMLElement element = ...;
Iterator iter = element.getAttributeNames();
while (iter.hasNext()) {
String key = (String) iter.next();
String value = element.getStringAttribute(key);
System.out.println(key + " = " + value);
}
- Retrieving Child Elements
-
You can enumerate the children of an element using
XMLElement.iterateChildren() iterateChildren .
The number of child iterator can be retrieved using
XMLElement.countChildren() countChildren .
- Elements Containing Character Data
-
If an iterator contains character data, like in the following example:
you can retrieve that data using the method
XMLElement.getContent() getContent .
- Subclassing XMLElement
-
When subclassing XMLElement, you need to override the method
XMLElement.createAnotherElement() createAnotherElement which has to return a new copy of the receiver.
author: Marc De Scheemaecker author: <cyberelf@mac.com> version: 2005-06-18 Werner Randelshofer: Adapted for Java 2 Collections API. version: $Name: RELEASE_2_2_1 $, $Revision: 1.4 $ See Also: XMLParseException |
Constructor Summary | |
public | XMLElement() Creates and initializes a new XML element. | public | XMLElement(HashMap entities) Creates and initializes a new XML element. | public | XMLElement(boolean skipLeadingWhitespace) Creates and initializes a new XML element. | public | XMLElement(HashMap entities, boolean skipLeadingWhitespace) Creates and initializes a new XML element. | public | XMLElement(HashMap entities, boolean skipLeadingWhitespace, boolean ignoreCase) Creates and initializes a new XML element. | protected | XMLElement(HashMap entities, boolean skipLeadingWhitespace, boolean fillBasicConversionTable, boolean ignoreCase) Creates and initializes a new XML element. |
Method Summary | |
public void | addChild(XMLElement child) Adds a child element. | public void | addProperty(String name, Object value) Adds or modifies an attribute. | public void | addProperty(String key, int value) Adds or modifies an attribute. | public void | addProperty(String name, double value) Adds or modifies an attribute. | protected boolean | checkCDATA(StringBuffer buf) Scans a special tag and if the tag is a CDATA section, append its
content to buf . | protected boolean | checkLiteral(String literal) Scans the data for literal text. | public int | countChildren() Returns the number of child iterator of the element. | public XMLElement | createAnotherElement() Creates a new similar XML element. | public Iterator | enumerateAttributeNames() Enumerates the attribute names. | public Iterator | enumeratePropertyNames() Enumerates the attribute names. | protected XMLParseException | expectedInput(String charSet) Creates a parse exception for when the next character read is not
the character that was expected. | public Object | getAttribute(String name) Returns an attribute of the element. | public Object | getAttribute(String name, Object defaultValue) Returns an attribute of the element. | public Object | getAttribute(String name, HashMap valueSet, String defaultKey, boolean allowLiterals) Returns an attribute by looking up a key in a hashtable. | public boolean | getBooleanAttribute(String name, String trueValue, String falseValue, boolean defaultValue) Returns an attribute of the element. | public ArrayList | getChildren() Returns the child iterator as a ArrayList. | public String | getContent() Returns the PCDATA content of the object. | public String | getContents() Returns the PCDATA content of the object. | public double | getDoubleAttribute(String name) Returns an attribute of the element. | public double | getDoubleAttribute(String name, double defaultValue) Returns an attribute of the element. | public double | getDoubleAttribute(String name, HashMap valueSet, String defaultKey, boolean allowLiteralNumbers) Returns an attribute by looking up a key in a hashtable. | public int | getIntAttribute(String name) Returns an attribute of the element. | public int | getIntAttribute(String name, int defaultValue) Returns an attribute of the element. | public int | getIntAttribute(String name, HashMap valueSet, String defaultKey, boolean allowLiteralNumbers) Returns an attribute by looking up a key in a hashtable. | public int | getIntProperty(String name, HashMap valueSet, String defaultKey) Returns an attribute by looking up a key in a hashtable. | public int | getLineNr() Returns the line nr in the source data on which the element is found. | public String | getName() Returns the name of the element. | public String | getProperty(String name) Returns an attribute. | public String | getProperty(String name, String defaultValue) Returns an attribute. | public int | getProperty(String name, int defaultValue) Returns an attribute. | public double | getProperty(String name, double defaultValue) Returns an attribute. | public boolean | getProperty(String key, String trueValue, String falseValue, boolean defaultValue) Returns an attribute. | public Object | getProperty(String name, HashMap valueSet, String defaultKey) Returns an attribute by looking up a key in a hashtable. | public double | getSpecialDoubleProperty(String name, HashMap valueSet, String defaultKey) Returns an attribute by looking up a key in a hashtable. | public int | getSpecialIntProperty(String name, HashMap valueSet, String defaultKey) Returns an attribute by looking up a key in a hashtable. | public String | getStringAttribute(String name) Returns an attribute of the element. | public String | getStringAttribute(String name, String defaultValue) Returns an attribute of the element. | public String | getStringAttribute(String name, HashMap valueSet, String defaultKey, boolean allowLiterals) Returns an attribute by looking up a key in a hashtable. | public String | getStringProperty(String name, HashMap valueSet, String defaultKey) Returns an attribute by looking up a key in a hashtable. | public String | getTagName() Returns the name of the element. | protected XMLParseException | invalidValue(String name, String value) Creates a parse exception for when an invalid value is given to a
method. | protected XMLParseException | invalidValueSet(String name) Creates a parse exception for when an invalid valueset is given to
a method. | public Iterator | iterateChildren() Enumerates the child iterator. | public void | parseCharArray(char[] input, int offset, int end) Reads one XML element from a char array and parses it. | public void | parseCharArray(char[] input, int offset, int end, int startingLineNr) Reads one XML element from a char array and parses it. | public void | parseFromReader(Reader reader) Reads one XML element from a java.io.Reader and parses it. | public void | parseFromReader(Reader reader, int startingLineNr) Reads one XML element from a java.io.Reader and parses it. | public void | parseString(String string) Reads one XML element from a String and parses it. | public void | parseString(String string, int offset) Reads one XML element from a String and parses it. | public void | parseString(String string, int offset, int end) Reads one XML element from a String and parses it. | public void | parseString(String string, int offset, int end, int startingLineNr) Reads one XML element from a String and parses it. | protected char | readChar() Reads a character from a reader. | public void | removeAttribute(String name) Removes an attribute. | public void | removeChild(XMLElement child) Removes a child element. | public void | removeChild(String name) Removes an attribute. | public void | removeProperty(String name) Removes an attribute. | protected void | resolveEntity(StringBuffer buf) Resolves an entity. | protected void | scanElement(XMLElement elt) Scans an XML element. | protected void | scanIdentifier(StringBuffer result) Scans an identifier from the current reader. | protected void | scanPCData(StringBuffer data) Scans a #PCDATA element. | protected void | scanString(StringBuffer string) This method scans a delimited string from the current reader. | protected char | scanWhitespace() This method scans an identifier from the current reader. | protected char | scanWhitespace(StringBuffer result) This method scans an identifier from the current reader. | public void | setAttribute(String name, Object value) Adds or modifies an attribute. | public void | setContent(String content) Changes the content string. | public void | setDoubleAttribute(String name, double value) Adds or modifies an attribute. | public void | setIntAttribute(String name, int value) Adds or modifies an attribute. | public void | setName(String name) Changes the name of the element. | public void | setTagName(String name) Changes the name of the element. | protected void | skipComment() Skips a comment. | protected void | skipSpecialTag(int bracketLevel) Skips a special tag or comment. | protected XMLParseException | syntaxError(String context) Creates a parse exception for when a syntax error occured. | public String | toString() Writes the XML element to a string. | protected XMLParseException | unexpectedEndOfData() Creates a parse exception for when the end of the data input has been
reached. | protected XMLParseException | unknownEntity(String name) Creates a parse exception for when an entity could not be resolved. | protected void | unreadChar(char ch) Pushes a character back to the read-back buffer. | public void | write(Writer writer) Writes the XML element to a writer. | protected void | writeEncoded(Writer writer, String str) Writes a string encoded to a writer. |
NANOXML_MAJOR_VERSION | final public static int NANOXML_MAJOR_VERSION(Code) | | Major version of NanoXML. Classes with the same major and minor
version are binary compatible. Classes with the same major version
are source compatible. If the major version is different, you may
need to modify the client source code.
See Also: XMLElement.NANOXML_MINOR_VERSION |
NANOXML_MINOR_VERSION | final public static int NANOXML_MINOR_VERSION(Code) | | Minor version of NanoXML. Classes with the same major and minor
version are binary compatible. Classes with the same major version
are source compatible. If the major version is different, you may
need to modify the client source code.
See Also: XMLElement.NANOXML_MAJOR_VERSION |
serialVersionUID | final static long serialVersionUID(Code) | | Serialization serial version ID.
|
XMLElement | public XMLElement(HashMap entities)(Code) | | Creates and initializes a new XML element.
Calling the construction is equivalent to:
new XMLElement(entities, false, true)
Parameters: entities - The entity conversion table.- Preconditions:
- Postconditions:
- countChildren() => 0
- iterateChildren() => empty enumeration
- enumeratePropertyNames() => empty enumeration
- getChildren() => empty vector
- getContent() => ""
- getLineNr() => 0
- getName() => null
See Also: XMLElement.XMLElement See Also: XMLElement.XMLElement(boolean) See Also: XMLElement.XMLElement(java.util.HashMapboolean) See Also: XMLElement(HashMap, boolean)
|
XMLElement | public XMLElement(boolean skipLeadingWhitespace)(Code) | | Creates and initializes a new XML element.
Calling the construction is equivalent to:
new XMLElement(new HashMap(), skipLeadingWhitespace, true)
Parameters: skipLeadingWhitespace - true if leading and trailing whitespace in PCDATAcontent has to be removed.- Postconditions:
- countChildren() => 0
- iterateChildren() => empty enumeration
- enumeratePropertyNames() => empty enumeration
- getChildren() => empty vector
- getContent() => ""
- getLineNr() => 0
- getName() => null
See Also: XMLElement.XMLElement See Also: XMLElement.XMLElement(java.util.HashMap) See Also: XMLElement(HashMap) See Also: XMLElement.XMLElement(java.util.HashMapboolean) See Also: XMLElement(HashMap, boolean)
|
XMLElement | public XMLElement(HashMap entities, boolean skipLeadingWhitespace)(Code) | | Creates and initializes a new XML element.
Calling the construction is equivalent to:
new XMLElement(entities, skipLeadingWhitespace, true)
Parameters: entities - The entity conversion table. Parameters: skipLeadingWhitespace - true if leading and trailing whitespace in PCDATAcontent has to be removed.- Preconditions:
- Postconditions:
- countChildren() => 0
- iterateChildren() => empty enumeration
- enumeratePropertyNames() => empty enumeration
- getChildren() => empty vector
- getContent() => ""
- getLineNr() => 0
- getName() => null
See Also: XMLElement.XMLElement See Also: XMLElement.XMLElement(boolean) See Also: XMLElement.XMLElement(java.util.HashMap) See Also: XMLElement(HashMap)
|
XMLElement | public XMLElement(HashMap entities, boolean skipLeadingWhitespace, boolean ignoreCase)(Code) | | Creates and initializes a new XML element.
Parameters: entities - The entity conversion table. Parameters: skipLeadingWhitespace - true if leading and trailing whitespace in PCDATAcontent has to be removed. Parameters: ignoreCase - true if the case of element and attribute names haveto be ignored.- Preconditions:
- Postconditions:
- countChildren() => 0
- iterateChildren() => empty enumeration
- enumeratePropertyNames() => empty enumeration
- getChildren() => empty vector
- getContent() => ""
- getLineNr() => 0
- getName() => null
See Also: XMLElement.XMLElement See Also: XMLElement.XMLElement(boolean) See Also: XMLElement.XMLElement(java.util.HashMap) See Also: XMLElement(HashMap) See Also: XMLElement.XMLElement(java.util.HashMapboolean) See Also: XMLElement(HashMap, boolean)
|
XMLElement | protected XMLElement(HashMap entities, boolean skipLeadingWhitespace, boolean fillBasicConversionTable, boolean ignoreCase)(Code) | | Creates and initializes a new XML element.
This constructor should only be called from
XMLElement.createAnotherElement() createAnotherElement to create child iterator.
Parameters: entities - The entity conversion table. Parameters: skipLeadingWhitespace - true if leading and trailing whitespace in PCDATAcontent has to be removed. Parameters: fillBasicConversionTable - true if the basic entities need to be added tothe entity list. Parameters: ignoreCase - true if the case of element and attribute names haveto be ignored.- Preconditions:
entities != null - if
fillBasicConversionTable == false then entities contains at least the followingentries: amp , lt , gt ,apos and quot
- Postconditions:
- countChildren() => 0
- iterateChildren() => empty enumeration
- enumeratePropertyNames() => empty enumeration
- getChildren() => empty vector
- getContent() => ""
- getLineNr() => 0
- getName() => null
See Also: XMLElement.createAnotherElement
|
checkCDATA | protected boolean checkCDATA(StringBuffer buf) throws IOException(Code) | | Scans a special tag and if the tag is a CDATA section, append its
content to buf .
- Preconditions:
-
buf != null
- The first < has already been read.
|
checkLiteral | protected boolean checkLiteral(String literal) throws IOException(Code) | | Scans the data for literal text.
Scanning stops when a character does not match or after the complete
text has been checked, whichever comes first.
Parameters: literal - the literal to check.- Preconditions:
|
createAnotherElement | public XMLElement createAnotherElement()(Code) | | Creates a new similar XML element.
You should override this method when subclassing XMLElement.
|
enumerateAttributeNames | public Iterator enumerateAttributeNames()(Code) | | Enumerates the attribute names.
- Postconditions:
-
See Also: XMLElement.setDoubleAttribute(Stringdouble) See Also: setDoubleAttribute(String, double) See Also: XMLElement.setIntAttribute(Stringint) See Also: setIntAttribute(String, int) See Also: XMLElement.setAttribute(StringObject) See Also: setAttribute(String, Object) See Also: XMLElement.removeAttribute(String) See Also: removeAttribute(String) See Also: XMLElement.getAttribute(String) See Also: getAttribute(String) See Also: XMLElement.getAttribute(StringObject) See Also: getAttribute(String, String) See Also: XMLElement.getAttribute(Stringjava.util.HashMapStringboolean) See Also: getAttribute(String, HashMap, String, boolean) See Also: XMLElement.getStringAttribute(String) See Also: getStringAttribute(String) See Also: XMLElement.getStringAttribute(StringString) See Also: getStringAttribute(String, String) See Also: XMLElement.getStringAttribute(Stringjava.util.HashMapStringboolean) See Also: getStringAttribute(String, HashMap, String, boolean) See Also: XMLElement.getIntAttribute(String) See Also: getIntAttribute(String) See Also: XMLElement.getIntAttribute(Stringint) See Also: getIntAttribute(String, int) See Also: XMLElement.getIntAttribute(Stringjava.util.HashMapStringboolean) See Also: getIntAttribute(String, HashMap, String, boolean) See Also: XMLElement.getDoubleAttribute(String) See Also: getDoubleAttribute(String) See Also: XMLElement.getDoubleAttribute(Stringdouble) See Also: getDoubleAttribute(String, double) See Also: XMLElement.getDoubleAttribute(Stringjava.util.HashMapStringboolean) See Also: getDoubleAttribute(String, HashMap, String, boolean) See Also: XMLElement.getBooleanAttribute(StringStringStringboolean) See Also: getBooleanAttribute(String, String, String, boolean) |
expectedInput | protected XMLParseException expectedInput(String charSet)(Code) | | Creates a parse exception for when the next character read is not
the character that was expected.
Parameters: charSet - The set of characters (in human readable form) that wasexpected.- Preconditions:
charSet != null charSet.length() > 0
|
getAttribute | public Object getAttribute(String name, HashMap valueSet, String defaultKey, boolean allowLiterals)(Code) | | Returns an attribute by looking up a key in a hashtable.
If the attribute doesn't exist, the value corresponding to defaultKey
is returned.
As an example, if valueSet contains the mapping "one" =>
"1"
and the element contains the attribute attr="one" , then
getAttribute("attr", mapping, defaultKey, false) returns
"1" .
Parameters: name - The name of the attribute. Parameters: valueSet - HashMap mapping keySet().iterator to values. Parameters: defaultKey - Key to use if the attribute is missing. Parameters: allowLiterals - true if literals are valid.- Preconditions:
name != null name is a valid XML identifiervalueSet != null- the keySet().iterator of
valueSet are strings
See Also: XMLElement.setAttribute(StringObject) See Also: setAttribute(String, Object) See Also: XMLElement.removeAttribute(String) See Also: removeAttribute(String) See Also: XMLElement.enumerateAttributeNames See Also: XMLElement.getAttribute(String) See Also: getAttribute(String) See Also: XMLElement.getAttribute(StringObject) See Also: getAttribute(String, Object)
|
getBooleanAttribute | public boolean getBooleanAttribute(String name, String trueValue, String falseValue, boolean defaultValue)(Code) | | Returns an attribute of the element.
If the attribute doesn't exist, defaultValue is returned.
If the value of the attribute is equal to trueValue ,
true is returned.
If the value of the attribute is equal to falseValue ,
false is returned.
If the value doesn't match trueValue or
falseValue , an exception is thrown.
Parameters: name - The name of the attribute. Parameters: trueValue - The value associated with true . Parameters: falseValue - The value associated with true . Parameters: defaultValue - Value to use if the attribute is missing.- Preconditions:
name != null name is a valid XML identifiertrueValue and falseValue are different strings.
See Also: XMLElement.setAttribute(StringObject) See Also: setAttribute(String, Object) See Also: XMLElement.removeAttribute(String) See Also: removeAttribute(String) See Also: XMLElement.enumerateAttributeNames
|
getDoubleAttribute | public double getDoubleAttribute(String name, HashMap valueSet, String defaultKey, boolean allowLiteralNumbers)(Code) | | Returns an attribute by looking up a key in a hashtable.
If the attribute doesn't exist, the value corresponding to defaultKey
is returned.
As an example, if valueSet contains the mapping "one" =>
1.0
and the element contains the attribute attr="one" , then
getDoubleAttribute("attr", mapping, defaultKey, false)
returns 1.0 .
Parameters: name - The name of the attribute. Parameters: valueSet - HashMap mapping keySet().iterator to values. Parameters: defaultKey - Key to use if the attribute is missing. Parameters: allowLiteralNumbers - true if literal numbers are valid.- Preconditions:
name != null name is a valid XML identifiervalueSet != null - the keySet().iterator of
valueSet are strings - the values of
valueSet are Double objects defaultKey is either null , akey in valueSet or a double.
See Also: XMLElement.setDoubleAttribute(Stringdouble) See Also: setDoubleAttribute(String, double) See Also: XMLElement.enumerateAttributeNames See Also: XMLElement.getDoubleAttribute(String) See Also: getDoubleAttribute(String) See Also: XMLElement.getDoubleAttribute(Stringdouble) See Also: getDoubleAttribute(String, double)
|
getIntAttribute | public int getIntAttribute(String name, HashMap valueSet, String defaultKey, boolean allowLiteralNumbers)(Code) | | Returns an attribute by looking up a key in a hashtable.
If the attribute doesn't exist, the value corresponding to defaultKey
is returned.
As an example, if valueSet contains the mapping "one" => 1
and the element contains the attribute attr="one" , then
getIntAttribute("attr", mapping, defaultKey, false) returns
1 .
Parameters: name - The name of the attribute. Parameters: valueSet - HashMap mapping keySet().iterator to values. Parameters: defaultKey - Key to use if the attribute is missing. Parameters: allowLiteralNumbers - true if literal numbers are valid.- Preconditions:
name != null name is a valid XML identifiervalueSet != null- the keySet().iterator of
valueSet are strings - the values of
valueSet are Integer objects defaultKey is either null , akey in valueSet or an integer.
See Also: XMLElement.setIntAttribute(Stringint) See Also: setIntAttribute(String, int) See Also: XMLElement.enumerateAttributeNames See Also: XMLElement.getIntAttribute(String) See Also: getIntAttribute(String) See Also: XMLElement.getIntAttribute(Stringint) See Also: getIntAttribute(String, int)
|
getLineNr | public int getLineNr()(Code) | | Returns the line nr in the source data on which the element is found.
This method returns 0 there is no associated source data.
- Postconditions:
-
|
getStringAttribute | public String getStringAttribute(String name, HashMap valueSet, String defaultKey, boolean allowLiterals)(Code) | | Returns an attribute by looking up a key in a hashtable.
If the attribute doesn't exist, the value corresponding to defaultKey
is returned.
As an example, if valueSet contains the mapping "one" =>
"1"
and the element contains the attribute attr="one" , then
getAttribute("attr", mapping, defaultKey, false) returns
"1" .
Parameters: name - The name of the attribute. Parameters: valueSet - HashMap mapping keySet().iterator to values. Parameters: defaultKey - Key to use if the attribute is missing. Parameters: allowLiterals - true if literals are valid.- Preconditions:
name != null name is a valid XML identifiervalueSet != null- the keySet().iterator of
valueSet are strings - the values of
valueSet are strings
See Also: XMLElement.setAttribute(StringObject) See Also: setAttribute(String, Object) See Also: XMLElement.removeAttribute(String) See Also: removeAttribute(String) See Also: XMLElement.enumerateAttributeNames See Also: XMLElement.getStringAttribute(String) See Also: getStringAttribute(String) See Also: XMLElement.getStringAttribute(StringString) See Also: getStringAttribute(String, String)
|
invalidValue | protected XMLParseException invalidValue(String name, String value)(Code) | | Creates a parse exception for when an invalid value is given to a
method.
Parameters: name - The name of the entity. Parameters: value - The value of the entity.- Preconditions:
name != null value != null
|
invalidValueSet | protected XMLParseException invalidValueSet(String name)(Code) | | Creates a parse exception for when an invalid valueset is given to
a method.
Parameters: name - The name of the entity.- Preconditions:
|
parseCharArray | public void parseCharArray(char[] input, int offset, int end) throws XMLParseException(Code) | | Reads one XML element from a char array and parses it.
Parameters: input - The reader from which to retrieve the XML data. Parameters: offset - The first character in string to scan. Parameters: end - The character where to stop scanning.This character is not scanned.- Preconditions:
input != null end <= input.length offset < end offset >= 0
- Postconditions:
- the state of the receiver is updated to reflect the XML elementparsed from the reader
throws: XMLParseException - If an error occured while parsing the string.
|
parseCharArray | public void parseCharArray(char[] input, int offset, int end, int startingLineNr) throws XMLParseException(Code) | | Reads one XML element from a char array and parses it.
Parameters: input - The reader from which to retrieve the XML data. Parameters: offset - The first character in string to scan. Parameters: end - The character where to stop scanning.This character is not scanned. Parameters: startingLineNr - The line number of the first line in the data.- Preconditions:
input != null end <= input.length offset < end offset >= 0
- Postconditions:
- the state of the receiver is updated to reflect the XML elementparsed from the reader
throws: XMLParseException - If an error occured while parsing the string.
|
parseFromReader | public void parseFromReader(Reader reader) throws IOException, XMLParseException(Code) | | Reads one XML element from a java.io.Reader and parses it.
Parameters: reader - The reader from which to retrieve the XML data.- Preconditions:
reader != null reader is not closed
- Postconditions:
- the state of the receiver is updated to reflect the XML elementparsed from the reader
- the reader points to the first character following the last'>' character of the XML element
throws: java.io.IOException - If an error occured while reading the input. throws: XMLParseException - If an error occured while parsing the read data.
|
parseFromReader | public void parseFromReader(Reader reader, int startingLineNr) throws IOException, XMLParseException(Code) | | Reads one XML element from a java.io.Reader and parses it.
Parameters: reader - The reader from which to retrieve the XML data. Parameters: startingLineNr - The line number of the first line in the data.- Preconditions:
reader != null reader is not closed
- Postconditions:
- the state of the receiver is updated to reflect the XML elementparsed from the reader
- the reader points to the first character following the last'>' character of the XML element
throws: java.io.IOException - If an error occured while reading the input. throws: XMLParseException - If an error occured while parsing the read data.
|
parseString | public void parseString(String string) throws XMLParseException(Code) | | Reads one XML element from a String and parses it.
Parameters: string - The reader from which to retrieve the XML data.- Preconditions:
string != null string.length() > 0
- Postconditions:
- the state of the receiver is updated to reflect the XML elementparsed from the reader
throws: XMLParseException - If an error occured while parsing the string.
|
parseString | public void parseString(String string, int offset) throws XMLParseException(Code) | | Reads one XML element from a String and parses it.
Parameters: string - The reader from which to retrieve the XML data. Parameters: offset - The first character in string to scan.- Preconditions:
string != null offset < string.length() offset >= 0
- Postconditions:
- the state of the receiver is updated to reflect the XML elementparsed from the reader
throws: XMLParseException - If an error occured while parsing the string.
|
parseString | public void parseString(String string, int offset, int end) throws XMLParseException(Code) | | Reads one XML element from a String and parses it.
Parameters: string - The reader from which to retrieve the XML data. Parameters: offset - The first character in string to scan. Parameters: end - The character where to stop scanning.This character is not scanned.- Preconditions:
string != null end <= string.length() offset < end offset >= 0
- Postconditions:
- the state of the receiver is updated to reflect the XML elementparsed from the reader
throws: XMLParseException - If an error occured while parsing the string.
|
parseString | public void parseString(String string, int offset, int end, int startingLineNr) throws XMLParseException(Code) | | Reads one XML element from a String and parses it.
Parameters: string - The reader from which to retrieve the XML data. Parameters: offset - The first character in string to scan. Parameters: end - The character where to stop scanning.This character is not scanned. Parameters: startingLineNr - The line number of the first line in the data.- Preconditions:
string != null end <= string.length() offset < end offset >= 0
- Postconditions:
- the state of the receiver is updated to reflect the XML elementparsed from the reader
throws: XMLParseException - If an error occured while parsing the string.
|
readChar | protected char readChar() throws IOException(Code) | | Reads a character from a reader.
|
removeAttribute | public void removeAttribute(String name)(Code) | | Removes an attribute.
Parameters: name - The name of the attribute.- Preconditions:
name != null name is a valid XML identifier
- Postconditions:
- enumerateAttributeNames()=> old.enumerateAttributeNames() - name
- getAttribute(name) =>
null
See Also: XMLElement.enumerateAttributeNames See Also: XMLElement.setDoubleAttribute(Stringdouble) See Also: setDoubleAttribute(String, double) See Also: XMLElement.setIntAttribute(Stringint) See Also: setIntAttribute(String, int) See Also: XMLElement.setAttribute(StringObject) See Also: setAttribute(String, Object) See Also: XMLElement.getAttribute(String) See Also: getAttribute(String) See Also: XMLElement.getAttribute(StringObject) See Also: getAttribute(String, Object) See Also: XMLElement.getAttribute(Stringjava.util.HashMapStringboolean) See Also: getAttribute(String, HashMap, String, boolean) See Also: XMLElement.getStringAttribute(String) See Also: getStringAttribute(String) See Also: XMLElement.getStringAttribute(StringString) See Also: getStringAttribute(String, String) See Also: XMLElement.getStringAttribute(Stringjava.util.HashMapStringboolean) See Also: getStringAttribute(String, HashMap, String, boolean) See Also: XMLElement.getIntAttribute(String) See Also: getIntAttribute(String) See Also: XMLElement.getIntAttribute(Stringint) See Also: getIntAttribute(String, int) See Also: XMLElement.getIntAttribute(Stringjava.util.HashMapStringboolean) See Also: getIntAttribute(String, HashMap, String, boolean) See Also: XMLElement.getDoubleAttribute(String) See Also: getDoubleAttribute(String) See Also: XMLElement.getDoubleAttribute(Stringdouble) See Also: getDoubleAttribute(String, double) See Also: XMLElement.getDoubleAttribute(Stringjava.util.HashMapStringboolean) See Also: getDoubleAttribute(String, HashMap, String, boolean) See Also: XMLElement.getBooleanAttribute(StringStringStringboolean) See Also: getBooleanAttribute(String, String, String, boolean)
|
resolveEntity | protected void resolveEntity(StringBuffer buf) throws IOException(Code) | | Resolves an entity. The name of the entity is read from the reader.
The value of the entity is appended to buf .
Parameters: buf - Where to put the entity value.- Preconditions:
- The first & has already been read.
buf != null
|
scanElement | protected void scanElement(XMLElement elt) throws IOException(Code) | | Scans an XML element.
Parameters: elt - The element that will contain the result.- Preconditions:
- The first < has already been read.
elt != null
|
scanIdentifier | protected void scanIdentifier(StringBuffer result) throws IOException(Code) | | Scans an identifier from the current reader.
The scanned identifier is appended to result .
Parameters: result - The buffer in which the scanned identifier will be put.- Preconditions:
result != null - The next character read from the reader is a valid firstcharacter of an XML identifier.
- Postconditions:
- The next character read from the reader won't be an identifiercharacter.
|
scanPCData | protected void scanPCData(StringBuffer data) throws IOException(Code) | | Scans a #PCDATA element. CDATA sections and entities are resolved.
The next < char is skipped.
The scanned data is appended to data .
- Preconditions:
-
|
scanString | protected void scanString(StringBuffer string) throws IOException(Code) | | This method scans a delimited string from the current reader.
The scanned string without delimiters is appended to
string .
- Preconditions:
-
string != null
- the next char read is the string delimiter
|
scanWhitespace | protected char scanWhitespace() throws IOException(Code) | | This method scans an identifier from the current reader.
the next character following the whitespace. |
scanWhitespace | protected char scanWhitespace(StringBuffer result) throws IOException(Code) | | This method scans an identifier from the current reader.
The scanned whitespace is appended to result .
the next character following the whitespace.- Preconditions:
|
setAttribute | public void setAttribute(String name, Object value)(Code) | | Adds or modifies an attribute.
Parameters: name - The name of the attribute. Parameters: value - The value of the attribute.- Preconditions:
name != null name is a valid XML identifiervalue != null
- Postconditions:
- enumerateAttributeNames()=> old.enumerateAttributeNames() + name
- getAttribute(name) => value
See Also: XMLElement.setDoubleAttribute(Stringdouble) See Also: setDoubleAttribute(String, double) See Also: XMLElement.setIntAttribute(Stringint) See Also: setIntAttribute(String, int) See Also: XMLElement.enumerateAttributeNames See Also: XMLElement.getAttribute(String) See Also: getAttribute(String) See Also: XMLElement.getAttribute(StringObject) See Also: getAttribute(String, Object) See Also: XMLElement.getAttribute(Stringjava.util.HashMapStringboolean) See Also: getAttribute(String, HashMap, String, boolean) See Also: XMLElement.getStringAttribute(String) See Also: getStringAttribute(String) See Also: XMLElement.getStringAttribute(StringString) See Also: getStringAttribute(String, String) See Also: XMLElement.getStringAttribute(Stringjava.util.HashMapStringboolean) See Also: getStringAttribute(String, HashMap, String, boolean)
|
setContent | public void setContent(String content)(Code) | | Changes the content string.
Parameters: content - The new content string. |
setName | public void setName(String name)(Code) | | Changes the name of the element.
Parameters: name - The new name.- Preconditions:
name != null name is a valid XML identifier
See Also: XMLElement.getName |
skipComment | protected void skipComment() throws IOException(Code) | | Skips a comment.
- Preconditions:
-
- The first <!-- has already been read.
|
skipSpecialTag | protected void skipSpecialTag(int bracketLevel) throws IOException(Code) | | Skips a special tag or comment.
Parameters: bracketLevel - The number of open square brackets ([) that havealready been read.- Preconditions:
- The first <! has already been read.
bracketLevel >= 0
|
syntaxError | protected XMLParseException syntaxError(String context)(Code) | | Creates a parse exception for when a syntax error occured.
Parameters: context - The context in which the error occured.- Preconditions:
context != null context.length() > 0
|
unexpectedEndOfData | protected XMLParseException unexpectedEndOfData()(Code) | | Creates a parse exception for when the end of the data input has been
reached.
|
unknownEntity | protected XMLParseException unknownEntity(String name)(Code) | | Creates a parse exception for when an entity could not be resolved.
Parameters: name - The name of the entity.- Preconditions:
name != null name.length() > 0
|
unreadChar | protected void unreadChar(char ch)(Code) | | Pushes a character back to the read-back buffer.
Parameters: ch - The character to push back.- Preconditions:
- The read-back buffer is empty.
ch != '\0'
|
write | public void write(Writer writer) throws IOException(Code) | | Writes the XML element to a writer.
Parameters: writer - The writer to write the XML data to.- Preconditions:
writer != null writer is not closed
throws: java.io.IOException - If the data could not be written to the writer. See Also: XMLElement.toString |
writeEncoded | protected void writeEncoded(Writer writer, String str) throws IOException(Code) | | Writes a string encoded to a writer.
Parameters: writer - The writer to write the XML data to. Parameters: str - The string to write encoded.- Preconditions:
writer != null writer is not closedstr != null
|
|
|