com.bea.xml.stream

Class MXParser

public class MXParser extends Object implements XMLStreamReader, Location

XML Streaming Parser.

Author: Aleksander Slominski

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 StringcharEncodingScheme
protected char[]charRefOneCharBuf
protected intcolumnNumber
protected HashMapdefaultAttributes
protected intdepth
protected String[]elName
protected int[]elNamespaceCount
protected String[]elPrefix
protected char[][]elRawName
protected int[]elRawNameEnd
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 char[]entityValue
Replacement value for the current entity, when automatic entity expansion is disabled.
protected inteventType
protected static char[]ENCODING
protected static StringFEATURE_NAMES_INTERNED
static StringFEATURE_PROCESS_DOCDECL
static StringFEATURE_PROCESS_NAMESPACES
protected static StringFEATURE_XML_ROUNDTRIP
protected StringinputEncoding
protected intlineNumber
protected intlocalNamespaceEnd
protected String[]localNamespacePrefix
protected int[]localNamespacePrefixHash
protected String[]localNamespaceUri
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[]NO
static StringNO_NAMESPACE
protected booleanpastEndTag
protected char[]pc
protected intpcEnd
protected intpcStart
protected StringpiData
protected StringpiTarget
protected intpos
protected intposEnd
protected intposStart
protected booleanprocessNamespaces
protected booleanreachedEnd
protected Readerreader
protected booleanroundtripSupported
protected static intREAD_CHUNK_SIZE
protected booleanseenAmpersand
protected booleanseenDocdecl
protected booleanseenEndTag
protected booleanseenMarkup
protected booleanseenRoot
protected booleanseenStartTag
protected booleanstandalone
protected booleanstandaloneSet
protected static char[]STANDALONE
protected Stringtext
Lazily-constructed String that contains what getText() returns; cleared by tokenizer before parsing new events
protected booleantokenize
static String[]TYPES
These constants are used for diagnostics messages, and need to match with ones from XMLStreamConstants.
protected booleanusePC
protected static char[]VERSION
protected StringxmlVersion
protected static char[]YES
Constructor Summary
MXParser()
Method Summary
protected voidaddDefaultAttributes(String elementName)
booleancheckForXMLDecl()
voidclose()
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 voidensureLocalNamespacesCapacity(int size)
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()
intgetAttributeCount()
StringgetAttributeLocalName(int index)
QNamegetAttributeName(int index)
StringgetAttributeNamespace(int index)
StringgetAttributePrefix(int index)
IteratorgetAttributes()
StringgetAttributeType(int index)
StringgetAttributeValue(int index)
StringgetAttributeValue(String namespace, String name)
StringgetCharacterEncodingScheme()
intgetCharacterOffset()
intgetColumnNumber()
ConfigurationContextBasegetConfigurationContext()
intgetDepth()
StringgetElementText()
StringgetEncoding()
intgetEventType()
booleangetFeature(String name)
Unknown properties are always returned as false
StringgetInputEncoding()
intgetLineNumber()
StringgetLocalName()
intgetLocalNamespaceCount()
LocationgetLocation()
StringgetLocationURI()
QNamegetName()
NamespaceContextgetNamespaceContext()
intgetNamespaceCount()
intgetNamespaceCount(int depth)
StringgetNamespacePrefix(int pos)
IteratorgetNamespaces()
StringgetNamespaceURI(int pos)
StringgetNamespaceURI(String prefix)
StringgetNamespaceURI()
IteratorgetOutOfScopeNamespaces()
StringgetPIData()
StringgetPITarget()
StringgetPositionDescription()
Return string describing current position of parsers as text 'STATE [seen %s...]
StringgetPrefix()
ObjectgetProperty(String name)
StringgetPublicId()
StringgetSystemId()
StringgetText()
intgetTextCharacters(int sourceStart, char[] target, int targetStart, int length)
char[]getTextCharacters()
intgetTextLength()
intgetTextStart()
ReadergetTextStream()
StringgetValue()
StringgetVersion()
booleanhasAttributes()
booleanhasName()
booleanhasNamespaces()
booleanhasNext()
booleanhasText()
IteratorinternalGetNamespaces(int depth, int namespaceCount)
booleanisAttributeSpecified(int index)
booleanisCharacters()
booleanisEmptyElementTag()
booleanisEndElement()
booleanisEOF()
protected booleanisNameChar(char ch)
protected booleanisNameStartChar(char ch)
protected booleanisS(char ch)
booleanisStandalone()
booleanisStartElement()
booleanisWhiteSpace()
protected voidjoinPC()
protected char[]lookupEntityReplacement(int entitNameLen)
protected charmore()
booleanmoveToEndElement()
booleanmoveToEndElement(String localName)
booleanmoveToEndElement(String localName, String namespaceUri)
booleanmoveToStartElement()
booleanmoveToStartElement(String localName)
booleanmoveToStartElement(String localName, String namespaceUri)
protected StringnewString(char[] cbuf, int off, int len)
protected StringnewStringIntern(char[] cbuf, int off, int len)
intnext()
intnextElement()
protected intnextImpl()
intnextTag()
StringnextText()
intnextToken()
protected charparseAttribute()
protected voidparseCDATA()
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)
protected voidprocessDTD()
voidrecycle()
voidrequire(int type, String namespace, String name)
protected charrequireInput(char ch, char[] input)
protected charrequireNextS()
protected voidresetStringCache()
voidsetConfigurationContext(ConfigurationContextBase c)
voidsetFeature(String name, boolean state)
Method setFeature
voidsetInput(Reader in)
voidsetInput(InputStream in)
voidsetInput(InputStream inputStream, String inputEncoding)
voidsetProperty(String name, Object value)
voidskip()
protected charskipS(char ch)
booleanstandaloneSet()
XMLStreamReadersubReader()

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

