Package com.bea.xml.stream
Class MXParser
java.lang.Object
com.bea.xml.stream.MXParser
- All Implemented Interfaces:
Location,XMLStreamConstants,XMLStreamReader
XML Streaming Parser.
- Author:
- Aleksander Slominski
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanImplementation notice: the is instance variable that controls if newString() is interning.protected intprotected String[]protected int[]protected String[]protected String[]protected String[]protected char[]Logics for this should be clarified...protected intprotected intprotected intprotected intprotected intprotected static final charprotected Stringprotected char[]This buffer is used for expanding single character (non-surrogate) character entity expansions.protected char[]This buffer is used in cases where an entity expands to a surrogate pair.protected intprotected HashMapprotected intprotected String[]protected int[]protected String[]protected char[][]protected int[]protected String[]protected booleanprotected static final char[]protected intprotected String[]protected char[][]protected int[]protected Stringprotected String[]protected char[][]protected char[]Replacement value for the current entity, when automatic entity expansion is disabled.protected intprotected static final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringprotected static final Stringprotected Stringprotected intprotected intprotected String[]protected int[]protected String[]protected static final intprotected static final charprotected static boolean[]protected static boolean[]protected static final intprotected com.wutka.dtd.DTDIf the internal DTD subset was parsed, this object will be non-null, and can be used for accessing entities, elements and notations declared in the internal subset.protected intprotected String[]protected int[]protected String[]protected static final char[]static final StringThis constant defines URI used for "no namespace" (when the default namespace not defined, for elements; when attribute has no prefix, or for all URIs if namespace support is disabled).protected booleanprotected char[]protected intprotected intprotected Stringprotected Stringprotected intprotected intprotected intprotected booleanprotected booleanprotected static final intprotected Readerprotected booleanprotected booleanprotected booleanprotected booleanprotected booleanprotected booleanprotected booleanprotected booleanFlag that indicates whether 'standalone="yes"' was found from the xml declaration.protected static final char[]protected booleanprotected StringLazily-constructed String that contains what getText() returns; cleared by tokenizer before parsing new eventsprotected booleanstatic final String[]These constants are used for diagnostics messages, and need to match with ones fromXMLStreamConstants.protected booleanprotected static final char[]protected StringXML version found from the xml declaration, if any.protected static final char[]Fields inherited from interface javax.xml.stream.XMLStreamConstants
ATTRIBUTE, CDATA, CHARACTERS, COMMENT, DTD, END_DOCUMENT, END_ELEMENT, ENTITY_DECLARATION, ENTITY_REFERENCE, NAMESPACE, NOTATION_DECLARATION, PROCESSING_INSTRUCTION, SPACE, START_DOCUMENT, START_ELEMENT -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddDefaultAttributes(String elementName) protected voidcheckCharValidity(int ch, boolean surrogatesOk) booleanvoidclose()voiddefineEntityReplacementText(String entityName, String replacementText) protected voidensureAttributesCapacity(int size) Make sure that in attributes temporary array is enough space.protected voidMake sure that we have enough space to keep element stack if passed size.protected voidprotected voidensureLocalNamespacesCapacity(int size) protected voidensureNamespacesCapacity(int size) protected voidensurePC(int end) protected static final 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()intgetAttributeLocalName(int index) getAttributeName(int index) getAttributeNamespace(int index) getAttributePrefix(int index) getAttributeType(int index) getAttributeValue(int index) getAttributeValue(String namespace, String name) intintintgetDepth()intbooleangetFeature(String name) Unknown properties arealways returned as false intintgetName()intintgetNamespaceCount(int depth) getNamespacePrefix(int pos) getNamespaceURI(int pos) getNamespaceURI(String prefix) Return string describing current position of parsers as text 'STATE [seen %s...] @line:column'.getProperty(String name) getText()char[]intgetTextCharacters(int sourceStart, char[] target, int targetStart, int length) intintgetValue()booleanbooleanhasName()booleanbooleanhasNext()booleanhasText()internalGetNamespaces(int depth, int namespaceCount) booleanisAttributeSpecified(int index) booleanbooleanbooleanbooleanisEOF()protected booleanisNameChar(char ch) protected booleanisNameStartChar(char ch) protected booleanisS(char ch) booleanbooleanbooleanprotected voidjoinPC()protected char[]lookupEntityReplacement(int entitNameLen) protected charmore()booleanbooleanmoveToEndElement(String localName) booleanmoveToEndElement(String localName, String namespaceUri) booleanbooleanmoveToStartElement(String localName) booleanmoveToStartElement(String localName, String namespaceUri) protected StringnewString(char[] cbuf, int off, int len) protected StringnewStringIntern(char[] cbuf, int off, int len) intnext()intprotected intnextImpl()intnextTag()nextText()intprotected charprotected voidprotected voidprotected voidintprotected char[]parseEntityRef(boolean replace) protected intprotected booleanparsePI()protected intintprotected voidparseXmlDecl(char ch) protected voidparseXmlDeclWithVersion(int versionStart, int versionEnd) protected Stringprintable(char ch) protected Stringprotected voidvoidrecycle()voidprotected charrequireInput(char ch, char[] input) protected charprotected voidvoidvoidsetFeature(String name, boolean state) Method setFeaturevoidsetInput(InputStream in) voidsetInput(InputStream inputStream, String inputEncoding) voidvoidsetProperty(String name, Object value) voidskip()protected charskipS(char ch) boolean
-
Field Details
-
CHAR_UTF8_BOM
protected static final char CHAR_UTF8_BOM- See Also:
-
MAX_UNICODE_CHAR
protected static final int MAX_UNICODE_CHAR- See Also:
-
FEATURE_XML_ROUNDTRIP
- See Also:
-
FEATURE_NAMES_INTERNED
- See Also:
-
FEATURE_PROCESS_DOCDECL
- See Also:
-
FEATURE_STAX_NOTATIONS
- See Also:
-
FEATURE_STAX_ENTITIES
- See Also:
-
TYPES
These constants are used for diagnostics messages, and need to match with ones fromXMLStreamConstants. -
NO_NAMESPACE
This constant defines URI used for "no namespace" (when the default namespace not defined, for elements; when attribute has no prefix, or for all URIs if namespace support is disabled). -
allStringsInterned
protected boolean allStringsInternedImplementation 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!
-
FEATURE_PROCESS_NAMESPACES
- See Also:
-
processNamespaces
protected boolean processNamespaces -
roundtripSupported
protected boolean roundtripSupported -
lineNumber
protected int lineNumber -
columnNumber
protected int columnNumber -
seenRoot
protected boolean seenRoot -
reachedEnd
protected boolean reachedEnd -
eventType
protected int eventType -
emptyElementTag
protected boolean emptyElementTag -
depth
protected int depth -
elRawName
protected char[][] elRawName -
elRawNameEnd
protected int[] elRawNameEnd -
elName
-
elPrefix
-
elUri
-
elNamespaceCount
protected int[] elNamespaceCount -
xmlVersion
XML version found from the xml declaration, if any. -
standalone
protected boolean standaloneFlag that indicates whether 'standalone="yes"' was found from the xml declaration. -
standaloneSet
protected boolean standaloneSet -
charEncodingScheme
-
piTarget
-
piData
-
mDtdIntSubset
protected com.wutka.dtd.DTD mDtdIntSubsetIf the internal DTD subset was parsed, this object will be non-null, and can be used for accessing entities, elements and notations declared in the internal subset. -
defaultAttributes
-
LOOKUP_MAX
protected static final int LOOKUP_MAX- See Also:
-
LOOKUP_MAX_CHAR
protected static final char LOOKUP_MAX_CHAR- See Also:
-
lookupNameStartChar
protected static boolean[] lookupNameStartChar -
lookupNameChar
protected static boolean[] lookupNameChar -
attributeCount
protected int attributeCount -
attributeName
-
attributeNameHash
protected int[] attributeNameHash -
attributePrefix
-
attributeUri
-
attributeValue
-
namespaceEnd
protected int namespaceEnd -
namespacePrefix
-
namespacePrefixHash
protected int[] namespacePrefixHash -
namespaceUri
-
localNamespaceEnd
protected int localNamespaceEnd -
localNamespacePrefix
-
localNamespacePrefixHash
protected int[] localNamespacePrefixHash -
localNamespaceUri
-
entityEnd
protected int entityEnd -
entityName
-
entityNameBuf
protected char[][] entityNameBuf -
entityNameHash
protected int[] entityNameHash -
entityReplacementBuf
protected char[][] entityReplacementBuf -
entityReplacement
-
READ_CHUNK_SIZE
protected static final int READ_CHUNK_SIZE- See Also:
-
reader
-
inputEncoding
-
bufLoadFactor
protected int bufLoadFactor -
buf
protected char[] bufLogics for this should be clarified... but it looks like we use a 8k buffer if there's 1M of free memory or more, otherwise just 256 bytes? -
bufSoftLimit
protected int bufSoftLimit -
bufAbsoluteStart
protected int bufAbsoluteStart -
bufStart
protected int bufStart -
bufEnd
protected int bufEnd -
pos
protected int pos -
posStart
protected int posStart -
posEnd
protected int posEnd -
pc
protected char[] pc -
pcStart
protected int pcStart -
pcEnd
protected int pcEnd -
usePC
protected boolean usePC -
seenStartTag
protected boolean seenStartTag -
seenEndTag
protected boolean seenEndTag -
pastEndTag
protected boolean pastEndTag -
seenAmpersand
protected boolean seenAmpersand -
seenMarkup
protected boolean seenMarkup -
seenDocdecl
protected boolean seenDocdecl -
tokenize
protected boolean tokenize -
text
Lazily-constructed String that contains what getText() returns; cleared by tokenizer before parsing new events -
entityRefName
-
entityValue
protected char[] entityValueReplacement 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 -
charRefOneCharBuf
protected char[] charRefOneCharBufThis buffer is used for expanding single character (non-surrogate) character entity expansions. -
charRefTwoCharBuf
protected char[] charRefTwoCharBufThis buffer is used in cases where an entity expands to a surrogate pair. Since this is a rare occurence, it's lazily created if needed. -
VERSION
protected static final char[] VERSION -
ENCODING
protected static final char[] ENCODING -
STANDALONE
protected static final char[] STANDALONE -
YES
protected static final char[] YES -
NO
protected static final char[] NO
-
-
Constructor Details
-
MXParser
public MXParser()
-
-
Method Details
-
resetStringCache
protected void resetStringCache() -
newString
-
newStringIntern
-
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 -
isNameStartChar
protected boolean isNameStartChar(char ch) -
isNameChar
protected boolean isNameChar(char ch) -
isS
protected boolean isS(char ch) -
checkCharValidity
- Throws:
XMLStreamException
-
ensureAttributesCapacity
protected void ensureAttributesCapacity(int size) Make sure that in attributes temporary array is enough space. -
ensureNamespacesCapacity
protected void ensureNamespacesCapacity(int size) -
ensureLocalNamespacesCapacity
protected void ensureLocalNamespacesCapacity(int size) -
getLocalNamespaceCount
public int getLocalNamespaceCount() -
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 ... -
ensureEntityCapacity
protected void ensureEntityCapacity() -
setFeature
Method setFeature- Parameters:
name- a Stringstate- a boolean- Throws:
XMLStreamException
-
getFeature
Unknown properties arealways returned as false -
setProperty
- Throws:
XMLStreamException
-
checkForXMLDecl
- Throws:
XMLStreamException
-
setInput
- Throws:
XMLStreamException
-
setInput
- Throws:
XMLStreamException
-
setInput
- Throws:
XMLStreamException
-
getInputEncoding
-
defineEntityReplacementText
public void defineEntityReplacementText(String entityName, String replacementText) throws XMLStreamException - Throws:
XMLStreamException
-
getNamespaceCount
public int getNamespaceCount()- Specified by:
getNamespaceCountin interfaceXMLStreamReader
-
getNamespaceCount
public int getNamespaceCount(int depth) -
getNamespacePrefix
- Specified by:
getNamespacePrefixin interfaceXMLStreamReader
-
getNamespaceURI
- Specified by:
getNamespaceURIin interfaceXMLStreamReader
-
getNamespaceURI
- Specified by:
getNamespaceURIin interfaceXMLStreamReader
-
getDepth
public int getDepth() -
getPositionDescription
Return string describing current position of parsers as text 'STATE [seen %s...] @line:column'. -
getLineNumber
public int getLineNumber()- Specified by:
getLineNumberin interfaceLocation
-
getColumnNumber
public int getColumnNumber()- Specified by:
getColumnNumberin interfaceLocation
-
getLocationURI
-
isWhiteSpace
public boolean isWhiteSpace()- Specified by:
isWhiteSpacein interfaceXMLStreamReader
-
getNamespaceURI
- Specified by:
getNamespaceURIin interfaceXMLStreamReader
-
getLocalName
- Specified by:
getLocalNamein interfaceXMLStreamReader
-
getPrefix
- Specified by:
getPrefixin interfaceXMLStreamReader
-
isEmptyElementTag
- Throws:
XMLStreamException
-
getAttributeCount
public int getAttributeCount()- Specified by:
getAttributeCountin interfaceXMLStreamReader
-
getAttributeNamespace
- Specified by:
getAttributeNamespacein interfaceXMLStreamReader
-
getAttributeLocalName
- Specified by:
getAttributeLocalNamein interfaceXMLStreamReader
-
getAttributePrefix
- Specified by:
getAttributePrefixin interfaceXMLStreamReader
-
getAttributeType
- Specified by:
getAttributeTypein interfaceXMLStreamReader
-
isAttributeSpecified
public boolean isAttributeSpecified(int index) - Specified by:
isAttributeSpecifiedin interfaceXMLStreamReader
-
getAttributeValue
- Specified by:
getAttributeValuein interfaceXMLStreamReader
-
getAttributeValue
- Specified by:
getAttributeValuein interfaceXMLStreamReader
-
getEventType
public int getEventType()- Specified by:
getEventTypein interfaceXMLStreamReader
-
require
- Specified by:
requirein interfaceXMLStreamReader- Throws:
XMLStreamException
-
nextText
- Throws:
XMLStreamException
-
nextTag
- Specified by:
nextTagin interfaceXMLStreamReader- Throws:
XMLStreamException
-
getElementText
- Specified by:
getElementTextin interfaceXMLStreamReader- Throws:
XMLStreamException
-
next
- Specified by:
nextin interfaceXMLStreamReader- Throws:
XMLStreamException
-
nextToken
- Throws:
XMLStreamException
-
nextElement
- Throws:
XMLStreamException
-
hasNext
- Specified by:
hasNextin interfaceXMLStreamReader- Throws:
XMLStreamException
-
skip
- Throws:
XMLStreamException
-
close
- Specified by:
closein interfaceXMLStreamReader- Throws:
XMLStreamException
-
isStartElement
public boolean isStartElement()- Specified by:
isStartElementin interfaceXMLStreamReader
-
isEndElement
public boolean isEndElement()- Specified by:
isEndElementin interfaceXMLStreamReader
-
isCharacters
public boolean isCharacters()- Specified by:
isCharactersin interfaceXMLStreamReader
-
isEOF
public boolean isEOF() -
moveToStartElement
- Throws:
XMLStreamException
-
moveToStartElement
- Throws:
XMLStreamException
-
moveToStartElement
- Throws:
XMLStreamException
-
moveToEndElement
- Throws:
XMLStreamException
-
moveToEndElement
- Throws:
XMLStreamException
-
moveToEndElement
- Throws:
XMLStreamException
-
hasAttributes
public boolean hasAttributes() -
hasNamespaces
public boolean hasNamespaces() -
getAttributes
-
internalGetNamespaces
-
getNamespaces
-
getOutOfScopeNamespaces
-
subReader
- Throws:
XMLStreamException
-
recycle
- Throws:
XMLStreamException
-
getTextStream
-
getText
- Specified by:
getTextin interfaceXMLStreamReader
-
getTextCharacters
public int getTextCharacters(int sourceStart, char[] target, int targetStart, int length) throws XMLStreamException - Specified by:
getTextCharactersin interfaceXMLStreamReader- Throws:
XMLStreamException
-
getTextCharacters
public char[] getTextCharacters()- Specified by:
getTextCharactersin interfaceXMLStreamReader
-
getTextStart
public int getTextStart()- Specified by:
getTextStartin interfaceXMLStreamReader
-
getTextLength
public int getTextLength()- Specified by:
getTextLengthin interfaceXMLStreamReader
-
hasText
public boolean hasText()- Specified by:
hasTextin interfaceXMLStreamReader
-
getValue
-
getEncoding
- Specified by:
getEncodingin interfaceXMLStreamReader
-
getCharacterOffset
public int getCharacterOffset()- Specified by:
getCharacterOffsetin interfaceLocation
-
getAttributeName
- Specified by:
getAttributeNamein interfaceXMLStreamReader
-
getName
- Specified by:
getNamein interfaceXMLStreamReader
-
hasName
public boolean hasName()- Specified by:
hasNamein interfaceXMLStreamReader
-
getVersion
- Specified by:
getVersionin interfaceXMLStreamReader
-
isStandalone
public boolean isStandalone()- Specified by:
isStandalonein interfaceXMLStreamReader
-
standaloneSet
public boolean standaloneSet()- Specified by:
standaloneSetin interfaceXMLStreamReader
-
getCharacterEncodingScheme
- Specified by:
getCharacterEncodingSchemein interfaceXMLStreamReader
-
nextImpl
- Throws:
XMLStreamException
-
parseProlog
- Throws:
XMLStreamException
-
parseEpilog
- Throws:
XMLStreamException
-
parseEndTag
- Throws:
XMLStreamException
-
parseStartTag
- Throws:
XMLStreamException
-
addDefaultAttributes
- Throws:
XMLStreamException
-
parseAttribute
- Throws:
XMLStreamException
-
parseEntityRef
- Returns:
- Character array that contains value the reference expands to.
- Throws:
XMLStreamException
-
lookupEntityReplacement
- Returns:
- Character array that contains (unparsed) entity expansion value; or null if no such entity has been declared
- Throws:
XMLStreamException
-
parseComment
- Throws:
XMLStreamException
-
getPITarget
- Specified by:
getPITargetin interfaceXMLStreamReader
-
getPIData
- Specified by:
getPIDatain interfaceXMLStreamReader
-
getNamespaceContext
- Specified by:
getNamespaceContextin interfaceXMLStreamReader
-
parsePI
- Returns:
- True if this was the xml declaration; false if a regular processing instruction
- Throws:
XMLStreamException
-
requireInput
- Throws:
XMLStreamException
-
requireNextS
- Throws:
XMLStreamException
-
skipS
- Throws:
XMLStreamException
-
parseXmlDecl
- Throws:
XMLStreamException
-
parseXmlDeclWithVersion
- Throws:
XMLStreamException
-
parseDocdecl
- Throws:
XMLStreamException
-
processDTD
- Throws:
XMLStreamException
-
parseCDATA
- Throws:
XMLStreamException
-
fillBuf
- Throws:
XMLStreamExceptionEOFException
-
more
- Throws:
XMLStreamExceptionEOFException
-
printable
-
printable
-
ensurePC
protected void ensurePC(int end) -
joinPC
protected void joinPC() -
getLocation
- Specified by:
getLocationin interfaceXMLStreamReader
-
getPublicId
- Specified by:
getPublicIdin interfaceLocation
-
getSystemId
- Specified by:
getSystemIdin interfaceLocation
-
setConfigurationContext
-
getConfigurationContext
-
getProperty
- Specified by:
getPropertyin interfaceXMLStreamReader
-