Package org.kxml2.kdom
Class Document
- java.lang.Object
-
- org.kxml2.kdom.Node
-
- org.kxml2.kdom.Document
-
public class Document extends Node
The document consists of some legacy events and a single root element. This class basically adds some consistency checks to Node.
-
-
Field Summary
Fields Modifier and Type Field Description protected introotIndex-
Fields inherited from class org.kxml2.kdom.Node
CDSECT, children, COMMENT, DOCDECL, DOCUMENT, ELEMENT, ENTITY_REF, IGNORABLE_WHITESPACE, PROCESSING_INSTRUCTION, TEXT, types
-
-
Constructor Summary
Constructors Constructor Description Document()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddChild(int index, int type, Object child)Adds a child at the given index position.StringgetEncoding()returns "#document"StringgetName()ElementgetRootElement()returns the root element of this document.BooleangetStandalone()voidparse(XmlPullParser parser)reads the document and checks if the last event is END_DOCUMENT.voidremoveChild(int index)Removes the child object at the given indexvoidsetEncoding(String enc)voidsetStandalone(Boolean standalone)voidwrite(XmlSerializer writer)Writes this node to the given XmlWriter.-
Methods inherited from class org.kxml2.kdom.Node
addChild, createElement, getChild, getChildCount, getElement, getElement, getText, getType, indexOf, isText, writeChildren
-
-
-
-
Method Detail
-
getEncoding
public String getEncoding()
returns "#document"
-
setEncoding
public void setEncoding(String enc)
-
setStandalone
public void setStandalone(Boolean standalone)
-
getStandalone
public Boolean getStandalone()
-
getName
public String getName()
-
addChild
public void addChild(int index, int type, Object child)Adds a child at the given index position. Throws an exception when a second root element is added
-
parse
public void parse(XmlPullParser parser) throws IOException, XmlPullParserException
reads the document and checks if the last event is END_DOCUMENT. If not, an exception is thrown. The end event is consumed. For parsing partial XML structures, consider using Node.parse ().- Overrides:
parsein classNode- Throws:
IOExceptionXmlPullParserException
-
removeChild
public void removeChild(int index)
Description copied from class:NodeRemoves the child object at the given index- Overrides:
removeChildin classNode
-
getRootElement
public Element getRootElement()
returns the root element of this document.
-
write
public void write(XmlSerializer writer) throws 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.- Overrides:
writein classNode- Throws:
IOException
-
-