charEncodingScheme

protected String charEncodingScheme

charRefOneCharBuf

protected char[] charRefOneCharBuf

columnNumber

protected int columnNumber

defaultAttributes

protected HashMap defaultAttributes

depth

protected int depth

elName

protected String[] elName

elNamespaceCount

protected int[] elNamespaceCount

elPrefix

protected String[] elPrefix

elRawName

protected char[][] elRawName

elRawNameEnd

protected int[] elRawNameEnd

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

entityValue

protected char[] entityValue
Replacement value for the current entity, when automatic entity expansion is disabled. Will always refer to some other array; either globally shared ones (for general entities), or the temp buffer for char entities. As such, does not need to be cleared by tokenizer: will get properly overwritten as needed

eventType

protected int eventType

ENCODING

protected static final char[] ENCODING

FEATURE_NAMES_INTERNED

protected static final String FEATURE_NAMES_INTERNED

FEATURE_PROCESS_DOCDECL

public static final String FEATURE_PROCESS_DOCDECL

FEATURE_PROCESS_NAMESPACES

public static final String FEATURE_PROCESS_NAMESPACES

FEATURE_XML_ROUNDTRIP

protected static final String FEATURE_XML_ROUNDTRIP

inputEncoding

protected String inputEncoding

lineNumber

protected int lineNumber

localNamespaceEnd

protected int localNamespaceEnd

localNamespacePrefix

protected String[] localNamespacePrefix

localNamespacePrefixHash

protected int[] localNamespacePrefixHash

localNamespaceUri

protected String[] localNamespaceUri

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

NO

protected static final char[] NO

NO_NAMESPACE

public static final String NO_NAMESPACE

pastEndTag

protected boolean pastEndTag

pc

protected char[] pc

pcEnd

protected int pcEnd

pcStart

protected int pcStart

piData

protected String piData

piTarget

protected String piTarget

pos

protected int pos

posEnd

protected int posEnd

posStart

protected int posStart

processNamespaces

protected boolean processNamespaces

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

standalone

protected boolean standalone

standaloneSet

protected boolean standaloneSet

STANDALONE

protected static final char[] STANDALONE

text

protected String text
Lazily-constructed String that contains what getText() returns; cleared by tokenizer before parsing new events

tokenize

protected boolean tokenize

TYPES

public static final String[] TYPES
These constants are used for diagnostics messages, and need to match with ones from XMLStreamConstants.

usePC

protected boolean usePC

VERSION

protected static final char[] VERSION

xmlVersion

protected String xmlVersion

YES

protected static final char[] YES

Constructor Detail

MXParser

public MXParser()

Method Detail

addDefaultAttributes

protected void addDefaultAttributes(String elementName)

checkForXMLDecl

public boolean checkForXMLDecl()

close

public void close()

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()

ensureLocalNamespacesCapacity

protected void ensureLocalNamespacesCapacity(int size)

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()

getAttributeCount

public int getAttributeCount()

getAttributeLocalName

public String getAttributeLocalName(int index)

getAttributeName

public QName getAttributeName(int index)

getAttributeNamespace

public String getAttributeNamespace(int index)

getAttributePrefix

public String getAttributePrefix(int index)

getAttributes

