org.xmlpull.v1.wrapper
Interface XmlPullParserWrapper

All Superinterfaces:
XmlPullParser
All Known Implementing Classes:
StaticXmlPullParserWrapper

public interface XmlPullParserWrapper
extends XmlPullParser

Extensions to XmlPullParser interface


Field Summary
static java.lang.String XSD_NS
           
static java.lang.String XSI_NS
           
 
Fields inherited from interface org.xmlpull.v1.XmlPullParser
CDSECT, COMMENT, DOCDECL, END_DOCUMENT, END_TAG, ENTITY_REF, FEATURE_PROCESS_DOCDECL, FEATURE_PROCESS_NAMESPACES, FEATURE_REPORT_NAMESPACE_ATTRIBUTES, FEATURE_VALIDATION, IGNORABLE_WHITESPACE, NO_NAMESPACE, PROCESSING_INSTRUCTION, START_DOCUMENT, START_TAG, TEXT, TYPES
 
Method Summary
 java.lang.String getAttributeValue(java.lang.String name)
          Return value of attribute with given name and no namespace.
 java.lang.String getPIData()
          Return everything past PITarget and S from Processing Instruction (PI) as defined in XML 1.0 Section 2.6 Processing Instructions [16] PI ::= '<?'
 java.lang.String getPITarget()
          Return PITarget from Processing Instruction (PI) as defined in XML 1.0 Section 2.6 Processing Instructions [16] PI ::= '<?'
 java.lang.String getRequiredAttributeValue(java.lang.String name)
          Read attribute value and return it or throw exception if current element does not have such attribute.
 java.lang.String getRequiredAttributeValue(java.lang.String namespace, java.lang.String name)
          Read attribute value and return it or throw exception if current element does not have such attribute.
 java.lang.String getRequiredElementText(java.lang.String namespace, java.lang.String name)
          Read the text of a required element and return it or throw exception if required element is not found.
 boolean isNil()
          Is the current tag nil?
 boolean matches(int type, java.lang.String namespace, java.lang.String name)
          Tests if the current event is of the given type and if the namespace and name match.
 void nextEndTag()
          Call parser nextTag() and check that it is END_TAG, throw exception if not.
 void nextEndTag(java.lang.String name)
          combine nextTag(); pp.require(XmlPullParser.END_TAG, null, name);
 void nextEndTag(java.lang.String namespace, java.lang.String name)
          combine nextTag(); pp.require(XmlPullParser.END_TAG, namespace, name);
 void nextStartTag()
          call parser nextTag() and check that it is START_TAG, throw exception if not.
 void nextStartTag(java.lang.String name)
          combine nextTag(); pp.require(XmlPullParser.START_TAG, null, name);
 void nextStartTag(java.lang.String namespace, java.lang.String name)
          combine nextTag(); pp.require(XmlPullParser.START_TAG, namespace, name);
 java.lang.String nextText(java.lang.String namespace, java.lang.String name)
          Read text content of element ith given namespace and name (use null namespace do indicate that nemspace should not be checked)
 void skipSubTree()
          Skip sub tree that is currently porser positioned on.
 
Methods inherited from interface org.xmlpull.v1.XmlPullParser
defineEntityReplacementText, getAttributeCount, getAttributeName, getAttributeNamespace, getAttributePrefix, getAttributeType, getAttributeValue, getAttributeValue, getColumnNumber, getDepth, getEventType, getFeature, getInputEncoding, getLineNumber, getName, getNamespace, getNamespace, getNamespaceCount, getNamespacePrefix, getNamespaceUri, getPositionDescription, getPrefix, getProperty, getText, getTextCharacters, isAttributeDefault, isEmptyElementTag, isWhitespace, next, nextTag, nextText, nextToken, require, setFeature, setInput, setInput, setProperty
 

Field Detail

XSI_NS

static final java.lang.String XSI_NS
See Also:
Constant Field Values

XSD_NS

static final java.lang.String XSD_NS
See Also:
Constant Field Values
Method Detail

getAttributeValue

java.lang.String getAttributeValue(java.lang.String name)
Return value of attribute with given name and no namespace.


getPITarget

java.lang.String getPITarget()
                             throws java.lang.IllegalStateException
Return PITarget from Processing Instruction (PI) as defined in XML 1.0 Section 2.6 Processing Instructions [16] PI ::= '<?' PITarget (S (Char* - (Char* '?>' Char*)))? '?>'

Throws:
java.lang.IllegalStateException

