Package org.kxml2.kdom
Class Node
- java.lang.Object
-
- org.kxml2.kdom.Node
-
-
Field Summary
Fields Modifier and Type Field Description static int
CDSECT
static int
COMMENT
static int
DOCDECL
static int
DOCUMENT
static int
ELEMENT
static int
ENTITY_REF
static int
IGNORABLE_WHITESPACE
static int
PROCESSING_INSTRUCTION
static int
TEXT
-
Constructor Summary
Constructors Constructor Description Node()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addChild(int index, int type, java.lang.Object child)
inserts the given child object of the given type at the given index.void
addChild(int type, java.lang.Object child)
convenience method for addChild (getChildCount (), child)Element
createElement(java.lang.String namespace, java.lang.String name)
Builds a default element with the given properties.java.lang.Object
getChild(int index)
Returns the child object at the given index.int
getChildCount()
Returns the number of child objectsElement
getElement(int index)
returns the element at the given index.Element
getElement(java.lang.String namespace, java.lang.String name)
Returns the element with the given namespace and name.java.lang.String
getText(int index)
Returns the text node with the given index or null if the node with the given index is not a text node.int
getType(int index)
Returns the type of the child at the given index.int
indexOf(java.lang.String namespace, java.lang.String name, int startIndex)
Performs search for an element with the given namespace and name, starting at the given start index.boolean
isText(int i)
void
parse(org.xmlpull.v1.XmlPullParser parser)
Recursively builds the child elements from the given parser until an end tag or end document is found.void
removeChild(int idx)
Removes the child object at the given indexvoid
write(org.xmlpull.v1.XmlSerializer writer)
Writes this node to the given XmlWriter.void
writeChildren(org.xmlpull.v1.XmlSerializer writer)
Writes the children of this node to the given XmlWriter.
-
-
-
Field Detail
-
DOCUMENT
public static final int DOCUMENT
- See Also:
- Constant Field Values
-
ELEMENT
public static final int ELEMENT
- See Also:
- Constant Field Values
-
TEXT
public static final int TEXT
- See Also:
- Constant Field Values
-
CDSECT
public static final int CDSECT
- See Also:
- Constant Field Values
-
ENTITY_REF
public static final int ENTITY_REF
- See Also:
- Constant Field Values
-
IGNORABLE_WHITESPACE
public static final int IGNORABLE_WHITESPACE
- See Also:
- Constant Field Values
-
PROCESSING_INSTRUCTION
public static final int PROCESSING_INSTRUCTION
- See Also:
- Constant Field Values
-
COMMENT
public static final int COMMENT
- See Also:
- Constant Field Values
-
DOCDECL
public static final int DOCDECL
- See Also:
- Constant Field Values
-
-
Method Detail
-
addChild
public void addChild(int index, int type, java.lang.Object child)
inserts the given child object of the given type at the given index.
-
addChild
public void addChild(int type, java.lang.Object child)
convenience method for addChild (getChildCount (), child)
-
createElement
public Element createElement(java.lang.String namespace, java.lang.String name)
Builds a default element with the given properties. Elements should always be created using this method instead of the constructor in order to enable construction of specialized subclasses by deriving custom Document classes. Please note: For no namespace, please use Xml.NO_NAMESPACE, null is not a legal value. Currently, null is converted to Xml.NO_NAMESPACE, but future versions may throw an exception.
-
getChild
public java.lang.Object getChild(int index)
Returns the child object at the given index. For child elements, an Element object is returned. For all other child types, a String is returned.
-
getChildCount
public int getChildCount()
Returns the number of child objects
-
getElement
public Element getElement(int index)
returns the element at the given index. If the node at the given index is a text node, null is returned
-
getElement
public Element getElement(java.lang.String namespace, java.lang.String name)
Returns the element with the given namespace and name. If the element is not found, or more than one matching elements are found, an exception is thrown.
-
getText
public java.lang.String getText(int index)
Returns the text node with the given index or null if the node with the given index is not a text node.
-
getType
public int getType(int index)
Returns the type of the child at the given index. Possible types are ELEMENT, TEXT, COMMENT, and PROCESSING_INSTRUCTION
-
indexOf
public int indexOf(java.lang.String namespace, java.lang.String name, int startIndex)
Performs search for an element with the given namespace and name, starting at the given start index. A null namespace matches any namespace, please use Xml.NO_NAMESPACE for no namespace). returns -1 if no matching element was found.
-
isText
public boolean isText(int i)
-
parse
public void parse(org.xmlpull.v1.XmlPullParser parser) throws java.io.IOException, org.xmlpull.v1.XmlPullParserException
Recursively builds the child elements from the given parser until an end tag or end document is found. The end tag is not consumed.- Throws:
java.io.IOException
org.xmlpull.v1.XmlPullParserException
-
removeChild
public void removeChild(int idx)
Removes the child object at the given index
-
write
public void write(org.xmlpull.v1.XmlSerializer writer) throws java.io.IOException
Writes this node to the given XmlWriter. For node and document, this method is identical to writeChildren, except that the stream is flushed automatically.- Throws:
java.io.IOException
-
writeChildren
public void writeChildren(org.xmlpull.v1.XmlSerializer writer) throws java.io.IOException
Writes the children of this node to the given XmlWriter.- Throws:
java.io.IOException
-
-