public Iterator getAttributes()

getAttributeType

public String getAttributeType(int index)

getAttributeValue

public String getAttributeValue(int index)

getAttributeValue

public String getAttributeValue(String namespace, String name)

getCharacterEncodingScheme

public String getCharacterEncodingScheme()

getCharacterOffset

public int getCharacterOffset()

getColumnNumber

public int getColumnNumber()

getConfigurationContext

public ConfigurationContextBase getConfigurationContext()

getDepth

public int getDepth()

getElementText

public String getElementText()

getEncoding

public String getEncoding()

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()

getLocalName

public String getLocalName()

getLocalNamespaceCount

public int getLocalNamespaceCount()

getLocation

public Location getLocation()

getLocationURI

public String getLocationURI()

getName

public QName getName()

getNamespaceContext

public NamespaceContext getNamespaceContext()

getNamespaceCount

public int getNamespaceCount()

getNamespaceCount

public int getNamespaceCount(int depth)

getNamespacePrefix

public String getNamespacePrefix(int pos)

getNamespaces

public Iterator getNamespaces()

getNamespaceURI

public String getNamespaceURI(int pos)

getNamespaceURI

public String getNamespaceURI(String prefix)

getNamespaceURI

public String getNamespaceURI()

getOutOfScopeNamespaces

public Iterator getOutOfScopeNamespaces()

getPIData

public String getPIData()

getPITarget

public String getPITarget()

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)

getPublicId

public String getPublicId()

getSystemId

public String getSystemId()

getText

public String getText()

getTextCharacters

public int getTextCharacters(int sourceStart, char[] target, int targetStart, int length)

getTextCharacters

public char[] getTextCharacters()

getTextLength

public int getTextLength()

getTextStart

public int getTextStart()

getTextStream

public Reader getTextStream()

getValue

public String getValue()

getVersion

public String getVersion()

hasAttributes

public boolean hasAttributes()

hasName

public boolean hasName()

hasNamespaces

public boolean hasNamespaces()

hasNext

public boolean hasNext()

hasText

public boolean hasText()

internalGetNamespaces

public Iterator internalGetNamespaces(int depth, int namespaceCount)

isAttributeSpecified

public boolean isAttributeSpecified(int index)

isCharacters

public boolean isCharacters()

isEmptyElementTag

public boolean isEmptyElementTag()

isEndElement

public boolean isEndElement()

isEOF

public boolean isEOF()

isNameChar

protected boolean isNameChar(char ch)

isNameStartChar

protected boolean isNameStartChar(char ch)

isS

protected boolean isS(char ch)

isStandalone

public boolean isStandalone()

isStartElement

public boolean isStartElement()

isWhiteSpace

public boolean isWhiteSpace()

joinPC

protected void joinPC()

lookupEntityReplacement

protected char[] lookupEntityReplacement(int entitNameLen)

more

protected char more()

moveToEndElement

public boolean moveToEndElement()

moveToEndElement

public boolean moveToEndElement(String localName)

moveToEndElement

public boolean moveToEndElement(String localName, String namespaceUri)

moveToStartElement

public boolean moveToStartElement()

moveToStartElement

public boolean moveToStartElement(String localName)

moveToStartElement

public boolean moveToStartElement(String localName, String namespaceUri)

newString

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

newStringIntern

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

next

public int next()

nextElement

public int nextElement()

nextImpl

protected int nextImpl()

nextTag

public int nextTag()

nextText

public String nextText()

nextToken

public int nextToken()

parseAttribute

protected char parseAttribute()

parseCDATA

protected void parseCDATA()

parseComment

protected void parseComment()

parseDocdecl

protected void parseDocdecl()

parseEndTag

public int parseEndTag()

parseEntityRef

protected char[] parseEntityRef()

Returns: Character array that contains value the reference expands to.

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)

processDTD

protected void processDTD()

recycle

public void recycle()

require

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

requireInput

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

requireNextS

protected char requireNextS()

resetStringCache

protected void resetStringCache()

setConfigurationContext

public void setConfigurationContext(ConfigurationContextBase c)

setFeature

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

Parameters: name a String state a boolean

Throws: XMLStreamException

setInput

public void setInput(Reader in)

setInput

public void setInput(InputStream in)

setInput

public void setInput(InputStream inputStream, String inputEncoding)

setProperty

public void setProperty(String name, Object value)

skip

public void skip()

skipS

protected char skipS(char ch)

standaloneSet

public boolean standaloneSet()

subReader

public XMLStreamReader subReader()