|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectdiva.util.xml.XmlElement
public class XmlElement
An XmlElement is a node of a tree representing an XML file. It is a concrete class. An XmlReader object will construct a tree of XmlElements from an XML file and place it into an XmlDocument. Applications can traverse a tree of XmlElements to extract data or build their own application-specific data structure. They can also construct a tree of XmlElements and add it to an XmlDocument and generate an XML output file.
Field Summary | |
---|---|
private java.util.TreeMap |
_attributes
|
private java.util.List |
_children
The child elements of this element. |
private XmlElement |
_parent
|
private java.lang.String |
_pcdata
|
private java.lang.String |
_type
|
Constructor Summary | |
---|---|
XmlElement()
Create a new XmlElement of unknown type. |
|
XmlElement(java.lang.String type)
Create a new XmlElement with element type given by the string. |
|
XmlElement(java.lang.String type,
java.util.Map attrs)
Create a new XmlElement with element type with the given name and the given attributes. |
Method Summary | |
---|---|
void |
addElement(XmlElement e)
Add a child element to this element. |
void |
appendPCData(java.lang.String s)
Add the String to the end of the current PCDATA for this element. |
java.util.Iterator |
attributeNames()
Return an enumeration over the names of the attributes in this schematic. |
boolean |
containsElement(XmlElement elt)
Test if this element contains the given element. |
int |
elementCount()
Return the number of child elements. |
java.util.Iterator |
elements()
Return an Iterator of all the child elements of this element. |
java.util.Iterator |
elements(java.lang.String type)
Return an Iterator of all the child elements of this element that have the given element type. |
java.lang.String |
getAttribute(java.lang.String name)
Return the value of the attribute with the given name, or null if there isn't one. |
java.util.Map |
getAttributeMap()
Return the map from attribute names to value. |
java.util.List |
getChildList()
Return the list of child elements. |
XmlElement |
getElement(java.lang.String type)
Return the first child element of this element with the given type, or null if there isn't one. |
XmlElement |
getElement(java.lang.String type,
java.lang.String name)
Return the first child element of this element with the given type and name, or null if there isn't one. |
XmlElement |
getParent()
Return the parent element of this element, or null if it has no parent. |
java.lang.String |
getPCData()
Return the PCData that is associated with this XmlElement. |
java.lang.String |
getType()
Return the type of this XmlElement. |
boolean |
hasAttribute(java.lang.String name)
Test if this element has the attribute with the given name. |
void |
removeAttribute(java.lang.String name)
Remove an attribute from this element |
void |
removeElement(XmlElement e)
Remove a child element from this element |
void |
setAttribute(java.lang.String name,
java.lang.String value)
Set the attribute with the given name to the given value. |
void |
setParent(XmlElement p)
Set the parent element of this element. |
void |
setPCData(java.lang.String s)
Set the text of this element to the given string. |
void |
setType(java.lang.String s)
Set the type of this element |
java.lang.String |
toString()
Convert this element to a string in XML |
void |
writeXML(java.io.Writer out,
java.lang.String prefix)
Print this element to a Writer |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private java.util.List _children
private java.util.TreeMap _attributes
private java.lang.String _type
private java.lang.String _pcdata
private XmlElement _parent
Constructor Detail |
---|
public XmlElement(java.lang.String type)
type
- The element typepublic XmlElement()
public XmlElement(java.lang.String type, java.util.Map attrs)
type
- The element typeattrs
- The attributes of this XmlElement.Method Detail |
---|
public void addElement(XmlElement e)
public void appendPCData(java.lang.String s)
public java.util.Iterator attributeNames()
public boolean containsElement(XmlElement elt)
public int elementCount()
public java.util.Iterator elements()
public java.util.Iterator elements(java.lang.String type)
public java.lang.String getAttribute(java.lang.String name)
public java.util.Map getAttributeMap()
public java.util.List getChildList()
public XmlElement getElement(java.lang.String type)
public XmlElement getElement(java.lang.String type, java.lang.String name)
public java.lang.String getType()
public XmlElement getParent()
public java.lang.String getPCData()
public boolean hasAttribute(java.lang.String name)
public void removeAttribute(java.lang.String name)
public void removeElement(XmlElement e)
public void setAttribute(java.lang.String name, java.lang.String value)
public void setParent(XmlElement p)
public void setPCData(java.lang.String s)
public void setType(java.lang.String s)
public java.lang.String toString()
toString
in class java.lang.Object
public void writeXML(java.io.Writer out, java.lang.String prefix) throws java.io.IOException
java.io.IOException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |