Package org.xmlpull.v1.builder
Class XmlInfosetBuilder
- java.lang.Object
-
- org.xmlpull.v1.builder.XmlInfosetBuilder
-
- Direct Known Subclasses:
XmlInfosetBuilderImpl
public abstract class XmlInfosetBuilder extends Object
By default builder is using non-validating pull parser with next() method without namespaces to build tree consisting only of XmlDocument, XmlElemenet and String nodes. Additional options are available to change builder behaviour and to generate any deseired subset of XML Information Set- Version:
- $Revision: 1.8 $
- Author:
- Aleksander Slominski
-
-
Field Summary
Fields Modifier and Type Field Description protected XmlPullParserFactoryfactory
-
Constructor Summary
Constructors Constructor Description XmlInfosetBuilder()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description XmlPullParserFactorygetFactory()Method get XmlPull factory that is ued by this builder.XmlDocumentnewDocument()Create a new document.abstract XmlDocumentnewDocument(String version, Boolean standalone, String characterEncoding)Create a new document with given XML prolog.abstract XmlElementnewFragment(String elementName)Create XML fragment that is not associated with any document.abstract XmlElementnewFragment(String elementNamespace, String elementName)Create XML fragment that is not associated with any document.abstract XmlElementnewFragment(XmlNamespace elementNamespace, String elementName)Create XML fragment that is not associated with any document.static XmlInfosetBuildernewInstance()Create a new instance of the builder.static XmlInfosetBuildernewInstance(XmlPullParserFactory factory)abstract XmlNamespacenewNamespace(String namespaceName)Create a new namespace that is not associated with any XML document.abstract XmlNamespacenewNamespace(String prefix, String namespaceName)Create a new namespace that is not associated with any XML document.abstract XmlDocumentparse(XmlPullParser sourceForDocument)Parse document - parser must be in START_DOCUMENT state.XmlElementparseFragementFromInputStream(InputStream is, String encoding)Parse input stream to create XML fragment using specified encoding.abstract XmlElementparseFragment(XmlPullParser sourceForXml)Parse fragment - parser must be on START_TAG.XmlElementparseFragmentFromInputStream(InputStream is)Parse input stream to create XML fragment.XmlElementparseFragmentFromReader(Reader reader)Parse reader to create XML fragment.XmlDocumentparseInputStream(InputStream is)Parse input stream to create XML document.XmlDocumentparseInputStream(InputStream is, String encoding)Parse input stream to create XML document using specified encoding.abstract ObjectparseItem(XmlPullParser pp)Will convert current parser state into event rerpresenting XML infoset item: START_Document: XmlDocument without root element START_TAG: XmlElement without children TEXT: String or XmlCHaracters depending on builder mode additiona states to corresponding XML infoset items (when implemented!)abstract XmlDocumentparseLocation(String locationUrl)Parse input from URL location to create XML document.XmlDocumentparseReader(Reader reader)Parse reader to create XML document.abstract XmlElementparseStartTag(XmlPullParser pp)Parser must be on START_TAG and this method will convert START_TAG content into XmlELement.abstract voidserialize(Object item, XmlSerializer serializer)Serialize XML infoset item including serializing of children.abstract voidserializeEndTag(XmlElement el, XmlSerializer ser)Write XML end tag with information provided in XML element.abstract voidserializeItem(Object item, XmlSerializer serializer)Serialize XML infoset item without serializing any of children.abstract voidserializeStartTag(XmlElement el, XmlSerializer ser)Write XML start tag with information provided in XML element.voidserializeToOutputStream(Object item, OutputStream os)Serialize item using default UTF8 encoding.voidserializeToOutputStream(Object item, OutputStream os, String encoding)Serialize item to given output stream using given character encoding.StringserializeToString(Object item)Convert item into String representing XML content.voidserializeToWriter(Object item, Writer writer)Serialize item to given writer.voidskipSubTree(XmlPullParser pp)Move parser from START_TAG to the corresponding END_TAG which means that XML sub tree is skipped.
-
-
-
Field Detail
-
factory
protected XmlPullParserFactory factory
-
-
Method Detail
-
newInstance
public static XmlInfosetBuilder newInstance() throws XmlBuilderException
Create a new instance of the builder.- Throws:
XmlBuilderException
-
newInstance
public static XmlInfosetBuilder newInstance(XmlPullParserFactory factory) throws XmlBuilderException
- Throws:
XmlBuilderException
-
getFactory
public XmlPullParserFactory getFactory() throws XmlBuilderException
Method get XmlPull factory that is ued by this builder.- Throws:
XmlBuilderException
-
newDocument
public XmlDocument newDocument() throws XmlBuilderException
Create a new document.- Throws:
XmlBuilderException
-
newDocument
public abstract XmlDocument newDocument(String version, Boolean standalone, String characterEncoding) throws XmlBuilderException
Create a new document with given XML prolog.- Parameters:
version- a Stringstandalone- a BooleancharacterEncoding- a String- Returns:
- a XmlDocument
- Throws:
XmlBuilderException
-
newFragment
public abstract XmlElement newFragment(String elementName) throws XmlBuilderException
Create XML fragment that is not associated with any document.- Parameters:
elementName- name of element- Returns:
- a XmlElement
- Throws:
XmlBuilderException
-
newFragment
public abstract XmlElement newFragment(String elementNamespace, String elementName) throws XmlBuilderException
Create XML fragment that is not associated with any document.- Parameters:
elementNamespace- namespace of elementelementName- name of element- Returns:
- a XmlElement
- Throws:
XmlBuilderException
-
newFragment
public abstract XmlElement newFragment(XmlNamespace elementNamespace, String elementName) throws XmlBuilderException
Create XML fragment that is not associated with any document.- Parameters:
elementNamespace- a XmlNamespaceelementName- a String- Returns:
- a XmlElement
- Throws:
XmlBuilderException
-
newNamespace
public abstract XmlNamespace newNamespace(String namespaceName) throws XmlBuilderException
Create a new namespace that is not associated with any XML document.- Parameters:
namespaceName- a String- Returns:
- a XmlNamespace
- Throws:
XmlBuilderException
-
newNamespace
public abstract XmlNamespace newNamespace(String prefix, String namespaceName) throws XmlBuilderException
Create a new namespace that is not associated with any XML document.- Parameters:
prefix- a StringnamespaceName- a String- Returns:
- a XmlNamespace
- Throws:
XmlBuilderException
-
parse
public abstract XmlDocument parse(XmlPullParser sourceForDocument) throws XmlBuilderException
Parse document - parser must be in START_DOCUMENT state.- Throws:
XmlBuilderException
-
parseItem
public abstract Object parseItem(XmlPullParser pp) throws XmlBuilderException
Will convert current parser state into event rerpresenting XML infoset item:- START_Document: XmlDocument without root element
- START_TAG: XmlElement without children
- TEXT: String or XmlCHaracters depending on builder mode
- additiona states to corresponding XML infoset items (when implemented!)
- Throws:
XmlBuilderException
-
parseStartTag
public abstract XmlElement parseStartTag(XmlPullParser pp) throws XmlBuilderException
Parser must be on START_TAG and this method will convert START_TAG content into XmlELement. Parser location is not chnaged.- Throws:
XmlBuilderException
-
parseInputStream
public XmlDocument parseInputStream(InputStream is) throws XmlBuilderException
Parse input stream to create XML document.- Parameters:
is- an InputStream- Returns:
- a XmlDocument
- Throws:
XmlBuilderException
-
parseInputStream
public XmlDocument parseInputStream(InputStream is, String encoding) throws XmlBuilderException
Parse input stream to create XML document using specified encoding.- Parameters:
is- an InputStreamencoding- a String- Returns:
- a XmlDocument
- Throws:
XmlBuilderException
-
parseReader
public XmlDocument parseReader(Reader reader) throws XmlBuilderException
Parse reader to create XML document.- Parameters:
reader- a Reader- Returns:
- a XmlDocument
- Throws:
XmlBuilderException
-
parseLocation
public abstract XmlDocument parseLocation(String locationUrl) throws XmlBuilderException
Parse input from URL location to create XML document.- Parameters:
locationUrl- a String- Returns:
- a XmlDocument
- Throws:
XmlBuilderException
-
parseFragment
public abstract XmlElement parseFragment(XmlPullParser sourceForXml) throws XmlBuilderException
Parse fragment - parser must be on START_TAG. After parsing is on corresponding END_TAG.- Throws:
XmlBuilderException
-
parseFragmentFromInputStream
public XmlElement parseFragmentFromInputStream(InputStream is) throws XmlBuilderException
Parse input stream to create XML fragment.- Parameters:
is- an InputStream- Returns:
- a XmlElement
- Throws:
XmlBuilderException
-
parseFragementFromInputStream
public XmlElement parseFragementFromInputStream(InputStream is, String encoding) throws XmlBuilderException
Parse input stream to create XML fragment using specified encoding.- Parameters:
is- an InputStreamencoding- a String- Returns:
- a XmlElement
- Throws:
XmlBuilderException
-
parseFragmentFromReader
public XmlElement parseFragmentFromReader(Reader reader) throws XmlBuilderException
Parse reader to create XML fragment.- Parameters:
reader- a Reader- Returns:
- a XmlElement
- Throws:
XmlBuilderException
-
skipSubTree
public void skipSubTree(XmlPullParser pp) throws XmlBuilderException
Move parser from START_TAG to the corresponding END_TAG which means that XML sub tree is skipped.- Parameters:
pp- a XmlPullParser- Throws:
XmlBuilderException
-
serializeStartTag
public abstract void serializeStartTag(XmlElement el, XmlSerializer ser) throws XmlBuilderException
Write XML start tag with information provided in XML element.- Parameters:
el- a XmlElementser- a XmlSerializer- Throws:
XmlBuilderException
-
serializeEndTag
public abstract void serializeEndTag(XmlElement el, XmlSerializer ser) throws XmlBuilderException
Write XML end tag with information provided in XML element.- Parameters:
el- a XmlElementser- a XmlSerializer- Throws:
XmlBuilderException
-
serialize
public abstract void serialize(Object item, XmlSerializer serializer) throws XmlBuilderException
Serialize XML infoset item including serializing of children. If item is Collection all items in collection are serialized by recursively calling this function. This method assumes that item is either interface defined in XB1 API, class String, or that item implements XmlSerializable otherwise IllegalArgumentException is thrown.- Throws:
XmlBuilderException
-
serializeItem
public abstract void serializeItem(Object item, XmlSerializer serializer) throws XmlBuilderException
Serialize XML infoset item without serializing any of children. This method assumes that item is either interface defined in XB1 API, class String, or item that implements XmlSerializable otherwise IllegalArgumentException is thrown.- Throws:
XmlBuilderException
-
serializeToOutputStream
public void serializeToOutputStream(Object item, OutputStream os) throws XmlBuilderException
Serialize item using default UTF8 encoding.
-
serializeToOutputStream
public void serializeToOutputStream(Object item, OutputStream os, String encoding) throws XmlBuilderException
Serialize item to given output stream using given character encoding.- Parameters:
item- an Objectos- an OutputStreamencoding- a String- Throws:
XmlBuilderException- See Also:
serializeItem(java.lang.Object,org.xmlpull.v1.XmlSerializer)
-
serializeToWriter
public void serializeToWriter(Object item, Writer writer) throws XmlBuilderException
Serialize item to given writer.- Parameters:
item- an Objectwriter- a Writer- Throws:
XmlBuilderException
-
serializeToString
public String serializeToString(Object item) throws XmlBuilderException
Convert item into String representing XML content.- Parameters:
item- an Object- Returns:
- a String
- Throws:
XmlBuilderException
-
-