Top Description Fields Constructors Methods
io.github.xstream.mxparser

public Class MXParser

extends Object
implements XmlPullParser
Class Inheritance
All Implemented Interfaces
org.xmlpull.v1.XmlPullParser
Imports
java.io.EOFException, .IOException, .InputStream, .InputStreamReader, .Reader, .UnsupportedEncodingException, org.xmlpull.v1.XmlPullParser, .XmlPullParserException

Absolutely minimal implementation of XMLPULL V1 API
Author
Aleksander Slominski

Field Summary

Modifier and TypeField and Description
private boolean
allStringsInterned

Implementation notice: the is instance variable that controls if newString() is interning.

private int
private String[]
private int[]
private String[]
private String[]
private String[]
private char[]
private int
private int
private float
private int
private int
private int
private char[]
private int
private int
private String[]
private int[]
private String[]
private char[][]
private int[]
private int[]
private String[]
private boolean
private int
private String[]
private char[][]
private int[]
private String
private String[]
private char[][]
private int
private static final String
private static final String
private String
private int
private String
private static final int
private static final char
private static boolean[]
private static boolean[]
private int
private String[]
private int[]
private String[]
private static final char[]
private static final char[]
private static boolean
private boolean
private char[]
private int
private int
private int
private int
private int
private boolean
private boolean
private static final String
private static final String
private static final String
private static final String
private boolean
private static final int
private Reader
private boolean
private boolean
private boolean
private boolean
private boolean
private boolean
private boolean
private static final char[]
private String
private boolean
private static final boolean
private boolean
private static final char[]
private static final String
private String
private Boolean
private String
private static final String
private static final char[]

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
private void
ensureAttributesCapacity(int size)

Make sure that in attributes temporary array is enough space.

private void
ensureElementsCapacity()

Make sure that we have enough space to keep element stack if passed size.

private void
private void
private void
ensurePC(int end)

private static final 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 ...

private void
private static int
findFragment(int bufMinPos, char[] b, int start, int end)

public int
getAttributeCount()

Implements org.xmlpull.v1.XmlPullParser.getAttributeCount.

Returns the number of attributes of the current start tag, or -1 if the current event type is not START_TAG
public String
getAttributeName(int
based index of attribute
index
)

Implements org.xmlpull.v1.XmlPullParser.getAttributeName.

Returns the local name of the specified attribute if namespaces are enabled or just attribute name if namespaces are disabled.
public String
getAttributeNamespace(int
based index of attribute
index
)

Implements org.xmlpull.v1.XmlPullParser.getAttributeNamespace.

Returns the namespace URI of the attribute with the given index (starts from 0).
public String
getAttributePrefix(int
based index of attribute
index
)

Implements org.xmlpull.v1.XmlPullParser.getAttributePrefix.

Returns the prefix of the specified attribute Returns null if the element has no prefix.
public String
getAttributeType(int
based index of attribute
index
)

Implements org.xmlpull.v1.XmlPullParser.getAttributeType.

Returns the type of the specified attribute If parser is non-validating it MUST return CDATA.
public String
getAttributeValue(int
based index of attribute
index
)

Implements org.xmlpull.v1.XmlPullParser.getAttributeValue.

Returns the given attributes value.
public String
getAttributeValue(String
Namespace of the attribute if namespaces are enabled otherwise must be null
namespace
,
String
If namespaces enabled local name of attribute otherwise just attribute name
name
)

Implements org.xmlpull.v1.XmlPullParser.getAttributeValue.

Returns the attributes value identified by namespace URI and namespace localName.
public int
getColumnNumber()

Implements org.xmlpull.v1.XmlPullParser.getColumnNumber.

Returns the current column number, starting from 0.
public int
getDepth()

Implements org.xmlpull.v1.XmlPullParser.getDepth.

Returns the current depth of the element.
public int
getEventType()

Implements org.xmlpull.v1.XmlPullParser.getEventType.

Returns the type of the current event (START_TAG, END_TAG, TEXT, etc.)
public boolean
getFeature(String
The name of feature to be retrieved.
name
)

Implements org.xmlpull.v1.XmlPullParser.getFeature.

Unknown properties are always returned as false
public String
getInputEncoding()

Implements org.xmlpull.v1.XmlPullParser.getInputEncoding.

Returns the input encoding if known, null otherwise.
public int
getLineNumber()

Implements org.xmlpull.v1.XmlPullParser.getLineNumber.

Returns the current line number, starting from 1.
public String
getName()

Implements org.xmlpull.v1.XmlPullParser.getName.

For START_TAG or END_TAG events, the (local) name of the current element is returned when namespaces are enabled.
public String
getNamespace(String prefix)

Implements org.xmlpull.v1.XmlPullParser.getNamespace.

Returns the URI corresponding to the given prefix, depending on current state of the parser.
public String
getNamespace()

Implements org.xmlpull.v1.XmlPullParser.getNamespace.

Returns the namespace URI of the current element.
public int
getNamespaceCount(int depth)

Implements org.xmlpull.v1.XmlPullParser.getNamespaceCount.

Returns the numbers of elements in the namespace stack for the given depth.
public String
getNamespacePrefix(int pos)

Implements org.xmlpull.v1.XmlPullParser.getNamespacePrefix.

Returns the namespace prefixe for the given position in the namespace stack.
public String
getNamespaceUri(int pos)

Implements org.xmlpull.v1.XmlPullParser.getNamespaceUri.

Returns the namespace URI for the given position in the namespace stack If the position is out of range, an exception is thrown.
public String
getPositionDescription()

Implements org.xmlpull.v1.XmlPullParser.getPositionDescription.

Return string describing current position of parsers as text 'STATE [seen %s...] @line:column'.
public String
getPrefix()

Implements org.xmlpull.v1.XmlPullParser.getPrefix.

Returns the prefix of the current element.
public Object
getProperty(String
The name of property to be retrieved.
name
)

Implements org.xmlpull.v1.XmlPullParser.getProperty.

Look up the value of a property.
public String
getText()

Implements org.xmlpull.v1.XmlPullParser.getText.

Returns the text content of the current event as String.
public char[]
getTextCharacters(int[]
Must hold an 2-element int array into which the start offset and length values will be written.
holderForStartAndLength
)

Implements org.xmlpull.v1.XmlPullParser.getTextCharacters.

Returns the buffer that contains the text of the current event, as well as the start offset and length relevant for the current event.
public boolean
isAttributeDefault(int
based index of attribute
index
)

Implements org.xmlpull.v1.XmlPullParser.isAttributeDefault.

Returns if the specified attribute was not in input was declared in XML.
public boolean
isEmptyElementTag()

Implements org.xmlpull.v1.XmlPullParser.isEmptyElementTag.

Returns true if the current event is START_TAG and the tag is degenerated (e.g. <foobar/>).
private boolean
isNameChar(char ch)

private boolean
isNameStartChar(char ch)

private boolean
isS(char ch)

public boolean
isWhitespace()

Implements org.xmlpull.v1.XmlPullParser.isWhitespace.

Checks whether the current TEXT event contains only whitespace characters.
private void
private char[]
lookupEntityReplacement(int entityNameLen)

private char
more()

private String
newString(char[] cbuf, int off, int len)

private String
newStringIntern(char[] cbuf, int off, int len)

public int
next()

Implements org.xmlpull.v1.XmlPullParser.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).
private int
public int
nextTag()

Implements org.xmlpull.v1.XmlPullParser.nextTag.

Call next() and return event if it is START_TAG or END_TAG otherwise throw an exception.
public String
nextText()

Implements org.xmlpull.v1.XmlPullParser.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.
public int
nextToken()

Implements org.xmlpull.v1.XmlPullParser.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.
private char
private void
parseCDSect(boolean hadCharData)

private void
private void
public int
private char[]
private int
private boolean
private int
public int
private void
parseXmlDecl(char ch)

private void
parseXmlDeclWithVersion(int versionStart, int versionEnd)

private String
printable(char ch)

private String
public void
require(int type, String namespace, String name)

Implements org.xmlpull.v1.XmlPullParser.require.

Test if the current event is of the given type and if the namespace and name do match.
private char
requireInput(char ch, char[] input)

private char
private void
private void
public void
setFeature(String
a String
name
,
boolean
a boolean
state
)

Implements org.xmlpull.v1.XmlPullParser.setFeature.

Method setFeature
public void
setInput(Reader in)

Implements org.xmlpull.v1.XmlPullParser.setInput.

Set the input source for parser to the given reader and resets the parser.
public void
setInput(InputStream
contains a raw byte input stream of possibly unknown encoding (when inputEncoding is null).
inputStream
,
String
if not null it MUST be used as encoding for inputStream
inputEncoding
)

Implements org.xmlpull.v1.XmlPullParser.setInput.

Sets the input stream the parser is going to process.
private static final void
setName(char ch)

private static final void
setNameStart(char ch)

public void
setProperty(String name, Object value)

Implements org.xmlpull.v1.XmlPullParser.setProperty.

Set the value of a property.
private char
skipS(char ch)

public void
skipSubTree()

Skip sub tree that is currently parser positioned on.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait