| Prev Class | Next Class | Frames | No Frames |
| Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Objectfreemind.main.XMLElementpublic class XMLElementextends java.lang.Object
XMLElement xml = new XMLElement();
FileReader reader = new FileReader("filename.xml");
xml.parseFromReader(reader);
enumerateAttributeNamesgetStringAttribute
XMLElement element = ...;
Enumeration enum = element.getAttributeNames();
while (enum.hasMoreElements()) {
String key = (String) enum.nextElement();
String value = element.getStringAttribute(key);
System.out.println(key + " = " + value);
}
enumerateChildrencountChildren
<title>The Title</title>
getContentcreateAnotherElementnanoxml.XMLParseExceptionField Summary | |
static int |
|
static int |
|
protected boolean |
|
Constructor Summary | |
| |
| |
| |
| |
| |
| |
Method Summary | |
void |
|
void |
|
void |
|
void |
|
protected boolean |
|
protected boolean |
|
protected void | |
int |
|
protected XMLElement |
|
Enumeration |
|
Enumeration |
|
Enumeration |
|
protected XMLParseException |
|
Object |
|
Object |
|
Object |
|
boolean |
|
Vector |
|
String |
|
String |
|
double |
|
double |
|
double |
|
int |
|
int |
|
int |
|
int |
|
int |
|
String |
|
String |
|
Object |
|
String |
|
boolean |
|
double |
|
int |
|
double |
|
int |
|
String |
|
String |
|
String |
|
String |
|
String |
|
Object | |
protected XMLParseException |
|
protected XMLParseException |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
protected char |
|
void |
|
void |
|
void |
|
void |
|
protected void |
|
protected void |
|
protected void |
|
protected void |
|
protected void |
|
protected char |
|
protected char |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
protected void |
|
protected void |
|
protected XMLParseException |
|
String |
|
protected XMLParseException |
|
protected XMLParseException |
|
protected void |
|
void |
|
void |
|
void |
|
protected void |
|
void |
|
public static final int NANOXML_MAJOR_VERSION
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.
- Field Value:
- 2
- See Also:
nanoxml.XMLElement.NANOXML_MINOR_VERSION
public static final int NANOXML_MINOR_VERSION
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.
- Field Value:
- 2
- See Also:
nanoxml.XMLElement.NANOXML_MAJOR_VERSION
protected boolean ignoreCase
trueif the case of the element and attribute names are case insensitive.
public XMLElement()
Creates and initializes a new XML element. Calling the construction is equivalent to:
new XMLElement(new Hashtable(), false, true)
- Postconditions:
- countChildren() => 0
- enumerateChildren() => empty enumeration
- enumeratePropertyNames() => empty enumeration
- getChildren() => empty vector
- getContent() => ""
- getLineNr() => 0
- getName() => null
- See Also:
XMLElement(Hashtable),nanoxml.XMLElement.XMLElement(boolean),XMLElement(Hashtable, boolean)
public XMLElement(Hashtable entities)
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:
entities != null
- Postconditions:
- countChildren() => 0
- enumerateChildren() => empty enumeration
- enumeratePropertyNames() => empty enumeration
- getChildren() => empty vector
- getContent() => ""
- getLineNr() => 0
- getName() => null
- See Also:
nanoxml.XMLElement.XMLElement(),nanoxml.XMLElement.XMLElement(boolean),XMLElement(Hashtable, boolean)
public XMLElement(Hashtable entities,
boolean skipLeadingWhitespace)Creates and initializes a new XML element. Calling the construction is equivalent to:
new XMLElement(entities, skipLeadingWhitespace, true)
- Parameters:
entities- The entity conversion table.skipLeadingWhitespace-trueif leading and trailing whitespace in PCDATA content has to be removed.
- Preconditions:
entities != null
- Postconditions:
- countChildren() => 0
- enumerateChildren() => empty enumeration
- enumeratePropertyNames() => empty enumeration
- getChildren() => empty vector
- getContent() => ""
- getLineNr() => 0
- getName() => null
- See Also:
nanoxml.XMLElement.XMLElement(),nanoxml.XMLElement.XMLElement(boolean),XMLElement(Hashtable)
public XMLElement(Hashtable entities,
boolean skipLeadingWhitespace,
boolean ignoreCase)Creates and initializes a new XML element.
- Parameters:
entities- The entity conversion table.skipLeadingWhitespace-trueif leading and trailing whitespace in PCDATA content has to be removed.ignoreCase-trueif the case of element and attribute names have to be ignored.
- Preconditions:
entities != null
- Postconditions:
- countChildren() => 0
- enumerateChildren() => empty enumeration
- enumeratePropertyNames() => empty enumeration
- getChildren() => empty vector
- getContent() => ""
- getLineNr() => 0
- getName() => null
- See Also:
nanoxml.XMLElement.XMLElement(),nanoxml.XMLElement.XMLElement(boolean),XMLElement(Hashtable),XMLElement(Hashtable, boolean)
protected XMLElement(Hashtable entities,
boolean skipLeadingWhitespace,
boolean fillBasicConversionTable,
boolean ignoreCase)Creates and initializes a new XML element. This constructor should only be called fromcreateAnotherElementto create child elements.
- Parameters:
entities- The entity conversion table.skipLeadingWhitespace-trueif leading and trailing whitespace in PCDATA content has to be removed.fillBasicConversionTable-trueif the basic entities need to be added to the entity list.ignoreCase-trueif the case of element and attribute names have to be ignored.
- Preconditions:
entities != null- if
fillBasicConversionTable == falsethenentitiescontains at least the following entries:amp,lt,gt,aposandquot
- Postconditions:
- countChildren() => 0
- enumerateChildren() => empty enumeration
- enumeratePropertyNames() => empty enumeration
- getChildren() => empty vector
- getContent() => ""
- getLineNr() => 0
- getName() => null
- See Also:
nanoxml.XMLElement.createAnotherElement()
public XMLElement(boolean skipLeadingWhitespace)
Creates and initializes a new XML element. Calling the construction is equivalent to:
new XMLElement(new Hashtable(), skipLeadingWhitespace, true)
- Parameters:
skipLeadingWhitespace-trueif leading and trailing whitespace in PCDATA content has to be removed.
- Postconditions:
- countChildren() => 0
- enumerateChildren() => empty enumeration
- enumeratePropertyNames() => empty enumeration
- getChildren() => empty vector
- getContent() => ""
- getLineNr() => 0
- getName() => null
- See Also:
nanoxml.XMLElement.XMLElement(),XMLElement(Hashtable),XMLElement(Hashtable, boolean)
public void addChild(XMLElement child)
Adds a child element.
- Parameters:
child- The child element to add.
- Preconditions:
child != nullchild.getName() != nullchilddoes not have a parent element
- Postconditions:
- countChildren() => old.countChildren() + 1
- enumerateChildren() => old.enumerateChildren() + child
- getChildren() => old.enumerateChildren() + child
- See Also:
nanoxml.XMLElement.countChildren(),nanoxml.XMLElement.enumerateChildren(),nanoxml.XMLElement.getChildren(),removeChild(XMLElement)
public void addProperty(String name,
Object value)Deprecated. Use
setAttributeinstead.Adds or modifies an attribute.
- Parameters:
name- The name of the attribute.value- The value of the attribute.
public void addProperty(String name,
double value)Deprecated. Use
setDoubleAttributeinstead.Adds or modifies an attribute.
- Parameters:
name- The name of the attribute.value- The value of the attribute.
public void addProperty(String key,
int value)Deprecated. Use
setIntAttributeinstead.Adds or modifies an attribute.
- Parameters:
value- The value of the attribute.
protected boolean checkCDATA(StringBuffer buf)
throws IOExceptionScans a special tag and if the tag is a CDATA section, append its content tobuf.
- Preconditions:
buf != null- The first < has already been read.
protected boolean checkLiteral(String literal)
throws IOExceptionScans 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:
literal != null
protected void completeElement()
public int countChildren()
Returns the number of child elements of the element.
- Postconditions:
result >= 0
- See Also:
addChild(XMLElement),nanoxml.XMLElement.enumerateChildren(),nanoxml.XMLElement.getChildren(),removeChild(XMLElement)
protected XMLElement createAnotherElement()
Creates a new similar XML element. You should override this method when subclassing XMLElement.
public Enumeration enumerateAttributeNames()
Enumerates the attribute names.
- Postconditions:
result != null
- See Also:
setDoubleAttribute(String, double),setIntAttribute(String, int),setAttribute(String, Object),removeAttribute(String),getAttribute(String),getAttribute(String, String),getAttribute(String, Hashtable, String, boolean),getStringAttribute(String),getStringAttribute(String, String),getStringAttribute(String, Hashtable, String, boolean),getIntAttribute(String),getIntAttribute(String, int),getIntAttribute(String, Hashtable, String, boolean),getDoubleAttribute(String),getDoubleAttribute(String, double),getDoubleAttribute(String, Hashtable, String, boolean),getBooleanAttribute(String, String, String, boolean)
public Enumeration enumerateChildren()
Enumerates the child elements.
- Postconditions:
result != null
- See Also:
addChild(XMLElement),nanoxml.XMLElement.countChildren(),nanoxml.XMLElement.getChildren(),removeChild(XMLElement)
public Enumeration enumeratePropertyNames()
Deprecated. Use
enumerateAttributeNamesinstead.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.
- Parameters:
charSet- The set of characters (in human readable form) that was expected.
- Preconditions:
charSet != nullcharSet.length() > 0
public Object getAttribute(String name)
Returns an attribute of the element. If the attribute doesn't exist,nullis returned.
- Parameters:
name- The name of the attribute.
- Preconditions:
name != nullnameis a valid XML identifier
- See Also:
setAttribute(String, Object),removeAttribute(String),nanoxml.XMLElement.enumerateAttributeNames(),getAttribute(String, Object),getAttribute(String, Hashtable, String, boolean)
public Object getAttribute(String name,
Hashtable valueSet,
String defaultKey,
boolean allowLiterals)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 attributeattr="one", thengetAttribute("attr", mapping, defaultKey, false)returns"1".
- Parameters:
name- The name of the attribute.valueSet- Hashtable mapping keys to values.defaultKey- Key to use if the attribute is missing.allowLiterals-trueif literals are valid.
- Preconditions:
name != nullnameis a valid XML identifiervalueSet!= null- the keys of
valueSetare strings
- See Also:
setAttribute(String, Object),removeAttribute(String),nanoxml.XMLElement.enumerateAttributeNames(),getAttribute(String),getAttribute(String, Object)
public Object getAttribute(String name,
Object defaultValue)Returns an attribute of the element. If the attribute doesn't exist,defaultValueis returned.
- Parameters:
name- The name of the attribute.defaultValue- Key to use if the attribute is missing.
- Preconditions:
name != nullnameis a valid XML identifier
- See Also:
setAttribute(String, Object),removeAttribute(String),nanoxml.XMLElement.enumerateAttributeNames(),getAttribute(String),getAttribute(String, Hashtable, String, boolean)
public boolean getBooleanAttribute(String name,
String trueValue,
String falseValue,
boolean defaultValue)Returns an attribute of the element. If the attribute doesn't exist,defaultValueis returned. If the value of the attribute is equal totrueValue,trueis returned. If the value of the attribute is equal tofalseValue,falseis returned. If the value doesn't matchtrueValueorfalseValue, an exception is thrown.
- Parameters:
name- The name of the attribute.trueValue- The value associated withtrue.falseValue- The value associated withtrue.defaultValue- Value to use if the attribute is missing.
- Preconditions:
name != nullnameis a valid XML identifiertrueValueandfalseValueare different strings.
- See Also:
setAttribute(String, Object),removeAttribute(String),nanoxml.XMLElement.enumerateAttributeNames()
public Vector getChildren()
Returns the child elements as a Vector. It is safe to modify this Vector.
- Postconditions:
result != null
- See Also:
addChild(XMLElement),nanoxml.XMLElement.countChildren(),nanoxml.XMLElement.enumerateChildren(),removeChild(XMLElement)
public String getContent()
Returns the PCDATA content of the object. If there is no such content,nullis returned.
- See Also:
setContent(String)
public String getContents()
Deprecated. Use
getContentinstead.Returns the PCDATA content of the object. If there is no such content,nullis returned.
public double getDoubleAttribute(String name)
Returns an attribute of the element. If the attribute doesn't exist,0.0is returned.
- Parameters:
name- The name of the attribute.
- Preconditions:
name != nullnameis a valid XML identifier
- See Also:
setDoubleAttribute(String, double),nanoxml.XMLElement.enumerateAttributeNames(),getDoubleAttribute(String, double),getDoubleAttribute(String, Hashtable, String, boolean)
public double getDoubleAttribute(String name,
Hashtable valueSet,
String defaultKey,
boolean allowLiteralNumbers)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.0and the element contains the attributeattr="one", thengetDoubleAttribute("attr", mapping, defaultKey, false)returns1.0.
- Parameters:
name- The name of the attribute.valueSet- Hashtable mapping keys to values.defaultKey- Key to use if the attribute is missing.allowLiteralNumbers-trueif literal numbers are valid.
- Preconditions:
name != nullnameis a valid XML identifiervalueSet != null- the keys of
valueSetare strings- the values of
valueSetare Double objectsdefaultKeyis eithernull, a key invalueSetor a double.
- See Also:
setDoubleAttribute(String, double),nanoxml.XMLElement.enumerateAttributeNames(),getDoubleAttribute(String),getDoubleAttribute(String, double)
public double getDoubleAttribute(String name,
double defaultValue)Returns an attribute of the element. If the attribute doesn't exist,defaultValueis returned.
- Parameters:
name- The name of the attribute.defaultValue- Key to use if the attribute is missing.
- Preconditions:
name != nullnameis a valid XML identifier
- See Also:
setDoubleAttribute(String, double),nanoxml.XMLElement.enumerateAttributeNames(),getDoubleAttribute(String),getDoubleAttribute(String, Hashtable, String, boolean)
public int getIntAttribute(String name)
Returns an attribute of the element. If the attribute doesn't exist,0is returned.
- Parameters:
name- The name of the attribute.
- Preconditions:
name != nullnameis a valid XML identifier
- See Also:
setIntAttribute(String, int),nanoxml.XMLElement.enumerateAttributeNames(),getIntAttribute(String, int),getIntAttribute(String, Hashtable, String, boolean)
public int getIntAttribute(String name,
Hashtable valueSet,
String defaultKey,
boolean allowLiteralNumbers)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" => 1and the element contains the attributeattr="one", thengetIntAttribute("attr", mapping, defaultKey, false)returns1.
- Parameters:
name- The name of the attribute.valueSet- Hashtable mapping keys to values.defaultKey- Key to use if the attribute is missing.allowLiteralNumbers-trueif literal numbers are valid.
- Preconditions:
name != nullnameis a valid XML identifiervalueSet!= null- the keys of
valueSetare strings- the values of
valueSetare Integer objectsdefaultKeyis eithernull, a key invalueSetor an integer.
- See Also:
setIntAttribute(String, int),nanoxml.XMLElement.enumerateAttributeNames(),getIntAttribute(String),getIntAttribute(String, int)
public int getIntAttribute(String name,
int defaultValue)Returns an attribute of the element. If the attribute doesn't exist,defaultValueis returned.
- Parameters:
name- The name of the attribute.defaultValue- Key to use if the attribute is missing.
- Preconditions:
name != nullnameis a valid XML identifier
- See Also:
setIntAttribute(String, int),nanoxml.XMLElement.enumerateAttributeNames(),getIntAttribute(String),getIntAttribute(String, Hashtable, String, boolean)
public int getIntProperty(String name,
Hashtable valueSet,
String defaultKey)Deprecated. Use
getIntAttributeinstead.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. This method returns0there is no associated source data.
- Postconditions:
result >= 0
public String getName()
Returns the name of the element.
- See Also:
setName(String)
public String getProperty(String name)
Deprecated. Use
getStringAttributeinstead.Returns an attribute.
public Object getProperty(String name,
Hashtable valueSet,
String defaultKey)Deprecated. Use
getAttributeinstead.Returns an attribute by looking up a key in a hashtable.
public String getProperty(String name,
String defaultValue)Deprecated. Use
getStringAttributeinstead.Returns an attribute.
public boolean getProperty(String key,
String trueValue,
String falseValue,
boolean defaultValue)Deprecated. Use
getBooleanAttributeinstead.Returns an attribute.
public double getProperty(String name,
double defaultValue)Deprecated. Use
getDoubleAttributeinstead.Returns an attribute.
public int getProperty(String name,
int defaultValue)Deprecated. Use
getIntAttributeinstead.Returns an attribute.
public double getSpecialDoubleProperty(String name,
Hashtable valueSet,
String defaultKey)Deprecated. Use
getDoubleAttributeinstead.Returns an attribute by looking up a key in a hashtable.
public int getSpecialIntProperty(String name,
Hashtable valueSet,
String defaultKey)Deprecated. Use
getIntAttributeinstead.Returns an attribute by looking up a key in a hashtable.
public String getStringAttribute(String name)
Returns an attribute of the element. If the attribute doesn't exist,nullis returned.
- Parameters:
name- The name of the attribute.
- Preconditions:
name != nullnameis a valid XML identifier
- See Also:
setAttribute(String, Object),removeAttribute(String),nanoxml.XMLElement.enumerateAttributeNames(),getStringAttribute(String, String),getStringAttribute(String, Hashtable, String, boolean)
public String getStringAttribute(String name,
Hashtable valueSet,
String defaultKey,
boolean allowLiterals)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 attributeattr="one", thengetAttribute("attr", mapping, defaultKey, false)returns"1".
- Parameters:
name- The name of the attribute.valueSet- Hashtable mapping keys to values.defaultKey- Key to use if the attribute is missing.allowLiterals-trueif literals are valid.
- Preconditions:
name != nullnameis a valid XML identifiervalueSet!= null- the keys of
valueSetare strings- the values of
valueSetare strings
- See Also:
setAttribute(String, Object),removeAttribute(String),nanoxml.XMLElement.enumerateAttributeNames(),getStringAttribute(String),getStringAttribute(String, String)
public String getStringAttribute(String name,
String defaultValue)Returns an attribute of the element. If the attribute doesn't exist,defaultValueis returned.
- Parameters:
name- The name of the attribute.defaultValue- Key to use if the attribute is missing.
- Preconditions:
name != nullnameis a valid XML identifier
- See Also:
setAttribute(String, Object),removeAttribute(String),nanoxml.XMLElement.enumerateAttributeNames(),getStringAttribute(String),getStringAttribute(String, Hashtable, String, boolean)
public String getStringProperty(String name,
Hashtable valueSet,
String defaultKey)Deprecated. Use
getStringAttributeinstead.Returns an attribute by looking up a key in a hashtable.
public String getTagName()
Deprecated. Use
getNameinstead.Returns the name of the element.
public Object getUserObject()
protected XMLParseException invalidValue(String name, String value)
Creates a parse exception for when an invalid value is given to a method.
- Parameters:
name- The name of the entity.value- The value of the entity.
- Preconditions:
name != nullvalue != null
protected XMLParseException invalidValueSet(String name)
Creates a parse exception for when an invalid valueset is given to a method.
- Parameters:
name- The name of the entity.
- Preconditions:
name != null
public void parseCharArray(char[] input,
int offset,
int end)
throws XMLParseExceptionReads one XML element from a char array and parses it.
- Parameters:
offset- The first character instringto scan.end- The character where to stop scanning. This character is not scanned.
- Preconditions:
input != nullend <= input.lengthoffset < endoffset >= 0
- Postconditions:
- the state of the receiver is updated to reflect the XML element parsed from the reader
public void parseCharArray(char[] input,
int offset,
int end,
int startingLineNr)
throws XMLParseExceptionReads one XML element from a char array and parses it.
- Parameters:
offset- The first character instringto scan.end- The character where to stop scanning. This character is not scanned.startingLineNr- The line number of the first line in the data.
- Preconditions:
input != nullend <= input.lengthoffset < endoffset >= 0
- Postconditions:
- the state of the receiver is updated to reflect the XML element parsed from the reader
public void parseFromReader(Reader reader)
throws IOException,
XMLParseExceptionReads one XML element from a java.io.Reader and parses it.
- Parameters:
reader- The reader from which to retrieve the XML data.
- Preconditions:
reader != nullreaderis not closed
- Postconditions:
- the state of the receiver is updated to reflect the XML element parsed from the reader
- the reader points to the first character following the last '>' character of the XML element
public void parseFromReader(Reader reader,
int startingLineNr)
throws IOException,
XMLParseExceptionReads one XML element from a java.io.Reader and parses it.
- Parameters:
reader- The reader from which to retrieve the XML data.startingLineNr- The line number of the first line in the data.
- Preconditions:
reader != nullreaderis not closed
- Postconditions:
- the state of the receiver is updated to reflect the XML element parsed from the reader
- the reader points to the first character following the last '>' character of the XML element
public void parseString(String string)
throws XMLParseExceptionReads one XML element from a String and parses it.
- Parameters:
public void parseString(String string,
int offset)
throws XMLParseExceptionReads one XML element from a String and parses it.
- Parameters:
offset- The first character instringto scan.
- Preconditions:
string != nulloffset < string.length()offset >= 0
- Postconditions:
- the state of the receiver is updated to reflect the XML element parsed from the reader
public void parseString(String string,
int offset,
int end)
throws XMLParseExceptionReads one XML element from a String and parses it.
- Parameters:
offset- The first character instringto scan.end- The character where to stop scanning. This character is not scanned.
- Preconditions:
string != nullend <= string.length()offset < endoffset >= 0
- Postconditions:
- the state of the receiver is updated to reflect the XML element parsed from the reader
public void parseString(String string,
int offset,
int end,
int startingLineNr)
throws XMLParseExceptionReads one XML element from a String and parses it.
- Parameters:
offset- The first character instringto scan.end- The character where to stop scanning. This character is not scanned.startingLineNr- The line number of the first line in the data.
- Preconditions:
string != nullend <= string.length()offset < endoffset >= 0
- Postconditions:
- the state of the receiver is updated to reflect the XML element parsed from the reader
protected char readChar()
throws IOExceptionReads a character from a reader.
public void removeAttribute(String name)
Removes an attribute.
- Parameters:
name- The name of the attribute.
- Preconditions:
name != nullnameis a valid XML identifier
- Postconditions:
- enumerateAttributeNames() => old.enumerateAttributeNames() - name
- getAttribute(name) =>
null
- See Also:
nanoxml.XMLElement.enumerateAttributeNames(),setDoubleAttribute(String, double),setIntAttribute(String, int),setAttribute(String, Object),getAttribute(String),getAttribute(String, Object),getAttribute(String, Hashtable, String, boolean),getStringAttribute(String),getStringAttribute(String, String),getStringAttribute(String, Hashtable, String, boolean),getIntAttribute(String),getIntAttribute(String, int),getIntAttribute(String, Hashtable, String, boolean),getDoubleAttribute(String),getDoubleAttribute(String, double),getDoubleAttribute(String, Hashtable, String, boolean),getBooleanAttribute(String, String, String, boolean)
public void removeChild(String name)
Deprecated. Use
removeAttributeinstead.Removes an attribute.
- Parameters:
name- The name of the attribute.
public void removeChild(XMLElement child)
Removes a child element.
- Parameters:
child- The child element to remove.
- Preconditions:
child != nullchildis a child element of the receiver
- Postconditions:
- countChildren() => old.countChildren() - 1
- enumerateChildren() => old.enumerateChildren() - child
- getChildren() => old.enumerateChildren() - child
- See Also:
addChild(XMLElement),nanoxml.XMLElement.countChildren(),nanoxml.XMLElement.enumerateChildren(),nanoxml.XMLElement.getChildren()
public void removeProperty(String name)
Deprecated. Use
removeAttributeinstead.Removes an attribute.
- Parameters:
name- The name of the attribute.
protected void resolveEntity(StringBuffer buf)
throws IOExceptionResolves an entity. The name of the entity is read from the reader. The value of the entity is appended tobuf.
- Parameters:
buf- Where to put the entity value.
- Preconditions:
- The first & has already been read.
buf != null
protected void scanElement(XMLElement elt) throws IOException
Scans an XML element.
- Parameters:
elt- The element that will contain the result.
- Preconditions:
- The first < has already been read.
elt != null
protected void scanIdentifier(StringBuffer result)
throws IOExceptionScans an identifier from the current reader. The scanned identifier is appended toresult.
- 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 first character of an XML identifier.
- Postconditions:
- The next character read from the reader won't be an identifier character.
protected void scanPCData(StringBuffer data)
throws IOExceptionScans a #PCDATA element. CDATA sections and entities are resolved. The next < char is skipped. The scanned data is appended todata.
- Preconditions:
data != null
protected void scanString(StringBuffer string)
throws IOExceptionThis method scans a delimited string from the current reader. The scanned string without delimiters is appended tostring.
- Preconditions:
string != null- the next char read is the string delimiter
protected char scanWhitespace()
throws IOExceptionThis method scans an identifier from the current reader.
- Returns:
- the next character following the whitespace.
protected char scanWhitespace(StringBuffer result)
throws IOExceptionThis method scans an identifier from the current reader. The scanned whitespace is appended toresult.
- Returns:
- the next character following the whitespace.
- Preconditions:
result != null
public void setAttribute(String name,
Object value)Adds or modifies an attribute.
- Parameters:
name- The name of the attribute.value- The value of the attribute.
- Preconditions:
name != nullnameis a valid XML identifiervalue != null
- Postconditions:
- enumerateAttributeNames() => old.enumerateAttributeNames() + name
- getAttribute(name) => value
- See Also:
setDoubleAttribute(String, double),setIntAttribute(String, int),nanoxml.XMLElement.enumerateAttributeNames(),getAttribute(String),getAttribute(String, Object),getAttribute(String, Hashtable, String, boolean),getStringAttribute(String),getStringAttribute(String, String),getStringAttribute(String, Hashtable, String, boolean)
public void setContent(String content)
Changes the content string.
- Parameters:
content- The new content string.
public void setDoubleAttribute(String name,
double value)Adds or modifies an attribute.
- Parameters:
name- The name of the attribute.value- The value of the attribute.
- Preconditions:
name != nullnameis a valid XML identifier
- Postconditions:
- enumerateAttributeNames() => old.enumerateAttributeNames() + name
- getDoubleAttribute(name) => value
- See Also:
setIntAttribute(String, int),setAttribute(String, Object),removeAttribute(String),nanoxml.XMLElement.enumerateAttributeNames(),getDoubleAttribute(String),getDoubleAttribute(String, double),getDoubleAttribute(String, Hashtable, String, boolean)
public void setIntAttribute(String name,
int value)Adds or modifies an attribute.
- Parameters:
name- The name of the attribute.value- The value of the attribute.
- Preconditions:
name != nullnameis a valid XML identifier
- Postconditions:
- enumerateAttributeNames() => old.enumerateAttributeNames() + name
- getIntAttribute(name) => value
- See Also:
setDoubleAttribute(String, double),setAttribute(String, Object),removeAttribute(String),nanoxml.XMLElement.enumerateAttributeNames(),getIntAttribute(String),getIntAttribute(String, int),getIntAttribute(String, Hashtable, String, boolean)
public void setName(String name)
Changes the name of the element.
- Parameters:
name- The new name.
- Preconditions:
name != nullnameis a valid XML identifier
- See Also:
nanoxml.XMLElement.getName()
public void setTagName(String name)
Deprecated. Use
setNameinstead.Changes the name of the element.
- Parameters:
name- The new name.
protected void skipComment()
throws IOExceptionSkips a comment.
- Preconditions:
- The first <!-- has already been read.
protected void skipSpecialTag(int bracketLevel)
throws IOExceptionSkips a special tag or comment.
- Parameters:
bracketLevel- The number of open square brackets ([) that have already been read.
- Preconditions:
- The first <! has already been read.
bracketLevel >= 0
protected XMLParseException syntaxError(String context)
Creates a parse exception for when a syntax error occured.
- Parameters:
context- The context in which the error occured.
- Preconditions:
context != nullcontext.length() > 0
public String toString()
Writes the XML element to a string.
- See Also:
write(Writer)
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.
- Parameters:
name- The name of the entity.
- Preconditions:
name != nullname.length() > 0
protected void unreadChar(char ch)
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'
public void write(Writer writer)
throws IOExceptionWrites the XML element to a writer.
- Parameters:
writer- The writer to write the XML data to.
- Preconditions:
writer != nullwriteris not closed
- See Also:
nanoxml.XMLElement.toString()
public void write(Writer writer,
boolean withClosingTag)
throws IOExceptionpublic void writeClosingTag(Writer writer)
throws IOExceptionprotected void writeEncoded(Writer writer,
String str)
throws IOExceptionWrites a string encoded to a writer.
- Parameters:
writer- The writer to write the XML data to.str- The string to write encoded.
- Preconditions:
writer != nullwriteris not closedstr != null
public void writeWithoutClosingTag(Writer writer)
throws IOException