Class XMLElement

java.lang.Object
org.jvnet.lafplugin.XMLElement

public class XMLElement extends Object
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 enumerateAttributeNames. The attribute values can be retrieved using the method getStringAttribute. The following example shows how to list the attributes of an element:
    XMLElement element = ...;
    Enumeration enum = element.getAttributeNames();
    while (enum.hasMoreElements()) {
        String key = (String) enum.nextElement();
        String value = element.getStringAttribute(key);
        System.out.println(key + " = " + value);
    }
Retrieving Child Elements
You can enumerate the children of an element using enumerateChildren. The number of child elements can be retrieved using countChildren.
Elements Containing Character Data
If an elements contains character data, like in the following example:
    <title>The Title</title>
you can retrieve that data using the method getContent.
Subclassing XMLElement
When subclassing XMLElement, you need to override the method createAnotherElement which has to return a new copy of the receiver.

See Also:
  • invalid reference
    nanoxml.XMLParseException
  • Field Details

    • NANOXML_MAJOR_VERSION

      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.
      See Also:
    • 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.
      See Also:
  • Constructor Details

    • XMLElement

      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:
      • invalid reference
        XMLElement(Hashtable)
      • invalid reference
        nanoxml.XMLElement#XMLElement(boolean)
      • invalid reference
        XMLElement(Hashtable, boolean)
    • XMLElement

      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:
      • invalid reference
        nanoxml.XMLElement#XMLElement()
      • invalid reference
        nanoxml.XMLElement#XMLElement(boolean)
      • invalid reference
        XMLElement(Hashtable, boolean)
    • XMLElement

      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 - true if 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:
      • invalid reference
        nanoxml.XMLElement#XMLElement()
      • invalid reference
        XMLElement(Hashtable)
      • invalid reference
        XMLElement(Hashtable, boolean)
    • XMLElement

      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 - true if 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:
      • invalid reference
        nanoxml.XMLElement#XMLElement()
      • invalid reference
        nanoxml.XMLElement#XMLElement(boolean)
      • invalid reference
        XMLElement(Hashtable)
    • XMLElement

      public XMLElement(Hashtable entities, boolean skipLeadingWhitespace, boolean ignoreCase)
      Creates and initializes a new XML element.
      Parameters:
      entities - The entity conversion table.
      skipLeadingWhitespace - true if leading and trailing whitespace in PCDATA content has to be removed.
      ignoreCase - true if 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:
      • invalid reference
        nanoxml.XMLElement#XMLElement()
      • invalid reference
        nanoxml.XMLElement#XMLElement(boolean)
      • invalid reference
        XMLElement(Hashtable)
      • invalid reference
        XMLElement(Hashtable, boolean)
  • Method Details

    • addChild

      public void addChild(XMLElement child)
      Adds a child element.
      Parameters:
      child - The child element to add.
      Preconditions:
      • child != null
      • child.getName() != null
      • child does not have a parent element
      Postconditions:
      • countChildren() => old.countChildren() + 1
      • enumerateChildren() => old.enumerateChildren() + child
      • getChildren() => old.enumerateChildren() + child
      See Also:
      • invalid reference
        nanoxml.XMLElement#countChildren()
      • invalid reference
        nanoxml.XMLElement#enumerateChildren()
      • invalid reference
        nanoxml.XMLElement#getChildren()
      • invalid reference
        removeChild(XMLElement)
    • setAttribute

      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 != null
      • name is a valid XML identifier
      • value != null
      Postconditions:
      • enumerateAttributeNames() => old.enumerateAttributeNames() + name
      • getAttribute(name) => value
      See Also:
      • invalid reference
        setDoubleAttribute(String, double)
      • invalid reference
        setIntAttribute(String, int)
      • invalid reference
        nanoxml.XMLElement#enumerateAttributeNames()
      • invalid reference
        getAttribute(String)
      • invalid reference
        getAttribute(String, Object)
      • invalid reference
        getAttribute(String, Hashtable, String, boolean)
      • invalid reference
        getStringAttribute(String)
      • invalid reference
        getStringAttribute(String, String)
      • invalid reference
        getStringAttribute(String, Hashtable, String, boolean)
    • addProperty

      public void addProperty(String name, Object value)
      Deprecated.
      Use setAttribute instead.
      Adds or modifies an attribute.
      Parameters:
      name - The name of the attribute.
      value - The value of the attribute.
    • setIntAttribute

      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 != null
      • name is a valid XML identifier
      Postconditions:
      • enumerateAttributeNames() => old.enumerateAttributeNames() + name
      • getIntAttribute(name) => value
      See Also:
      • invalid reference
        setDoubleAttribute(String, double)
      • invalid reference
        setAttribute(String, Object)
      • invalid reference
        removeAttribute(String)
      • invalid reference
        nanoxml.XMLElement#enumerateAttributeNames()
      • invalid reference
        getIntAttribute(String)
      • invalid reference
        getIntAttribute(String, int)
      • invalid reference
        getIntAttribute(String, Hashtable, String, boolean)
    • addProperty

      public void addProperty(String key, int value)
      Deprecated.
      Use setIntAttribute instead.
      Adds or modifies an attribute.
      Parameters:
      value - The value of the attribute.
      name - The name of the attribute.
    • setDoubleAttribute

      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 != null
      • name is a valid XML identifier
      Postconditions:
      • enumerateAttributeNames() => old.enumerateAttributeNames() + name
      • getDoubleAttribute(name) => value
      See Also:
      • invalid reference
        setIntAttribute(String, int)
      • invalid reference
        setAttribute(String, Object)
      • invalid reference
        removeAttribute(String)
      • invalid reference
        nanoxml.XMLElement#enumerateAttributeNames()
      • invalid reference
        getDoubleAttribute(String)
      • invalid reference
        getDoubleAttribute(String, double)
      • invalid reference
        getDoubleAttribute(String, Hashtable, String, boolean)
    • addProperty

      public void addProperty(String name, double value)
      Deprecated.
      Use setDoubleAttribute instead.
      Adds or modifies an attribute.
      Parameters:
      name - The name of the attribute.
      value - The value of the attribute.
    • countChildren

      public int countChildren()
      Returns the number of child elements of the element.
      Postconditions:
      • result >= 0
      See Also:
      • invalid reference
        addChild(XMLElement)
      • invalid reference
        nanoxml.XMLElement#enumerateChildren()
      • invalid reference
        nanoxml.XMLElement#getChildren()
      • invalid reference
        removeChild(XMLElement)
    • enumerateAttributeNames

      public Enumeration enumerateAttributeNames()
      Enumerates the attribute names.
      Postconditions:
      • result != null
      See Also:
      • invalid reference
        setDoubleAttribute(String, double)
      • invalid reference
        setIntAttribute(String, int)
      • invalid reference
        setAttribute(String, Object)
      • invalid reference
        removeAttribute(String)
      • invalid reference
        getAttribute(String)
      • invalid reference
        getAttribute(String, String)
      • invalid reference
        getAttribute(String, Hashtable, String, boolean)
      • invalid reference
        getStringAttribute(String)
      • invalid reference
        getStringAttribute(String, String)
      • invalid reference
        getStringAttribute(String, Hashtable, String, boolean)
      • invalid reference
        getIntAttribute(String)
      • invalid reference
        getIntAttribute(String, int)
      • invalid reference
        getIntAttribute(String, Hashtable, String, boolean)
      • invalid reference
        getDoubleAttribute(String)
      • invalid reference
        getDoubleAttribute(String, double)
      • invalid reference
        getDoubleAttribute(String, Hashtable, String, boolean)
      • invalid reference
        getBooleanAttribute(String, String, String, boolean)
    • enumeratePropertyNames

      public Enumeration enumeratePropertyNames()
      Deprecated.
      Enumerates the attribute names.
    • enumerateChildren

      public Enumeration enumerateChildren()
      Enumerates the child elements.
      Postconditions:
      • result != null
      See Also:
      • invalid reference
        addChild(XMLElement)
      • invalid reference
        nanoxml.XMLElement#countChildren()
      • invalid reference
        nanoxml.XMLElement#getChildren()
      • invalid reference
        removeChild(XMLElement)
    • getChildren

      public Vector getChildren()
      Returns the child elements as a Vector. It is safe to modify this Vector.
      Postconditions:
      • result != null
      See Also:
      • invalid reference
        addChild(XMLElement)
      • invalid reference
        nanoxml.XMLElement#countChildren()
      • invalid reference
        nanoxml.XMLElement#enumerateChildren()
      • invalid reference
        removeChild(XMLElement)
    • getContents

      public String getContents()
      Deprecated.
      Use getContent instead.
      Returns the PCDATA content of the object. If there is no such content, null is returned.
    • getContent

      public String getContent()
      Returns the PCDATA content of the object. If there is no such content, null is returned.
      See Also:
      • invalid reference
        setContent(String)
    • getLineNr

      public int getLineNr()
      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:
      • result >= 0
    • getAttribute

      public Object getAttribute(String name)
      Returns an attribute of the element. If the attribute doesn't exist, null is returned.
      Parameters:
      name - The name of the attribute.
      Preconditions:
      • name != null
      • name is a valid XML identifier
      See Also:
      • invalid reference
        setAttribute(String, Object)
      • invalid reference
        removeAttribute(String)
      • invalid reference
        nanoxml.XMLElement#enumerateAttributeNames()
      • invalid reference
        getAttribute(String, Object)
      • invalid reference
        getAttribute(String, Hashtable, String, boolean)
    • getAttribute

      public Object getAttribute(String name, Object defaultValue)
      Returns an attribute of the element. If the attribute doesn't exist, defaultValue is returned.
      Parameters:
      name - The name of the attribute.
      defaultValue - Key to use if the attribute is missing.
      Preconditions:
      • name != null
      • name is a valid XML identifier
      See Also:
      • invalid reference
        setAttribute(String, Object)
      • invalid reference
        removeAttribute(String)
      • invalid reference
        nanoxml.XMLElement#enumerateAttributeNames()
      • invalid reference
        getAttribute(String)
      • invalid reference
        getAttribute(String, Hashtable, String, boolean)
    • getAttribute

      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 attribute attr="one", then getAttribute("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 - true if literals are valid.
      Preconditions:
      • name != null
      • name is a valid XML identifier
      • valueSet != null
      • the keys of valueSet are strings
      See Also:
      • invalid reference
        setAttribute(String, Object)
      • invalid reference
        removeAttribute(String)
      • invalid reference
        nanoxml.XMLElement#enumerateAttributeNames()
      • invalid reference
        getAttribute(String)
      • invalid reference
        getAttribute(String, Object)
    • getStringAttribute

      public String getStringAttribute(String name)
      Returns an attribute of the element. If the attribute doesn't exist, null is returned.
      Parameters:
      name - The name of the attribute.
      Preconditions:
      • name != null
      • name is a valid XML identifier
      See Also:
      • invalid reference
        setAttribute(String, Object)
      • invalid reference
        removeAttribute(String)
      • invalid reference
        nanoxml.XMLElement#enumerateAttributeNames()
      • invalid reference
        getStringAttribute(String, String)
      • invalid reference
        getStringAttribute(String, Hashtable, String, boolean)
    • getStringAttribute

      public String getStringAttribute(String name, String defaultValue)
      Returns an attribute of the element. If the attribute doesn't exist, defaultValue is returned.
      Parameters:
      name - The name of the attribute.
      defaultValue - Key to use if the attribute is missing.
      Preconditions:
      • name != null
      • name is a valid XML identifier
      See Also:
      • invalid reference
        setAttribute(String, Object)
      • invalid reference
        removeAttribute(String)
      • invalid reference
        nanoxml.XMLElement#enumerateAttributeNames()
      • invalid reference
        getStringAttribute(String)
      • invalid reference
        getStringAttribute(String, Hashtable, String, boolean)
    • getStringAttribute

      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 attribute attr="one", then getAttribute("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 - true if literals are valid.
      Preconditions:
      • name != null
      • name is a valid XML identifier
      • valueSet != null
      • the keys of valueSet are strings
      • the values of valueSet are strings
      See Also:
      • invalid reference
        setAttribute(String, Object)
      • invalid reference
        removeAttribute(String)
      • invalid reference
        nanoxml.XMLElement#enumerateAttributeNames()
      • invalid reference
        getStringAttribute(String)
      • invalid reference
        getStringAttribute(String, String)
    • getIntAttribute

      public int getIntAttribute(String name)
      Returns an attribute of the element. If the attribute doesn't exist, 0 is returned.
      Parameters:
      name - The name of the attribute.
      Preconditions:
      • name != null
      • name is a valid XML identifier
      See Also:
      • invalid reference
        setIntAttribute(String, int)
      • invalid reference
        nanoxml.XMLElement#enumerateAttributeNames()
      • invalid reference
        getIntAttribute(String, int)
      • invalid reference
        getIntAttribute(String, Hashtable, String, boolean)
    • getIntAttribute

      public int getIntAttribute(String name, int defaultValue)
      Returns an attribute of the element. If the attribute doesn't exist, defaultValue is returned.
      Parameters:
      name - The name of the attribute.
      defaultValue - Key to use if the attribute is missing.
      Preconditions:
      • name != null
      • name is a valid XML identifier
      See Also:
      • invalid reference
        setIntAttribute(String, int)
      • invalid reference
        nanoxml.XMLElement#enumerateAttributeNames()
      • invalid reference
        getIntAttribute(String)
      • invalid reference
        getIntAttribute(String, Hashtable, String, boolean)
    • getIntAttribute

      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" => 1 and the element contains the attribute attr="one", then getIntAttribute("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.
      allowLiteralNumbers - true if literal numbers are valid.
      Preconditions:
      • name != null
      • name is a valid XML identifier
      • valueSet != null
      • the keys of valueSet are strings
      • the values of valueSet are Integer objects
      • defaultKey is either null, a key in valueSet or an integer.
      See Also:
      • invalid reference
        setIntAttribute(String, int)
      • invalid reference
        nanoxml.XMLElement#enumerateAttributeNames()
      • invalid reference
        getIntAttribute(String)
      • invalid reference
        getIntAttribute(String, int)
    • getDoubleAttribute

      public double getDoubleAttribute(String name)
      Returns an attribute of the element. If the attribute doesn't exist, 0.0 is returned.
      Parameters:
      name - The name of the attribute.
      Preconditions:
      • name != null
      • name is a valid XML identifier
      See Also:
      • invalid reference
        setDoubleAttribute(String, double)
      • invalid reference
        nanoxml.XMLElement#enumerateAttributeNames()
      • invalid reference
        getDoubleAttribute(String, double)
      • invalid reference
        getDoubleAttribute(String, Hashtable, String, boolean)
    • getDoubleAttribute

      public double getDoubleAttribute(String name, double defaultValue)
      Returns an attribute of the element. If the attribute doesn't exist, defaultValue is returned.
      Parameters:
      name - The name of the attribute.
      defaultValue - Key to use if the attribute is missing.
      Preconditions:
      • name != null
      • name is a valid XML identifier
      See Also:
      • invalid reference
        setDoubleAttribute(String, double)
      • invalid reference
        nanoxml.XMLElement#enumerateAttributeNames()
      • invalid reference
        getDoubleAttribute(String)
      • invalid reference
        getDoubleAttribute(String, Hashtable, String, boolean)
    • getDoubleAttribute

      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.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.
      valueSet - Hashtable mapping keys to values.
      defaultKey - Key to use if the attribute is missing.
      allowLiteralNumbers - true if literal numbers are valid.
      Preconditions:
      • name != null
      • name is a valid XML identifier
      • valueSet != null
      • the keys of valueSet are strings
      • the values of valueSet are Double objects
      • defaultKey is either null, a key in valueSet or a double.
      See Also:
      • invalid reference
        setDoubleAttribute(String, double)
      • invalid reference
        nanoxml.XMLElement#enumerateAttributeNames()
      • invalid reference
        getDoubleAttribute(String)
      • invalid reference
        getDoubleAttribute(String, double)
    • getBooleanAttribute

      public boolean getBooleanAttribute(String name, String trueValue, String falseValue, boolean defaultValue)
      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.
      trueValue - The value associated with true.
      falseValue - The value associated with true.
      defaultValue - Value to use if the attribute is missing.
      Preconditions:
      • name != null
      • name is a valid XML identifier
      • trueValue and falseValue are different strings.
      See Also:
      • invalid reference
        setAttribute(String, Object)
      • invalid reference
        removeAttribute(String)
      • invalid reference
        nanoxml.XMLElement#enumerateAttributeNames()
    • getIntProperty

      public int getIntProperty(String name, Hashtable valueSet, String defaultKey)
      Deprecated.
      Use getIntAttribute instead.
      Returns an attribute by looking up a key in a hashtable.
    • getProperty

      public String getProperty(String name)
      Deprecated.
      Use getStringAttribute instead.
      Returns an attribute.
    • getProperty

      public String getProperty(String name, String defaultValue)
      Deprecated.
      Use getStringAttribute instead.
      Returns an attribute.
    • getProperty

      public int getProperty(String name, int defaultValue)
      Deprecated.
      Use getIntAttribute instead.
      Returns an attribute.
    • getProperty

      public double getProperty(String name, double defaultValue)
      Deprecated.
      Use getDoubleAttribute instead.
      Returns an attribute.
    • getProperty

      public boolean getProperty(String key, String trueValue, String falseValue, boolean defaultValue)
      Deprecated.
      Use getBooleanAttribute instead.
      Returns an attribute.
    • getProperty

      public Object getProperty(String name, Hashtable valueSet, String defaultKey)
      Deprecated.
      Use getAttribute instead.
      Returns an attribute by looking up a key in a hashtable.
    • getStringProperty

      public String getStringProperty(String name, Hashtable valueSet, String defaultKey)
      Deprecated.
      Use getStringAttribute instead.
      Returns an attribute by looking up a key in a hashtable.
    • getSpecialIntProperty

      public int getSpecialIntProperty(String name, Hashtable valueSet, String defaultKey)
      Deprecated.
      Use getIntAttribute instead.
      Returns an attribute by looking up a key in a hashtable.
    • getSpecialDoubleProperty

      public double getSpecialDoubleProperty(String name, Hashtable valueSet, String defaultKey)
      Deprecated.
      Use getDoubleAttribute instead.
      Returns an attribute by looking up a key in a hashtable.
    • getName

      public String getName()
      Returns the name of the element.
      See Also:
      • invalid reference
        setName(String)
    • getTagName

      public String getTagName()
      Deprecated.
      Use getName instead.
      Returns the name of the element.
    • parseFromReader

      public void parseFromReader(Reader reader) throws IOException, XMLParseException
      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 element parsed from the reader
      • the reader points to the first character following the last '>' character of the XML element
    • parseFromReader

      public void parseFromReader(Reader reader, int startingLineNr) throws IOException, XMLParseException
      Reads 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 != null
      • reader is 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
    • parseString

      public void parseString(String string) throws XMLParseException
      Reads one XML element from a String and parses it.
      Parameters:
      reader - 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 element parsed from the reader
    • parseString

      public void parseString(String string, int offset) throws XMLParseException
      Reads one XML element from a String and parses it.
      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 element parsed from the reader
      reader - The reader from which to retrieve the XML data.
    • parseString

      public void parseString(String string, int offset, int end) throws XMLParseException
      Reads one XML element from a String and parses it.
      Parameters:
      offset - The first character in string to scan.
      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 element parsed from the reader
      reader - The reader from which to retrieve the XML data.
    • parseString

      public void parseString(String string, int offset, int end, int startingLineNr) throws XMLParseException
      Reads one XML element from a String and parses it.
      Parameters:
      offset - The first character in string to 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 != null
      • end <= string.length()
      • offset < end
      • offset >= 0
      Postconditions:
      • the state of the receiver is updated to reflect the XML element parsed from the reader
      reader - The reader from which to retrieve the XML data.
    • parseCharArray

      public void parseCharArray(char[] input, int offset, int end) throws XMLParseException
      Reads one XML element from a char array and parses it.
      Parameters:
      offset - The first character in string to scan.
      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 element parsed from the reader
      reader - The reader from which to retrieve the XML data.
    • parseCharArray

      public void parseCharArray(char[] input, int offset, int end, int startingLineNr) throws XMLParseException
      Reads one XML element from a char array and parses it.
      Parameters:
      offset - The first character in string to 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 != null
      • end <= input.length
      • offset < end
      • offset >= 0
      Postconditions:
      • the state of the receiver is updated to reflect the XML element parsed from the reader
      reader - The reader from which to retrieve the XML data.
    • removeChild

      public void removeChild(XMLElement child)
      Removes a child element.
      Parameters:
      child - The child element to remove.
      Preconditions:
      • child != null
      • child is a child element of the receiver
      Postconditions:
      • countChildren() => old.countChildren() - 1
      • enumerateChildren() => old.enumerateChildren() - child
      • getChildren() => old.enumerateChildren() - child
      See Also:
      • invalid reference
        addChild(XMLElement)
      • invalid reference
        nanoxml.XMLElement#countChildren()
      • invalid reference
        nanoxml.XMLElement#enumerateChildren()
      • invalid reference
        nanoxml.XMLElement#getChildren()
    • removeAttribute

      public void removeAttribute(String name)
      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:
      • invalid reference
        nanoxml.XMLElement#enumerateAttributeNames()
      • invalid reference
        setDoubleAttribute(String, double)
      • invalid reference
        setIntAttribute(String, int)
      • invalid reference
        setAttribute(String, Object)
      • invalid reference
        getAttribute(String)
      • invalid reference
        getAttribute(String, Object)
      • invalid reference
        getAttribute(String, Hashtable, String, boolean)
      • invalid reference
        getStringAttribute(String)
      • invalid reference
        getStringAttribute(String, String)
      • invalid reference
        getStringAttribute(String, Hashtable, String, boolean)
      • invalid reference
        getIntAttribute(String)
      • invalid reference
        getIntAttribute(String, int)
      • invalid reference
        getIntAttribute(String, Hashtable, String, boolean)
      • invalid reference
        getDoubleAttribute(String)
      • invalid reference
        getDoubleAttribute(String, double)
      • invalid reference
        getDoubleAttribute(String, Hashtable, String, boolean)
      • invalid reference
        getBooleanAttribute(String, String, String, boolean)
    • removeProperty

      public void removeProperty(String name)
      Deprecated.
      Use removeAttribute instead.
      Removes an attribute.
      Parameters:
      name - The name of the attribute.
    • removeChild

      public void removeChild(String name)
      Deprecated.
      Use removeAttribute instead.
      Removes an attribute.
      Parameters:
      name - The name of the attribute.
    • setContent

      public void setContent(String content)
      Changes the content string.
      Parameters:
      content - The new content string.
    • setTagName

      public void setTagName(String name)
      Deprecated.
      Use setName instead.
      Changes the name of the element.
      Parameters:
      name - The new name.
    • setName

      public void setName(String name)
      Changes the name of the element.
      Parameters:
      name - The new name.
      Preconditions:
      • name != null
      • name is a valid XML identifier
      See Also:
      • invalid reference
        nanoxml.XMLElement#getName()
    • toString

      public String toString()
      Writes the XML element to a string.
      Overrides:
      toString in class Object
      See Also:
      • invalid reference
        write(Writer)
    • write

      public void write(Writer writer) throws IOException
      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:
      IOException - If the data could not be written to the writer.
      See Also:
      • invalid reference
        nanoxml.XMLElement#toString()