public class XMLElement
extends java.lang.Object
implements java.io.Serializable
StdXMLBuilder
,
Serialized FormModifier and Type | Field and Description |
---|---|
private java.util.Properties |
attributes
The attributes of the element.
|
private java.util.Vector |
children
The child elements.
|
private java.lang.String |
content
The content of the element.
|
private int |
lineNr
The line in the source data where this element starts.
|
private java.lang.String |
name
The name of the element.
|
static int |
NO_LINE
No line number defined.
|
(package private) static long |
serialVersionUID
Necessary for serialization.
|
private java.lang.String |
systemID
The system ID of the source data where this element is located.
|
Constructor and Description |
---|
XMLElement()
Creates an empty element to be used for #PCDATA content.
|
XMLElement(java.lang.String name)
Creates an empty element.
|
XMLElement(java.lang.String name,
java.lang.String systemID,
int lineNr)
Creates an empty element.
|
Modifier and Type | Method and Description |
---|---|
void |
addChild(XMLElement child)
Adds a child element.
|
java.util.Enumeration |
enumerateAttributeNames()
Returns an enumeration of all attribute names.
|
java.util.Enumeration |
enumerateChildren()
Returns an enumeration of all child elements.
|
protected void |
finalize()
Cleans up the object when it's destroyed.
|
java.lang.String |
getAttribute(java.lang.String name)
Returns the value of an attribute.
|
java.lang.String |
getAttribute(java.lang.String name,
java.lang.String defaultValue)
Returns the value of an attribute.
|
java.util.Properties |
getAttributes()
Returns all attributes as a Properties object.
|
XMLElement |
getChildAtIndex(int index)
Returns the child at a specific index.
|
java.util.Vector |
getChildren()
Returns a vector containing all the child elements.
|
int |
getChildrenCount()
Returns the number of children.
|
java.util.Vector |
getChildrenNamed(java.lang.String name)
Returns a vector of all child elements named name.
|
java.lang.String |
getContent()
Return the #PCDATA content of the element.
|
XMLElement |
getFirstChildNamed(java.lang.String name)
Searches a child element.
|
int |
getLineNr()
Returns the line number in the data where the element started.
|
java.lang.String |
getName()
Returns the name of the element.
|
java.lang.String |
getSystemID()
Returns the system ID of the data where the element started.
|
boolean |
hasAttribute(java.lang.String name)
Returns whether an attribute exists.
|
boolean |
hasChildren()
Returns whether the element has children.
|
boolean |
isLeaf()
Returns whether the element is a leaf element.
|
void |
removeAttribute(java.lang.String name)
Removes an attribute.
|
void |
removeChild(XMLElement child)
Removes a child element.
|
void |
removeChildAtIndex(int index)
Removes the child located at a certain index.
|
void |
setAttribute(java.lang.String name,
java.lang.String value)
Sets an attribute.
|
void |
setContent(java.lang.String content)
Sets the #PCDATA content.
|
void |
setName(java.lang.String name)
Sets the name.
|
static final long serialVersionUID
public static final int NO_LINE
private java.util.Properties attributes
private java.util.Vector children
private java.lang.String name
private java.lang.String content
private java.lang.String systemID
private int lineNr
public XMLElement()
public XMLElement(java.lang.String name)
name
- the name of the element.public XMLElement(java.lang.String name, java.lang.String systemID, int lineNr)
name
- the name of the element.systemID
- the system ID of the XML data where the element starts.lineNr
- the line in the XML data where the element starts.protected void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
java.lang.Throwable
public java.lang.String getName()
public void setName(java.lang.String name)
name
- the non-null name.public void addChild(XMLElement child)
child
- the non-null child to add.public void removeChild(XMLElement child)
child
- the non-null child to remove.public void removeChildAtIndex(int index)
index
- the index of the child, where the first child has index 0.public java.util.Enumeration enumerateChildren()
public boolean isLeaf()
public boolean hasChildren()
public int getChildrenCount()
public java.util.Vector getChildren()
public XMLElement getChildAtIndex(int index) throws java.lang.ArrayIndexOutOfBoundsException
java.lang.ArrayIndexOutOfBoundsException
- if the index is out of bounds.public XMLElement getFirstChildNamed(java.lang.String name)
name
- the name of the child to search for.public java.util.Vector getChildrenNamed(java.lang.String name)
name
- the name of the children to search for.public java.lang.String getAttribute(java.lang.String name)
name
- the non-null name of the attribute.public java.lang.String getAttribute(java.lang.String name, java.lang.String defaultValue)
name
- the non-null name of the attribute.defaultValue
- the default value of the attribute.public void setAttribute(java.lang.String name, java.lang.String value)
name
- the non-null name of the attribute.value
- the non-null value of the attribute.public void removeAttribute(java.lang.String name)
name
- the non-null name of the attribute.public java.util.Enumeration enumerateAttributeNames()
public boolean hasAttribute(java.lang.String name)
public java.util.Properties getAttributes()
public java.lang.String getSystemID()
getLineNr()
public int getLineNr()
NO_LINE
,
getSystemID()
public java.lang.String getContent()
public void setContent(java.lang.String content)
content
- the (possibly null) content.