org.gjt.xpp.x2impl.x2pullparser

Class X2PullParser

public class X2PullParser extends Object implements XmlPullParser, XmlPullParserEventPosition, XmlPullParserBufferControl, XMLErrorHandler, XMLDocumentHandler

This is Xerces 2 driver that uses XNI pull parsing capabilities to implement XML Pull Parser API. Advantages: Limitations:

Author: Aleksander Slominski

Nested Class Summary
protected classX2PullParser.CumulativeReader
Field Summary
protected booleanallowedMixedContent
protected X2Attribute[]attrPos
temporary array of current attributes
protected intattrPosEnd
index for last attribute in attrPos array
protected intattrPosSize
size of attrPos array
protected QNameattrQName
protected StringBuffercontentBuf
Content of current element if in CONTENT state
protected intcontentEventEnd
protected intcontentEventStart
protected X2PullParser.CumulativeReadercumulativeReader
protected booleandisableOffsetTracking
protected X2ElementContent[]elStack
temprary array to keep ElementContent stack
protected intelStackDepth
how many elements are on elStack
protected intelStackSize
size of elStack array
protected booleanemptyElement
Have we read empty element?
protected inteventEnd
end position of current event in tokenizer biffer
protected inteventStart
start position of current event in tokenizer biffer
protected XMLDocumentSourcefDocumentSource
Document source
protected booleangotContent
protected XMLInputSourceinputSource
protected XMLLocatorlocator
protected booleanmixInElement
protected booleanneedToSetInput
protected bytenextState
protected booleannonWhitespaceContent
protected static StringNAMESPACES_FEATURE_ID
protected static StringNAMESPACE_PREFIXES_FEATURE_ID
protected Hashtableprefix2Ns
mapping of names prefixes to uris
protected XMLPullParserConfigurationpullParserConfiguration
StringPOS_ABSOLUTE_END
StringPOS_ABSOLUTE_START
protected booleanreportNsAttribs
should parser report namespace xmlns* attributes ?
protected booleanseenContent
protected booleanseenCR
protected ExceptionseenException
protected booleanseenRootElement
Have we seen root element
protected booleanshrinkable
protected booleanstartTagInitialized
protected bytestate
what is current event type as returned from next()?
protected booleansupportNs
should parser support namespaces?
Constructor Summary
X2PullParser()
Create instance of pull parser.
Method Summary
voidcharacters(XMLString text, Augmentations augs)
voidcomment(XMLString text, Augmentations augs)
voiddoctypeDecl(String rootElement, String publicId, String systemId, Augmentations augs)
voidemptyElement(QName element, XMLAttributes attributes, Augmentations augs)
voidendCDATA(Augmentations augs)
voidendDocument(Augmentations augs)
voidendElement(QName element, Augmentations augs)
voidendEntity(String name, Augmentations augs)
voidendGeneralEntity(String name, Augmentations augs)
voidendPrefixMapping(String prefix, Augmentations augs)
protected voidensureAttribs(int size)
Make sure that in attributes temporary array is enough space.
protected voidensureCapacity(int size)
Make sure that we have enough space to keep element stack if passed size.
voiderror(String domain, String key, XMLParseException ex)
Error.
voidfatalError(String domain, String key, XMLParseException ex)
Fatal error.
intgetBufferShrinkOffset()
intgetColumnNumber()
intgetContentLength()
intgetDepth()
XMLDocumentSourcegetDocumentSource()
Returns the document source
char[]getEventBuffer()
intgetEventEnd()
intgetEventStart()
bytegetEventType()
intgetHardLimit()
intgetLineNumber()
StringgetLocalName()
intgetNamespacesLength(int depth)
StringgetNamespaceUri()
StringgetPosDesc()
Return string describing current position of parser in input stream as text 'at line %d (row) and column %d (colum) [seen %s...]'.
StringgetPrefix()
StringgetQNameLocal(String qName)
StringgetQNameUri(String qName)
StringgetRawName()
intgetSoftLimit()
voidignorableWhitespace(XMLString text, Augmentations augs)
booleanisAllowedMixedContent()
booleanisBufferShrinkable()
booleanisNamespaceAttributesReporting()
booleanisNamespaceAware()
booleanisWhitespaceContent()
Return true if just read CONTENT contained only white spaces.
bytenext()
This is a key method - translates XNI callbacks into XPP events (such as START_TAG, END_TAG, CONTENT). or END_DOCUMENT if no more input.
voidprocessingInstruction(String target, XMLString data, Augmentations augs)
StringreadContent()
Return String that contains just read CONTENT.
voidreadEndTag(XmlEndTag etag)
Read value of just read END_TAG into passed as argument EndTag.
voidreadNamespacesPrefixes(int depth, String[] prefixes, int off, int len)
Return namespace prefixes for element at depth
voidreadNamespacesUris(int depth, String[] uris, int off, int len)
Return namespace URIs for element at depth
bytereadNode(XmlNode node)
voidreadNodeWithoutChildren(XmlNode node)
voidreadStartTag(XmlStartTag stag)
Read value of just read START_TAG into passed as argument StartTag.
voidreset()
Reset parser state so it can be used to parse new
protected voidresetState()
voidsetAllowedMixedContent(boolean enable)
Allow for mixed element content.
voidsetBufferShrinkable(boolean shrinkable)
voidsetDocumentSource(XMLDocumentSource source)
Sets the document source
voidsetHardLimit(int value)
voidsetInput(Reader reader)
Reset parser and set new input.
voidsetInput(char[] buf)
Reset parser and set new input.
voidsetInput(char[] buf, int off, int len)
voidsetNamespaceAttributesReporting(boolean enable)
Make parser to report xmlns* attributes.
voidsetNamespaceAware(boolean awareness)
Set support of namespaces.
voidsetSoftLimit(int value)
byteskipNode()
If parser has just read start tag it allows to skip whoole subtree contined in this element.
voidstartCDATA(Augmentations augs)
voidstartDocument(XMLLocator locator, String encoding, NamespaceContext namespaceContext, Augmentations augs)
voidstartDocument(XMLLocator locator, String encoding, Augmentations augs)
voidstartElement(QName element, XMLAttributes attributes, Augmentations augs)
voidstartEntity(String name, String publicId, String systemId, String baseSystemId, String encoding, Augmentations augs)
voidstartGeneralEntity(String name, XMLResourceIdentifier identifier, String encoding, Augmentations augs)
voidstartPrefixMapping(String prefix, String uri, Augmentations augs)
voidtextDecl(String version, String encoding, Augmentations augs)
voidwarning(String domain, String key, XMLParseException ex)
Warning.
voidxmlDecl(String version, String encoding, String standalone, Augmentations augs)

Field Detail

allowedMixedContent

protected boolean allowedMixedContent

attrPos

protected X2Attribute[] attrPos
temporary array of current attributes

attrPosEnd

protected int attrPosEnd
index for last attribute in attrPos array

attrPosSize

protected int attrPosSize
size of attrPos array

attrQName

protected QName attrQName

contentBuf

protected StringBuffer contentBuf
Content of current element if in CONTENT state

contentEventEnd

protected int contentEventEnd

contentEventStart

protected int contentEventStart

cumulativeReader

protected X2PullParser.CumulativeReader cumulativeReader

disableOffsetTracking

protected boolean disableOffsetTracking

elStack

protected X2ElementContent[] elStack
temprary array to keep ElementContent stack

elStackDepth

protected int elStackDepth
how many elements are on elStack

elStackSize

protected int elStackSize
size of elStack array

emptyElement

protected boolean emptyElement
Have we read empty element?

eventEnd

protected int eventEnd
end position of current event in tokenizer biffer

eventStart

protected int eventStart
start position of current event in tokenizer biffer

fDocumentSource

protected XMLDocumentSource fDocumentSource
Document source

gotContent

protected boolean gotContent

inputSource

protected XMLInputSource inputSource

locator

protected XMLLocator locator

mixInElement

protected boolean mixInElement

needToSetInput

protected boolean needToSetInput

nextState

protected byte nextState

nonWhitespaceContent

protected boolean nonWhitespaceContent

NAMESPACES_FEATURE_ID

protected static final String NAMESPACES_FEATURE_ID

NAMESPACE_PREFIXES_FEATURE_ID

protected static final String NAMESPACE_PREFIXES_FEATURE_ID

prefix2Ns

protected Hashtable prefix2Ns
mapping of names prefixes to uris

pullParserConfiguration

protected XMLPullParserConfiguration pullParserConfiguration

POS_ABSOLUTE_END

public final String POS_ABSOLUTE_END

POS_ABSOLUTE_START

public final String POS_ABSOLUTE_START

reportNsAttribs

protected boolean reportNsAttribs
should parser report namespace xmlns* attributes ?

seenContent

protected boolean seenContent

seenCR

protected boolean seenCR

seenException

protected Exception seenException

seenRootElement

protected boolean seenRootElement
Have we seen root element

shrinkable

protected boolean shrinkable

startTagInitialized

protected boolean startTagInitialized

state

protected byte state
what is current event type as returned from next()?

supportNs

protected boolean supportNs
should parser support namespaces?

Constructor Detail

X2PullParser

public X2PullParser()
Create instance of pull parser.

Method Detail

characters

public void characters(XMLString text, Augmentations augs)

comment

public void comment(XMLString text, Augmentations augs)

doctypeDecl

public void doctypeDecl(String rootElement, String publicId, String systemId, Augmentations augs)

emptyElement

public void emptyElement(QName element, XMLAttributes attributes, Augmentations augs)

endCDATA

public void endCDATA(Augmentations augs)

endDocument

public void endDocument(Augmentations augs)

endElement

public void endElement(QName element, Augmentations augs)

endEntity

public void endEntity(String name, Augmentations augs)

endGeneralEntity

public void endGeneralEntity(String name, Augmentations augs)

endPrefixMapping

public void endPrefixMapping(String prefix, Augmentations augs)

ensureAttribs

protected void ensureAttribs(int size)
Make sure that in attributes temporary array is enough space.

ensureCapacity