getPIData

java.lang.String getPIData()
                           throws java.lang.IllegalStateException
Return everything past PITarget and S from Processing Instruction (PI) as defined in XML 1.0 Section 2.6 Processing Instructions [16] PI ::= '<?' PITarget (S (Char* - (Char* '?>' Char*)))? '?>'

NOTE: if there is no PI data it returns empty string.

Throws:
java.lang.IllegalStateException

getRequiredAttributeValue

java.lang.String getRequiredAttributeValue(java.lang.String name)
                                           throws java.io.IOException,
                                                  XmlPullParserException
Read attribute value and return it or throw exception if current element does not have such attribute.

Throws:
java.io.IOException
XmlPullParserException

getRequiredAttributeValue

java.lang.String getRequiredAttributeValue(java.lang.String namespace,
                                           java.lang.String name)
                                           throws java.io.IOException,
                                                  XmlPullParserException
Read attribute value and return it or throw exception if current element does not have such attribute.

Throws:
java.io.IOException
XmlPullParserException

getRequiredElementText

java.lang.String getRequiredElementText(java.lang.String namespace,
                                        java.lang.String name)
                                        throws java.io.IOException,
                                               XmlPullParserException
Read the text of a required element and return it or throw exception if required element is not found. Useful for getting the text of simple elements such as johndoe. Assumes that parser is just before the start tag and leaves the parser at the end tag. If the text is nil (e.g. ), then a null will be returned.

Throws:
java.io.IOException
XmlPullParserException

isNil

boolean isNil()
              throws java.io.IOException,
                     XmlPullParserException
Is the current tag nil? Checks for xsi:nil="true".

Throws:
java.io.IOException
XmlPullParserException

matches

boolean matches(int type,
                java.lang.String namespace,
                java.lang.String name)
                throws XmlPullParserException
Tests if the current event is of the given type and if the namespace and name match. null will match any namespace and any name. If the test passes a true is returned otherwise a false is returned.

Throws:
XmlPullParserException

nextStartTag

void nextStartTag()
                  throws XmlPullParserException,
                         java.io.IOException
call parser nextTag() and check that it is START_TAG, throw exception if not.

Throws:
XmlPullParserException
java.io.IOException

nextStartTag

void nextStartTag(java.lang.String name)
                  throws XmlPullParserException,
                         java.io.IOException
combine nextTag(); pp.require(XmlPullParser.START_TAG, null, name);

Throws:
XmlPullParserException
java.io.IOException

nextStartTag

void nextStartTag(java.lang.String namespace,
                  java.lang.String name)
                  throws XmlPullParserException,
                         java.io.IOException
combine nextTag(); pp.require(XmlPullParser.START_TAG, namespace, name);

Throws:
XmlPullParserException
java.io.IOException

nextEndTag

void nextEndTag()
                throws XmlPullParserException,
                       java.io.IOException
Call parser nextTag() and check that it is END_TAG, throw exception if not.

Throws:
XmlPullParserException
java.io.IOException

nextEndTag

void nextEndTag(java.lang.String name)
                throws XmlPullParserException,
                       java.io.IOException
combine nextTag(); pp.require(XmlPullParser.END_TAG, null, name);

Throws:
XmlPullParserException
java.io.IOException

nextEndTag

void nextEndTag(java.lang.String namespace,
                java.lang.String name)
                throws XmlPullParserException,
                       java.io.IOException
combine nextTag(); pp.require(XmlPullParser.END_TAG, namespace, name);

Throws:
XmlPullParserException
java.io.IOException

nextText

java.lang.String nextText(java.lang.String namespace,
                          java.lang.String name)
                          throws java.io.IOException,
                                 XmlPullParserException
Read text content of element ith given namespace and name (use null namespace do indicate that nemspace should not be checked)

Throws:
java.io.IOException
XmlPullParserException

skipSubTree

void skipSubTree()
                 throws XmlPullParserException,
                        java.io.IOException
Skip sub tree that is currently porser positioned on.
NOTE: parser must be on START_TAG and when funtion returns parser will be positioned on matching END_TAG This is typically optimized internally by parser but the logic should follow this: pp.require(XmlPullParser.START_TAG, null, null); int level = 1; while(level > 0) { int eventType = pp.next(); if(eventType == XmlPullParser.END_TAG) { --level; } else if(eventType == XmlPullParser.START_TAG) { ++level; } }

Throws:
XmlPullParserException
java.io.IOException