XmlPullParser
public class MXParser extends Object implements XmlPullParser
Modifier and Type | Field | Description |
---|---|---|
protected boolean |
allStringsInterned |
Implementation notice:
the is instance variable that controls if newString() is interning.
|
protected int |
attributeCount |
|
protected String[] |
attributeName |
|
protected int[] |
attributeNameHash |
|
protected String[] |
attributePrefix |
|
protected String[] |
attributeUri |
|
protected String[] |
attributeValue |
|
protected char[] |
buf |
|
protected int |
bufAbsoluteStart |
|
protected int |
bufEnd |
|
protected int |
bufLoadFactor |
|
protected int |
bufSoftLimit |
|
protected int |
bufStart |
|
protected char[] |
charRefOneCharBuf |
|
protected int |
columnNumber |
|
protected int |
depth |
|
protected String[] |
elName |
|
protected int[] |
elNamespaceCount |
|
protected String[] |
elPrefix |
|
protected char[][] |
elRawName |
|
protected int[] |
elRawNameEnd |
|
protected int[] |
elRawNameLine |
|
protected String[] |
elUri |
|
protected boolean |
emptyElementTag |
|
protected int |
entityEnd |
|
protected String[] |
entityName |
|
protected char[][] |
entityNameBuf |
|
protected int[] |
entityNameHash |
|
protected String |
entityRefName |
|
protected String[] |
entityReplacement |
|
protected char[][] |
entityReplacementBuf |
|
protected int |
eventType |
|
protected static String |
FEATURE_NAMES_INTERNED |
|
protected static String |
FEATURE_XML_ROUNDTRIP |
|
protected String |
inputEncoding |
|
protected InputStream |
inputStream |
|
protected int |
lineNumber |
|
protected String |
location |
|
protected static int |
LOOKUP_MAX |
|
protected static char |
LOOKUP_MAX_CHAR |
|
protected static boolean[] |
lookupNameChar |
|
protected static boolean[] |
lookupNameStartChar |
|
protected int |
namespaceEnd |
|
protected String[] |
namespacePrefix |
|
protected int[] |
namespacePrefixHash |
|
protected String[] |
namespaceUri |
|
protected static char[] |
NCODING |
|
protected static char[] |
NO |
|
protected boolean |
pastEndTag |
|
protected char[] |
pc |
|
protected int |
pcEnd |
|
protected int |
pcStart |
|
protected int |
pos |
|
protected int |
posEnd |
|
protected int |
posStart |
|
protected boolean |
preventBufferCompaction |
|
protected boolean |
processNamespaces |
|
protected static String |
PROPERTY_LOCATION |
|
protected static String |
PROPERTY_XMLDECL_CONTENT |
|
protected static String |
PROPERTY_XMLDECL_STANDALONE |
|
protected static String |
PROPERTY_XMLDECL_VERSION |
|
protected boolean |
reachedEnd |
|
protected static int |
READ_CHUNK_SIZE |
|
protected Reader |
reader |
|
protected boolean |
roundtripSupported |
|
protected boolean |
seenAmpersand |
|
protected boolean |
seenDocdecl |
|
protected boolean |
seenEndTag |
|
protected boolean |
seenMarkup |
|
protected boolean |
seenRoot |
|
protected boolean |
seenStartTag |
|
protected static char[] |
TANDALONE |
|
protected String |
text |
|
protected boolean |
tokenize |
|
protected boolean |
usePC |
|
protected static char[] |
VERSION |
|
protected static String |
XML_URI |
|
protected String |
xmlDeclContent |
|
protected Boolean |
xmlDeclStandalone |
|
protected String |
xmlDeclVersion |
|
protected static String |
XMLNS_URI |
|
protected static char[] |
YES |
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
Constructor | Description |
---|---|
MXParser() |
Modifier and Type | Method | Description |
---|---|---|
void |
defineEntityReplacementText(String entityName,
String replacementText) |
Set new value for entity replacement text as defined in
XML 1.0 Section 4.5
Construction of Internal Entity Replacement Text.
|
protected void |
ensureAttributesCapacity(int size) |
Make sure that in attributes temporary array is enough space.
|
protected void |
ensureElementsCapacity() |
Make sure that we have enough space to keep element stack if passed size.
|
protected void |
ensureEntityCapacity() |
|
protected void |
ensureNamespacesCapacity(int size) |
|
protected void |
ensurePC(int end) |
|
protected static int |
fastHash(char[] ch,
int off,
int len) |
simplistic implementation of hash function that has constant
time to compute - so it also means diminishing hash quality for long strings
but for XML parsing it should be good enough ...
|
protected void |
fillBuf() |
|
int |
getAttributeCount() |
Returns the number of attributes of the current start tag, or
-1 if the current event type is not START_TAG
|
String |
getAttributeName(int index) |
Returns the local name of the specified attribute
if namespaces are enabled or just attribute name if namespaces are disabled.
|
String |
getAttributeNamespace(int index) |
Returns the namespace URI of the attribute
with the given index (starts from 0).
|
String |
getAttributePrefix(int index) |
Returns the prefix of the specified attribute
Returns null if the element has no prefix.
|
String |
getAttributeType(int index) |
Returns the type of the specified attribute
If parser is non-validating it MUST return CDATA.
|
String |
getAttributeValue(int index) |
Returns the given attributes value.
|
String |
getAttributeValue(String namespace,
String name) |
Returns the attributes value identified by namespace URI and namespace localName.
|
int |
getColumnNumber() |
Returns the current column number, starting from 0.
|
int |
getDepth() |
Returns the current depth of the element.
|
int |
getEventType() |
Returns the type of the current event (START_TAG, END_TAG, TEXT, etc.)
|
boolean |
getFeature(String name) |
Unknown properties are always returned as false
|
String |
getInputEncoding() |
Returns the input encoding if known, null otherwise.
|
int |
getLineNumber() |
Returns the current line number, starting from 1.
|
String |
getName() |
For START_TAG or END_TAG events, the (local) name of the current
element is returned when namespaces are enabled.
|
String |
getNamespace() |
Returns the namespace URI of the current element.
|
String |
getNamespace(String prefix) |
Returns the URI corresponding to the given prefix,
depending on current state of the parser.
|
int |
getNamespaceCount(int depth) |
Returns the numbers of elements in the namespace stack for the given
depth.
|
String |
getNamespacePrefix(int pos) |
Returns the namespace prefixe for the given position
in the namespace stack.
|
String |
getNamespaceUri(int pos) |
Returns the namespace URI for the given position in the
namespace stack
If the position is out of range, an exception is thrown.
|
String |
getPositionDescription() |
Return string describing current position of parsers as
text 'STATE [seen %s...] @line:column'.
|
String |
getPrefix() |
Returns the prefix of the current element.
|
Object |
getProperty(String name) |
Look up the value of a property.
|
String |
getText() |
Returns the text content of the current event as String.
|
char[] |
getTextCharacters(int[] holderForStartAndLength) |
Returns the buffer that contains the text of the current event,
as well as the start offset and length relevant for the current
event.
|
boolean |
isAttributeDefault(int index) |
Returns if the specified attribute was not in input was declared in XML.
|
boolean |
isEmptyElementTag() |
Returns true if the current event is START_TAG and the tag
is degenerated
(e.g.
|
protected boolean |
isNameChar(char ch) |
|
protected boolean |
isNameStartChar(char ch) |
|
protected boolean |
isS(char ch) |
|
boolean |
isWhitespace() |
Checks whether the current TEXT event contains only whitespace
characters.
|
protected void |
joinPC() |
|
protected char[] |
lookuEntityReplacement(int entitNameLen) |
|
protected char |
more() |
|
protected String |
newString(char[] cbuf,
int off,
int len) |
|
protected String |
newStringIntern(char[] cbuf,
int off,
int len) |
|
int |
next() |
Get next parsing event - element content wil be coalesced and only one
TEXT event must be returned for whole element content
(comments and processing instructions will be ignored and emtity references
must be expanded or exception mus be thrown if entity reerence can not be exapnded).
|
protected int |
nextImpl() |
|
int |
nextTag() |
Call next() and return event if it is START_TAG or END_TAG
otherwise throw an exception.
|
String |
nextText() |
If current event is START_TAG then if next element is TEXT then element content is returned
or if next event is END_TAG then empty string is returned, otherwise exception is thrown.
|
int |
nextToken() |
This method works similarly to next() but will expose
additional event types (COMMENT, CDSECT, DOCDECL, ENTITY_REF, PROCESSING_INSTRUCTION, or
IGNORABLE_WHITESPACE) if they are available in input.
|
protected char |
parseAttribute() |
|
protected void |
parseCDSect(boolean hadCharData) |
|
protected void |
parseComment() |
|
protected void |
parseDocdecl() |
|
int |
parseEndTag() |
|
protected char[] |
parseEntityRef() |
|
protected int |
parseEpilog() |
|
protected boolean |
parsePI() |
|
protected int |
parseProlog() |
|
int |
parseStartTag() |
|
protected void |
parseXmlDecl(char ch) |
|
protected void |
parseXmlDeclWithVersion(int versionStart,
int versionEnd) |
|
protected String |
printable(char ch) |
|
protected String |
printable(String s) |
|
void |
require(int type,
String namespace,
String name) |
Test if the current event is of the given type and if the
namespace and name do match.
|
protected char |
requireInput(char ch,
char[] input) |
|
protected char |
requireNextS() |
|
protected void |
reset() |
|
protected void |
resetStringCache() |
|
void |
setFeature(String name,
boolean state) |
Method setFeature
|
void |
setInput(InputStream inputStream,
String inputEncoding) |
Sets the input stream the parser is going to process.
|
void |
setInput(Reader in) |
Set the input source for parser to the given reader and
resets the parser.
|
void |
setProperty(String name,
Object value) |
Set the value of a property.
|
protected char |
skipS(char ch) |
|
void |
skipSubTree() |
Skip sub tree that is currently parser positioned on.
|
protected static final String XML_URI
protected static final String XMLNS_URI
protected static final String FEATURE_XML_ROUNDTRIP
protected static final String FEATURE_NAMES_INTERNED
protected static final String PROPERTY_XMLDECL_VERSION
protected static final String PROPERTY_XMLDECL_STANDALONE
protected static final String PROPERTY_XMLDECL_CONTENT
protected static final String PROPERTY_LOCATION
protected boolean allStringsInterned
NOTE: newStringIntern always returns interned strings and newString MAY return interned String depending on this variable.
NOTE: by default in this minimal implementation it is false!
protected boolean processNamespaces
protected boolean roundtripSupported
protected String location
protected int lineNumber
protected int columnNumber
protected boolean seenRoot
protected boolean reachedEnd
protected int eventType
protected boolean emptyElementTag
protected int depth
protected char[][] elRawName
protected int[] elRawNameEnd
protected int[] elRawNameLine
protected String[] elName
protected String[] elPrefix
protected String[] elUri
protected int[] elNamespaceCount
protected int attributeCount
protected String[] attributeName
protected int[] attributeNameHash
protected String[] attributePrefix
protected String[] attributeUri
protected String[] attributeValue
protected int namespaceEnd
protected String[] namespacePrefix
protected int[] namespacePrefixHash
protected String[] namespaceUri
protected int entityEnd
protected String[] entityName
protected char[][] entityNameBuf
protected String[] entityReplacement
protected char[][] entityReplacementBuf
protected int[] entityNameHash
protected static final int READ_CHUNK_SIZE
protected Reader reader
protected String inputEncoding
protected InputStream inputStream
protected int bufLoadFactor
protected char[] buf
protected int bufSoftLimit
protected boolean preventBufferCompaction
protected int bufAbsoluteStart
protected int bufStart
protected int bufEnd
protected int pos
protected int posStart
protected int posEnd
protected char[] pc
protected int pcStart
protected int pcEnd
protected boolean usePC
protected boolean seenStartTag
protected boolean seenEndTag
protected boolean pastEndTag
protected boolean seenAmpersand
protected boolean seenMarkup
protected boolean seenDocdecl
protected boolean tokenize
protected String text
protected String entityRefName
protected String xmlDeclVersion
protected Boolean xmlDeclStandalone
protected String xmlDeclContent
protected char[] charRefOneCharBuf
protected static final char[] VERSION
protected static final char[] NCODING
protected static final char[] TANDALONE
protected static final char[] YES
protected static final char[] NO
protected static final int LOOKUP_MAX
protected static final char LOOKUP_MAX_CHAR
protected static boolean[] lookupNameStartChar
protected static boolean[] lookupNameChar
protected void resetStringCache()
protected String newString(char[] cbuf, int off, int len)
protected String newStringIntern(char[] cbuf, int off, int len)
protected void ensureElementsCapacity()
protected void ensureAttributesCapacity(int size)
protected void ensureNamespacesCapacity(int size)
protected static final int fastHash(char[] ch, int off, int len)
protected void ensureEntityCapacity()
protected void reset()
public void setFeature(String name, boolean state) throws XmlPullParserException
setFeature
in interface XmlPullParser
name
- a Stringstate
- a booleanXmlPullParserException
public boolean getFeature(String name)
getFeature
in interface XmlPullParser
name
- The name of feature to be retrieved.public void setProperty(String name, Object value) throws XmlPullParserException
XmlPullParser
setProperty
in interface XmlPullParser
XmlPullParserException
- If the property is not supported or can not be setpublic Object getProperty(String name)
XmlPullParser
NOTE: unknown properties are always returned as null.
getProperty
in interface XmlPullParser
name
- The name of property to be retrieved.public void setInput(Reader in) throws XmlPullParserException
XmlPullParser
setInput
in interface XmlPullParser
XmlPullParserException
public void setInput(InputStream inputStream, String inputEncoding) throws XmlPullParserException
XmlPullParser
NOTE: If an input encoding string is passed, it MUST be used. Otherwise, if inputEncoding is null, the parser SHOULD try to determine input encoding following XML 1.0 specification (see below). If encoding detection is supported then following feature http://xmlpull.org/v1/doc/features.html#detect-encoding MUST be true amd otherwise it must be false
setInput
in interface XmlPullParser
inputStream
- contains a raw byte input stream of possibly
unknown encoding (when inputEncoding is null).inputEncoding
- if not null it MUST be used as encoding for inputStreamXmlPullParserException
public String getInputEncoding()
XmlPullParser
getInputEncoding
in interface XmlPullParser
public void defineEntityReplacementText(String entityName, String replacementText) throws XmlPullParserException
XmlPullParser
The motivation for this function is to allow very small implementations of XMLPULL that will work in J2ME environments. Though these implementations may not be able to process the document type declaration, they still can work with known DTDs by using this function.
Please notes: The given value is used literally as replacement text and it corresponds to declaring entity in DTD that has all special characters escaped: left angle bracket is replaced with <, ampersnad with & and so on.
Note: The given value is the literal replacement text and must not contain any other entity reference (if it contains any entity reference there will be no further replacement).
Note: The list of pre-defined entity names will always contain standard XML entities such as amp (&), lt (<), gt (>), quot ("), and apos ('). Those cannot be redefined by this method!
defineEntityReplacementText
in interface XmlPullParser
XmlPullParserException
XmlPullParser.setInput(java.io.Reader)
,
XmlPullParser.FEATURE_PROCESS_DOCDECL
,
XmlPullParser.FEATURE_VALIDATION
public int getNamespaceCount(int depth) throws XmlPullParserException
XmlPullParser
NOTE: when parser is on END_TAG then it is allowed to call this function with getDepth()+1 argument to retrieve position of namespace prefixes and URIs that were declared on corresponding START_TAG.
NOTE: to retrieve lsit of namespaces declared in current element:
XmlPullParser pp = ... int nsStart = pp.getNamespaceCount(pp.getDepth()-1); int nsEnd = pp.getNamespaceCount(pp.getDepth()); for (int i = nsStart; i < nsEnd; i++) { String prefix = pp.getNamespacePrefix(i); String ns = pp.getNamespaceUri(i); // ... }
getNamespaceCount
in interface XmlPullParser
XmlPullParserException
XmlPullParser.getNamespacePrefix(int)
,
XmlPullParser.getNamespaceUri(int)
,
XmlPullParser.getNamespace()
,
XmlPullParser.getNamespace(String)
public String getNamespacePrefix(int pos) throws XmlPullParserException
XmlPullParser
Please note: when the parser is on an END_TAG, namespace prefixes that were declared in the corresponding START_TAG are still accessible although they are no longer in scope.
getNamespacePrefix
in interface XmlPullParser
XmlPullParserException
public String getNamespaceUri(int pos) throws XmlPullParserException
XmlPullParser
NOTE: when parser is on END_TAG then namespace prefixes that were declared in corresponding START_TAG are still accessible even though they are not in scope
getNamespaceUri
in interface XmlPullParser
XmlPullParserException
public String getNamespace(String prefix)
XmlPullParser
If the prefix was not declared in the current scope, null is returned. The default namespace is included in the namespace table and is available via getNamespace (null).
This method is a convenience method for
for (int i = getNamespaceCount(getDepth ())-1; i >= 0; i--) { if (getNamespacePrefix(i).equals( prefix )) { return getNamespaceUri(i); } } return null;
Please note: parser implementations may provide more efifcient lookup, e.g. using a Hashtable. The 'xml' prefix is bound to "http://www.w3.org/XML/1998/namespace", as defined in the Namespaces in XML specification. Analogous, the 'xmlns' prefix is resolved to http://www.w3.org/2000/xmlns/
getNamespace
in interface XmlPullParser
XmlPullParser.getNamespaceCount(int)
,
XmlPullParser.getNamespacePrefix(int)
,
XmlPullParser.getNamespaceUri(int)
public int getDepth()
XmlPullParser
<!-- outside --> 0 <root> 1 sometext 1 <foobar> 2 </foobar> 2 </root> 1 <!-- outside --> 0
getDepth
in interface XmlPullParser
public String getPositionDescription()
getPositionDescription
in interface XmlPullParser
public int getLineNumber()
XmlPullParser
getLineNumber
in interface XmlPullParser
public int getColumnNumber()
XmlPullParser
getColumnNumber
in interface XmlPullParser
public boolean isWhitespace() throws XmlPullParserException
XmlPullParser
Please note: non-validating parsers are not able to distinguish whitespace and ignorable whitespace, except from whitespace outside the root element. Ignorable whitespace is reported as separate event, which is exposed via nextToken only.
isWhitespace
in interface XmlPullParser
XmlPullParserException
public String getText()
XmlPullParser
NOTE: in case of ENTITY_REF, this method returns the entity replacement text (or null if not available). This is the only case where getText() and getTextCharacters() return different values.
getText
in interface XmlPullParser
XmlPullParser.getEventType()
,
XmlPullParser.next()
,
XmlPullParser.nextToken()
public char[] getTextCharacters(int[] holderForStartAndLength)
XmlPullParser
Please note: this buffer must not be modified and its content MAY change after a call to next() or nextToken(). This method will always return the same value as getText(), except for ENTITY_REF. In the case of ENTITY ref, getText() returns the replacement text and this method returns the actual input buffer containing the entity name. If getText() returns null, this method returns null as well and the values returned in the holder array MUST be -1 (both start and length).
getTextCharacters
in interface XmlPullParser
holderForStartAndLength
- Must hold an 2-element int array
into which the start offset and length values will be written.XmlPullParser.getText()
,
XmlPullParser.next()
,
XmlPullParser.nextToken()
public String getNamespace()
XmlPullParser
getNamespace
in interface XmlPullParser
public String getName()
XmlPullParser
Please note: To reconstruct the raw element name when namespaces are enabled and the prefix is not null, you will need to add the prefix and a colon to localName..
getName
in interface XmlPullParser
public String getPrefix()
XmlPullParser
getPrefix
in interface XmlPullParser
public boolean isEmptyElementTag() throws XmlPullParserException
XmlPullParser
NOTE: if the parser is not on START_TAG, an exception will be thrown.
isEmptyElementTag
in interface XmlPullParser
XmlPullParserException
public int getAttributeCount()
XmlPullParser
getAttributeCount
in interface XmlPullParser
XmlPullParser.getAttributeNamespace(int)
,
XmlPullParser.getAttributeName(int)
,
XmlPullParser.getAttributePrefix(int)
,
XmlPullParser.getAttributeValue(int)
public String getAttributeNamespace(int index)
XmlPullParser
NOTE: if FEATURE_REPORT_NAMESPACE_ATTRIBUTES is set then namespace attributes (xmlns:ns='...') must be reported with namespace http://www.w3.org/2000/xmlns/ (visit this URL for description!). The default namespace attribute (xmlns="...") will be reported with empty namespace.
NOTE:The xml prefix is bound as defined in Namespaces in XML specification to "http://www.w3.org/XML/1998/namespace".
getAttributeNamespace
in interface XmlPullParser
index
- zero based index of attributepublic String getAttributeName(int index)
XmlPullParser
getAttributeName
in interface XmlPullParser
index
- zero based index of attributepublic String getAttributePrefix(int index)
XmlPullParser
getAttributePrefix
in interface XmlPullParser
index
- zero based index of attributepublic String getAttributeType(int index)
XmlPullParser
getAttributeType
in interface XmlPullParser
index
- zero based index of attributepublic boolean isAttributeDefault(int index)
XmlPullParser
isAttributeDefault
in interface XmlPullParser
index
- zero based index of attributepublic String getAttributeValue(int index)
XmlPullParser
NOTE: attribute value must be normalized (including entity replacement text if PROCESS_DOCDECL is false) as described in XML 1.0 section 3.3.3 Attribute-Value Normalization
getAttributeValue
in interface XmlPullParser
index
- zero based index of attributeXmlPullParser.defineEntityReplacementText(java.lang.String, java.lang.String)
public String getAttributeValue(String namespace, String name)
XmlPullParser
NOTE: attribute value must be normalized (including entity replacement text if PROCESS_DOCDECL is false) as described in XML 1.0 section 3.3.3 Attribute-Value Normalization
getAttributeValue
in interface XmlPullParser
namespace
- Namespace of the attribute if namespaces are enabled otherwise must be nullname
- If namespaces enabled local name of attribute otherwise just attribute nameXmlPullParser.defineEntityReplacementText(java.lang.String, java.lang.String)
public int getEventType()
XmlPullParser
getEventType
in interface XmlPullParser
XmlPullParser.next()
,
XmlPullParser.nextToken()
public void require(int type, String namespace, String name) throws XmlPullParserException, IOException
XmlPullParser
Essentially it does this
if (type != getEventType() || (namespace != null && !namespace.equals( getNamespace () ) ) || (name != null && !name.equals( getName() ) ) ) throw new XmlPullParserException( "expected "+ TYPES[ type ]+getPositionDescription());
require
in interface XmlPullParser
XmlPullParserException
IOException
public void skipSubTree() throws XmlPullParserException, IOException
XmlPullParserException
IOException
public String nextText() throws XmlPullParserException, IOException
XmlPullParser
The motivation for this function is to allow to parse consistently both empty elements and elements that has non empty content, for example for input:
p.nextTag() p.requireEvent(p.START_TAG, "", "tag"); String content = p.nextText(); p.requireEvent(p.END_TAG, "", "tag");This function together with nextTag make it very easy to parse XML that has no mixed content.
Essentially it does this
if(getEventType() != START_TAG) { throw new XmlPullParserException( "parser must be on START_TAG to read next text", this, null); } int eventType = next(); if(eventType == TEXT) { String result = getText(); eventType = next(); if(eventType != END_TAG) { throw new XmlPullParserException( "event TEXT it must be immediately followed by END_TAG", this, null); } return result; } else if(eventType == END_TAG) { return ""; } else { throw new XmlPullParserException( "parser must be on START_TAG or TEXT to read text", this, null); }
nextText
in interface XmlPullParser
XmlPullParserException
IOException
public int nextTag() throws XmlPullParserException, IOException
XmlPullParser
essentially it does this
int eventType = next(); if(eventType == TEXT && isWhitespace()) { // skip whitespace eventType = next(); } if (eventType != START_TAG && eventType != END_TAG) { throw new XmlPullParserException("expected start or end tag", this, null); } return eventType;
nextTag
in interface XmlPullParser
XmlPullParserException
IOException
public int next() throws XmlPullParserException, IOException
XmlPullParser
NOTE: empty element (such as <tag/>) will be reported with two separate events: START_TAG, END_TAG - it must be so to preserve parsing equivalency of empty element to <tag></tag>. (see isEmptyElementTag ())
next
in interface XmlPullParser
XmlPullParserException
IOException
XmlPullParser.isEmptyElementTag()
,
XmlPullParser.START_TAG
,
XmlPullParser.TEXT
,
XmlPullParser.END_TAG
,
XmlPullParser.END_DOCUMENT
public int nextToken() throws XmlPullParserException, IOException
XmlPullParser
If special feature FEATURE_XML_ROUNDTRIP (identified by URI: http://xmlpull.org/v1/doc/features.html#xml-roundtrip) is enabled it is possible to do XML document round trip ie. reproduce exectly on output the XML input using getText(): returned content is always unnormalized (exactly as in input). Otherwise returned content is end-of-line normalized as described XML 1.0 End-of-Line Handling and. Also when this feature is enabled exact content of START_TAG, END_TAG, DOCDECL and PROCESSING_INSTRUCTION is available.
Here is the list of tokens that can be returned from nextToken() and what getText() and getTextCharacters() returns:
" titlepage SYSTEM "http://www.foo.bar/dtds/typo.dtd" [<!ENTITY % active.links "INCLUDE">]"
for input document that contained:
<!DOCTYPE titlepage SYSTEM "http://www.foo.bar/dtds/typo.dtd" [<!ENTITY % active.links "INCLUDE">]>otherwise if FEATURE_XML_ROUNDTRIP is false and PROCESS_DOCDECL is true then what is returned is undefined (it may be even null)
NOTE: there is no gurantee that there will only one TEXT or IGNORABLE_WHITESPACE event from nextToken() as parser may chose to deliver element content in multiple tokens (dividing element content into chunks)
NOTE: whether returned text of token is end-of-line normalized is depending on FEATURE_XML_ROUNDTRIP.
NOTE: XMLDecl (<?xml ...?>) is not reported but its content is available through optional properties (see class description above).
nextToken
in interface XmlPullParser
XmlPullParserException
IOException
XmlPullParser.next()
,
XmlPullParser.START_TAG
,
XmlPullParser.TEXT
,
XmlPullParser.END_TAG
,
XmlPullParser.END_DOCUMENT
,
XmlPullParser.COMMENT
,
XmlPullParser.DOCDECL
,
XmlPullParser.PROCESSING_INSTRUCTION
,
XmlPullParser.ENTITY_REF
,
XmlPullParser.IGNORABLE_WHITESPACE
protected int nextImpl() throws XmlPullParserException, IOException
XmlPullParserException
IOException
protected int parseProlog() throws XmlPullParserException, IOException
XmlPullParserException
IOException
protected int parseEpilog() throws XmlPullParserException, IOException
XmlPullParserException
IOException
public int parseEndTag() throws XmlPullParserException, IOException
XmlPullParserException
IOException
public int parseStartTag() throws XmlPullParserException, IOException
XmlPullParserException
IOException
protected char parseAttribute() throws XmlPullParserException, IOException
XmlPullParserException
IOException
protected char[] parseEntityRef() throws XmlPullParserException, IOException
XmlPullParserException
IOException
protected char[] lookuEntityReplacement(int entitNameLen) throws XmlPullParserException, IOException
XmlPullParserException
IOException
protected void parseComment() throws XmlPullParserException, IOException
XmlPullParserException
IOException
protected boolean parsePI() throws XmlPullParserException, IOException
XmlPullParserException
IOException
protected void parseXmlDecl(char ch) throws XmlPullParserException, IOException
XmlPullParserException
IOException
protected void parseXmlDeclWithVersion(int versionStart, int versionEnd) throws XmlPullParserException, IOException
XmlPullParserException
IOException
protected void parseDocdecl() throws XmlPullParserException, IOException
XmlPullParserException
IOException
protected void parseCDSect(boolean hadCharData) throws XmlPullParserException, IOException
XmlPullParserException
IOException
protected void fillBuf() throws IOException, XmlPullParserException
IOException
XmlPullParserException
protected char more() throws IOException, XmlPullParserException
IOException
XmlPullParserException
protected void ensurePC(int end)
protected void joinPC()
protected char requireInput(char ch, char[] input) throws XmlPullParserException, IOException
XmlPullParserException
IOException
protected char requireNextS() throws XmlPullParserException, IOException
XmlPullParserException
IOException
protected char skipS(char ch) throws XmlPullParserException, IOException
XmlPullParserException
IOException
protected boolean isNameStartChar(char ch)
protected boolean isNameChar(char ch)
protected boolean isS(char ch)
protected String printable(char ch)
Copyright © 2022 JBoss by Red Hat. All rights reserved.