protected void ensureCapacity(int size)
Make sure that we have enough space to keep element stack if passed size.

error

public void error(String domain, String key, XMLParseException ex)
Error.

fatalError

public void fatalError(String domain, String key, XMLParseException ex)
Fatal error.

getBufferShrinkOffset

public int getBufferShrinkOffset()

getColumnNumber

public int getColumnNumber()

getContentLength

public int getContentLength()

getDepth

public int getDepth()

getDocumentSource

public XMLDocumentSource getDocumentSource()
Returns the document source

getEventBuffer

public char[] getEventBuffer()

getEventEnd

public int getEventEnd()

getEventStart

public int getEventStart()

getEventType

public byte getEventType()

getHardLimit

public int getHardLimit()

getLineNumber

public int getLineNumber()

getLocalName

public String getLocalName()

getNamespacesLength

public int getNamespacesLength(int depth)

getNamespaceUri

public String getNamespaceUri()

getPosDesc

public String getPosDesc()
Return string describing current position of parser in input stream as text 'at line %d (row) and column %d (colum) [seen %s...]'.

getPrefix

public String getPrefix()

getQNameLocal

public String getQNameLocal(String qName)

getQNameUri

public String getQNameUri(String qName)

getRawName

public String getRawName()

getSoftLimit

public int getSoftLimit()

ignorableWhitespace

public void ignorableWhitespace(XMLString text, Augmentations augs)

isAllowedMixedContent

public boolean isAllowedMixedContent()

isBufferShrinkable

public boolean isBufferShrinkable()

isNamespaceAttributesReporting

public boolean isNamespaceAttributesReporting()

isNamespaceAware

public boolean isNamespaceAware()

isWhitespaceContent

public boolean isWhitespaceContent()
Return true if just read CONTENT contained only white spaces.

next

public byte next()
This is a key method - translates XNI callbacks into XPP events (such as START_TAG, END_TAG, CONTENT). or END_DOCUMENT if no more input.

processingInstruction

public void processingInstruction(String target, XMLString data, Augmentations augs)

readContent

public String readContent()
Return String that contains just read CONTENT.

readEndTag

public void readEndTag(XmlEndTag etag)
Read value of just read END_TAG into passed as argument EndTag.

readNamespacesPrefixes

public void readNamespacesPrefixes(int depth, String[] prefixes, int off, int len)
Return namespace prefixes for element at depth

readNamespacesUris

public void readNamespacesUris(int depth, String[] uris, int off, int len)
Return namespace URIs for element at depth

readNode

public byte readNode(XmlNode node)

readNodeWithoutChildren

public void readNodeWithoutChildren(XmlNode node)

readStartTag

public void readStartTag(XmlStartTag stag)
Read value of just read START_TAG into passed as argument StartTag.

reset

public void reset()
Reset parser state so it can be used to parse new

resetState

protected void resetState()

setAllowedMixedContent

public void setAllowedMixedContent(boolean enable)
Allow for mixed element content. Enabled by default. When disbaled element must containt either text or other elements.

setBufferShrinkable

public void setBufferShrinkable(boolean shrinkable)

setDocumentSource

public void setDocumentSource(XMLDocumentSource source)
Sets the document source

setHardLimit

public void setHardLimit(int value)

setInput

public void setInput(Reader reader)
Reset parser and set new input.

setInput

public void setInput(char[] buf)
Reset parser and set new input.

setInput

public void setInput(char[] buf, int off, int len)

setNamespaceAttributesReporting

public void setNamespaceAttributesReporting(boolean enable)
Make parser to report xmlns* attributes. Disabled by default. Only meaningful when namespaces are enabled (when namespaces are disabled all attributes are always reported).

setNamespaceAware

public void setNamespaceAware(boolean awareness)
Set support of namespaces. Disabled by default.

setSoftLimit

public void setSoftLimit(int value)

skipNode

public byte skipNode()
If parser has just read start tag it allows to skip whoole subtree contined in this element. Returns when encounters end tag matching the start tag.

startCDATA

public void startCDATA(Augmentations augs)

startDocument

public void startDocument(XMLLocator locator, String encoding, NamespaceContext namespaceContext, Augmentations augs)

startDocument

public void startDocument(XMLLocator locator, String encoding, Augmentations augs)

startElement

public void startElement(QName element, XMLAttributes attributes, Augmentations augs)

startEntity

public void startEntity(String name, String publicId, String systemId, String baseSystemId, String encoding, Augmentations augs)

startGeneralEntity

public void startGeneralEntity(String name, XMLResourceIdentifier identifier, String encoding, Augmentations augs)

startPrefixMapping

public void startPrefixMapping(String prefix, String uri, Augmentations augs)

textDecl

public void textDecl(String version, String encoding, Augmentations augs)

warning

public void warning(String domain, String key, XMLParseException ex)
Warning.

xmlDecl

public void xmlDecl(String version, String encoding, String standalone, Augmentations augs)
Copyright (c) 2003 IU Extreme! Lab http://www.extreme.indiana.edu/ All Rights Reserved.

Note this package is deprecated by XPP3 that implements XmlPull API