org.codehaus.plexus.util.xml.pull

Class MXParser

public class MXParser extends Object implements XmlPullParser

Absolutely minimal implementation of XMLPULL V1 API. Encoding handling done with XmlReader

Author: Aleksander Slominski

See Also: XmlReader

Field Summary
protected booleanallStringsInterned
Implementation notice: the is instance variable that controls if newString() is interning.
protected intattributeCount
protected String[]attributeName
protected int[]attributeNameHash
protected String[]attributePrefix
protected String[]attributeUri
protected String[]attributeValue
protected char[]buf
protected intbufAbsoluteStart
protected intbufEnd
protected intbufLoadFactor
protected intbufSoftLimit
protected intbufStart
protected char[]charRefOneCharBuf
protected intcolumnNumber
protected intdepth
protected String[]elName
protected int[]elNamespaceCount
protected String[]elPrefix
protected char[][]elRawName
protected int[]elRawNameEnd
protected int[]elRawNameLine
protected String[]elUri
protected booleanemptyElementTag
protected intentityEnd
protected String[]entityName
protected char[][]entityNameBuf
protected int[]entityNameHash
protected StringentityRefName
protected String[]entityReplacement
protected char[][]entityReplacementBuf
protected inteventType
protected static StringFEATURE_NAMES_INTERNED
protected static StringFEATURE_XML_ROUNDTRIP
protected StringinputEncoding
protected intlineNumber
protected Stringlocation
protected static boolean[]lookupNameChar
protected static boolean[]lookupNameStartChar
protected static intLOOKUP_MAX
protected static charLOOKUP_MAX_CHAR
protected intnamespaceEnd
protected String[]namespacePrefix
protected int[]namespacePrefixHash
protected String[]namespaceUri
protected static char[]NCODING
protected static char[]NO
protected booleanpastEndTag
protected char[]pc
protected intpcEnd
protected intpcStart
protected intpos
protected intposEnd
protected intposStart
protected booleanpreventBufferCompaction
protected booleanprocessNamespaces
protected static StringPROPERTY_LOCATION
protected static StringPROPERTY_XMLDECL_CONTENT
protected static StringPROPERTY_XMLDECL_STANDALONE
protected static StringPROPERTY_XMLDECL_VERSION
protected booleanreachedEnd
protected Readerreader
protected booleanroundtripSupported
protected static intREAD_CHUNK_SIZE
protected booleanseenAmpersand
protected booleanseenDocdecl
protected booleanseenEndTag
protected booleanseenMarkup
protected booleanseenRoot
protected booleanseenStartTag
protected Stringtext
protected booleantokenize
protected static char[]TANDALONE
static booleanTRACE_SIZING
protected booleanusePC
protected static char[]VERSION
protected StringxmlDeclContent
protected BooleanxmlDeclStandalone
protected StringxmlDeclVersion
protected static StringXMLNS_URI
protected static StringXML_URI
protected static char[]YES
Constructor Summary
MXParser()
Method Summary
voiddefineEntityReplacementText(String entityName, String replacementText)
protected voidensureAttributesCapacity(int size)
Make sure that in attributes temporary array is enough space.
protected voidensureElementsCapacity()
Make sure that we have enough space to keep element stack if passed size.
protected voidensureEntityCapacity()
protected voidensureNamespacesCapacity(int size)
protected voidensurePC(int end)
protected static intfastHash(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 voidfillBuf()
static intfindFragment(int bufMinPos, char[] b, int start, int end)
intgetAttributeCount()
StringgetAttributeName(int index)
StringgetAttributeNamespace(int index)
StringgetAttributePrefix(int index)
StringgetAttributeType(int index)
StringgetAttributeValue(int index)
StringgetAttributeValue(String namespace, String name)
intgetColumnNumber()
intgetDepth()
intgetEventType()
booleangetFeature(String name)
Unknown properties are always returned as false
StringgetInputEncoding()
intgetLineNumber()
StringgetName()
StringgetNamespace(String prefix)
StringgetNamespace()
intgetNamespaceCount(int depth)
StringgetNamespacePrefix(int pos)
StringgetNamespaceUri(int pos)
StringgetPositionDescription()
Return string describing current position of parsers as text 'STATE [seen %s...]
StringgetPrefix()
ObjectgetProperty(String name)
StringgetText()
char[]getTextCharacters(int[] holderForStartAndLength)
booleanisAttributeDefault(int index)
booleanisEmptyElementTag()
protected booleanisNameChar(char ch)
protected booleanisNameStartChar(char ch)
protected booleanisS(char ch)
booleanisWhitespace()
protected voidjoinPC()
protected char[]lookuEntityReplacement(int entitNameLen)
protected charmore()
protected StringnewString(char[] cbuf, int off, int len)
protected StringnewStringIntern(char[] cbuf, int off, int len)
intnext()
protected intnextImpl()
intnextTag()
StringnextText()
intnextToken()
protected charparseAttribute()
protected voidparseCDSect(boolean hadCharData)
protected voidparseComment()
protected voidparseDocdecl()
intparseEndTag()
protected char[]parseEntityRef()
protected intparseEpilog()
protected booleanparsePI()
protected intparseProlog()
intparseStartTag()
protected voidparseXmlDecl(char ch)
protected voidparseXmlDeclWithVersion(int versionStart, int versionEnd)
protected Stringprintable(char ch)
protected Stringprintable(String s)
voidrequire(int type, String namespace, String name)
protected charrequireInput(char ch, char[] input)
protected charrequireNextS()
protected voidreset()
protected voidresetStringCache()
voidsetFeature(String name, boolean state)
Method setFeature
voidsetInput(Reader in)
voidsetInput(InputStream inputStream, String inputEncoding)
static voidsetName(char ch)
static voidsetNameStart(char ch)
voidsetProperty(String name, Object value)
protected charskipS(char ch)
voidskipSubTree()
Skip sub tree that is currently porser positioned on.

Field Detail

allStringsInterned

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

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!

attributeCount

protected int attributeCount

attributeName

protected String[] attributeName

attributeNameHash

protected int[] attributeNameHash

attributePrefix

protected String[] attributePrefix

attributeUri

protected String[] attributeUri

attributeValue

protected String[] attributeValue

buf

protected char[] buf

bufAbsoluteStart

protected int bufAbsoluteStart

bufEnd

protected int bufEnd

bufLoadFactor

protected int bufLoadFactor

bufSoftLimit

protected int bufSoftLimit

bufStart

protected int bufStart

charRefOneCharBuf

protected char[] charRefOneCharBuf

columnNumber

protected int columnNumber

depth

protected int depth

elName

protected String[] elName

elNamespaceCount

protected int[] elNamespaceCount

elPrefix

protected String[] elPrefix

elRawName

protected char[][] elRawName

elRawNameEnd

protected int[] elRawNameEnd

elRawNameLine

protected int[] elRawNameLine

elUri

protected String[] elUri

emptyElementTag

protected boolean emptyElementTag

entityEnd

protected int entityEnd

entityName

protected String[] entityName

entityNameBuf

protected char[][] entityNameBuf

entityNameHash

protected int[] entityNameHash

entityRefName

protected String entityRefName

entityReplacement

protected String[] entityReplacement

entityReplacementBuf

protected char[][] entityReplacementBuf

eventType

protected int eventType

FEATURE_NAMES_INTERNED

protected static final String FEATURE_NAMES_INTERNED

FEATURE_XML_ROUNDTRIP

protected static final String FEATURE_XML_ROUNDTRIP

inputEncoding

protected String inputEncoding

lineNumber

protected int lineNumber

location

protected String location

lookupNameChar

protected static boolean[] lookupNameChar

lookupNameStartChar

protected static boolean[] lookupNameStartChar

LOOKUP_MAX

protected static final int LOOKUP_MAX

LOOKUP_MAX_CHAR

protected static final char LOOKUP_MAX_CHAR

namespaceEnd

protected int namespaceEnd

namespacePrefix

protected String[] namespacePrefix

namespacePrefixHash

protected int[] namespacePrefixHash

namespaceUri

protected String[] namespaceUri

NCODING

protected static final char[] NCODING

NO

protected static final char[] NO

pastEndTag

protected boolean pastEndTag

pc

protected char[] pc

pcEnd

protected int pcEnd

pcStart

protected int pcStart

pos

protected int pos

posEnd

protected int posEnd

posStart

protected int posStart

preventBufferCompaction

protected boolean preventBufferCompaction

processNamespaces

protected boolean processNamespaces

PROPERTY_LOCATION

protected static final String PROPERTY_LOCATION

PROPERTY_XMLDECL_CONTENT

protected static final String PROPERTY_XMLDECL_CONTENT

PROPERTY_XMLDECL_STANDALONE

protected static final String PROPERTY_XMLDECL_STANDALONE

PROPERTY_XMLDECL_VERSION

protected static final String PROPERTY_XMLDECL_VERSION

reachedEnd

protected boolean reachedEnd

reader

protected Reader reader

roundtripSupported

protected boolean roundtripSupported

READ_CHUNK_SIZE

protected static final int READ_CHUNK_SIZE

seenAmpersand

protected boolean seenAmpersand

seenDocdecl

protected boolean seenDocdecl

seenEndTag

protected boolean seenEndTag

seenMarkup

protected boolean seenMarkup

seenRoot

protected boolean seenRoot

seenStartTag

protected boolean seenStartTag

text

protected String text

tokenize

protected boolean tokenize

TANDALONE

protected static final char[] TANDALONE

TRACE_SIZING

private static final boolean TRACE_SIZING

usePC

protected boolean usePC

VERSION

protected static final char[] VERSION

xmlDeclContent

protected String xmlDeclContent

xmlDeclStandalone

protected Boolean xmlDeclStandalone

xmlDeclVersion

protected String xmlDeclVersion

XMLNS_URI

protected static final String XMLNS_URI

XML_URI

protected static final String XML_URI

YES

protected static final char[] YES

Constructor Detail

MXParser

public MXParser()

Method Detail

defineEntityReplacementText

public void defineEntityReplacementText(String entityName, String replacementText)

ensureAttributesCapacity

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

ensureElementsCapacity

protected void ensureElementsCapacity()
Make sure that we have enough space to keep element stack if passed size. It will always create one additional slot then current depth

ensureEntityCapacity

protected void ensureEntityCapacity()

ensureNamespacesCapacity

protected void ensureNamespacesCapacity(int size)

ensurePC

protected void ensurePC(int end)

fastHash

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

fillBuf

protected void fillBuf()

findFragment

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

getAttributeCount

public int getAttributeCount()

getAttributeName

public String getAttributeName(int index)

getAttributeNamespace

public String getAttributeNamespace(int index)

getAttributePrefix

public String getAttributePrefix(int index)

getAttributeType

public String getAttributeType(int index)

getAttributeValue

public String getAttributeValue(int index)

getAttributeValue

public String getAttributeValue(String namespace, String name)

getColumnNumber

public int getColumnNumber()

getDepth

public int getDepth()

getEventType

public int getEventType()

getFeature

public boolean getFeature(String name)
Unknown properties are always returned as false

getInputEncoding

public String getInputEncoding()

getLineNumber

public int getLineNumber()

getName

public String getName()

getNamespace

public String getNamespace(String prefix)

getNamespace

public String getNamespace()

getNamespaceCount

public int getNamespaceCount(int depth)

getNamespacePrefix

public String getNamespacePrefix(int pos)

getNamespaceUri

public String getNamespaceUri(int pos)

getPositionDescription

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

getPrefix

public String getPrefix()

getProperty

public Object getProperty(String name)

getText

public String getText()

getTextCharacters

public char[] getTextCharacters(int[] holderForStartAndLength)

isAttributeDefault

public boolean isAttributeDefault(int index)

isEmptyElementTag

public boolean isEmptyElementTag()

isNameChar

protected boolean isNameChar(char ch)

isNameStartChar

protected boolean isNameStartChar(char ch)

isS

protected boolean isS(char ch)

isWhitespace

public boolean isWhitespace()

joinPC

protected void joinPC()

lookuEntityReplacement

protected char[] lookuEntityReplacement(int entitNameLen)

more

protected char more()

newString

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

newStringIntern

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

next

public int next()

nextImpl

protected int nextImpl()

nextTag

public int nextTag()

nextText

public String nextText()

nextToken

public int nextToken()

parseAttribute

protected char parseAttribute()

parseCDSect

protected void parseCDSect(boolean hadCharData)

parseComment

protected void parseComment()

parseDocdecl

protected void parseDocdecl()

parseEndTag

public int parseEndTag()

parseEntityRef

protected char[] parseEntityRef()

parseEpilog

protected int parseEpilog()

parsePI

protected boolean parsePI()

parseProlog

protected int parseProlog()

parseStartTag

public int parseStartTag()

parseXmlDecl

protected void parseXmlDecl(char ch)

parseXmlDeclWithVersion

protected void parseXmlDeclWithVersion(int versionStart, int versionEnd)

printable

protected String printable(char ch)

printable

protected String printable(String s)

require

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

requireInput

protected char requireInput(char ch, char[] input)

requireNextS

protected char requireNextS()

reset

protected void reset()

resetStringCache

protected void resetStringCache()

setFeature

public void setFeature(String name, boolean state)
Method setFeature

Parameters: name a String state a boolean

Throws: XmlPullParserException

setInput

public void setInput(Reader in)

setInput

public void setInput(InputStream inputStream, String inputEncoding)

setName

private static final void setName(char ch)

setNameStart

private static final void setNameStart(char ch)

setProperty

public void setProperty(String name, Object value)

skipS

protected char skipS(char ch)

skipSubTree

public void skipSubTree()
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 corresponding END_TAG