Top Description Fields Constructors Methods
org.jboss.modules.xml

public Class MXParser

extends Object
implements XmlPullParser
Class Inheritance
All Implemented Interfaces
org.jboss.modules.xml.XmlPullParser
Imports
java.io.EOFException, .IOException, .InputStream, .InputStreamReader, .Reader, .UnsupportedEncodingException, java.nio.charset.StandardCharsets

Absolutely minimal implementation of XMLPULL V1 API
Author
Aleksander Slominski

Field Summary

Modifier and TypeField and Description
protected boolean
allStringsInterned

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

protected int
protected String[]
protected int[]
protected String[]
protected String[]
protected String[]
protected char[]
protected int
protected int
protected int
protected int
protected int
protected char[]
protected int
protected int
protected String[]
protected int[]
protected String[]
protected char[][]
protected int[]
protected int[]
protected String[]
protected boolean
protected int
protected String[]
protected char[][]
protected int[]
protected String
protected String[]
protected char[][]
protected int
protected static final String
protected static final String
protected String
protected InputStream
protected int
protected String
protected static final int
protected static final char
protected static boolean[]
protected static boolean[]
protected int
protected String[]
protected int[]
protected String[]
protected static final char[]
protected static final char[]
protected boolean
protected char[]
protected int
protected int
protected int
protected int
protected int
protected boolean
protected boolean
protected static final String
protected static final String
protected static final String
protected static final String
protected boolean
protected static final int
protected Reader
protected boolean
protected boolean
protected boolean
protected boolean
protected boolean
protected boolean
protected boolean
protected static final char[]
protected String
protected boolean
private static final boolean
protected boolean
protected static final char[]
protected static final String
protected String
protected Boolean
protected String
protected static final String
protected static final char[]

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
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
protected void
protected void
ensurePC(int end)

protected 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 ...

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

public int
getAttributeCount()

Implements org.jboss.modules.xml.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
zero based index of attribute
index
)

Implements org.jboss.modules.xml.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
zero based index of attribute
index
)

Implements org.jboss.modules.xml.XmlPullParser.getAttributeNamespace.

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

Implements org.jboss.modules.xml.XmlPullParser.getAttributePrefix.

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

Implements org.jboss.modules.xml.XmlPullParser.getAttributeType.

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

Implements org.jboss.modules.xml.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.jboss.modules.xml.XmlPullParser.getAttributeValue.

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

Implements org.jboss.modules.xml.XmlPullParser.getColumnNumber.

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

Implements org.jboss.modules.xml.XmlPullParser.getDepth.

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

Implements org.jboss.modules.xml.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.jboss.modules.xml.XmlPullParser.getFeature.

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

Implements org.jboss.modules.xml.XmlPullParser.getInputEncoding.

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

Implements org.jboss.modules.xml.XmlPullParser.getLineNumber.

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

Implements org.jboss.modules.xml.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.jboss.modules.xml.XmlPullParser.getNamespace.

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

Implements org.jboss.modules.xml.XmlPullParser.getNamespace.

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

Implements org.jboss.modules.xml.XmlPullParser.getNamespaceCount.

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

Implements org.jboss.modules.xml.XmlPullParser.getNamespacePrefix.

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

Implements org.jboss.modules.xml.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.jboss.modules.xml.XmlPullParser.getPositionDescription.

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

Implements org.jboss.modules.xml.XmlPullParser.getPrefix.

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

Implements org.jboss.modules.xml.XmlPullParser.getProperty.

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

Implements org.jboss.modules.xml.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.jboss.modules.xml.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
zero based index of attribute
index
)

Implements org.jboss.modules.xml.XmlPullParser.isAttributeDefault.

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

Implements org.jboss.modules.xml.XmlPullParser.isEmptyElementTag.

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

protected boolean
isNameStartChar(char ch)

protected boolean
isS(char ch)

public boolean
isWhitespace()

Implements org.jboss.modules.xml.XmlPullParser.isWhitespace.

Checks whether the current TEXT event contains only whitespace characters.
protected void
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)

public int
next()

Implements org.jboss.modules.xml.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).
protected int
public int
nextTag()

Implements org.jboss.modules.xml.XmlPullParser.nextTag.

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

Implements org.jboss.modules.xml.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.jboss.modules.xml.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.
protected char
protected void
parseCDSect(boolean hadCharData)

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

protected void
parseXmlDeclWithVersion(int versionStart, int versionEnd)

protected String
printable(char ch)

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

Implements org.jboss.modules.xml.XmlPullParser.require.

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
protected void
protected void
public void
setFeature(String
a String
name
,
boolean
a boolean
state
)

Implements org.jboss.modules.xml.XmlPullParser.setFeature.

Method setFeature
public void
setInput(Reader in)

Implements org.jboss.modules.xml.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.jboss.modules.xml.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.jboss.modules.xml.XmlPullParser.setProperty.

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

public void
skipSubTree()

Skip sub tree that is currently parser positioned on.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait