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 boolean
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[]
Logics for this should be clarified...protected int
protected int
protected int
protected int
protected int
protected static final char
protected String
protected 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 int
protected HashMap
protected int
protected String[]
protected int[]
protected String[]
protected char[][]
protected int[]
protected String[]
protected boolean
protected static final char[]
protected int
protected String[]
protected char[][]
protected int[]
protected String
protected String[]
protected char[][]
protected char[]
Replacement value for the current entity, when automatic entity expansion is disabled.protected int
protected static final String
static final String
static final String
static final String
static final String
protected static final String
protected String
protected int
protected int
protected String[]
protected int[]
protected String[]
protected static final int
protected static final char
protected static boolean[]
protected static boolean[]
protected static final int
protected com.wutka.dtd.DTD
If 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 int
protected String[]
protected int[]
protected String[]
protected static final char[]
static final String
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).protected boolean
protected char[]
protected int
protected int
protected String
protected String
protected int
protected int
protected int
protected boolean
protected boolean
protected static final int
protected Reader
protected boolean
protected boolean
protected boolean
protected boolean
protected boolean
protected boolean
protected boolean
protected boolean
Flag that indicates whether 'standalone="yes"' was found from the xml declaration.protected static final char[]
protected boolean
protected String
Lazily-constructed String that contains what getText() returns; cleared by tokenizer before parsing new eventsprotected boolean
static final String[]
These constants are used for diagnostics messages, and need to match with ones fromXMLStreamConstants
.protected boolean
protected static final char[]
protected String
XML 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 void
addDefaultAttributes
(String elementName) protected void
checkCharValidity
(int ch, boolean surrogatesOk) boolean
void
close()
void
defineEntityReplacementText
(String entityName, String replacementText) protected void
ensureAttributesCapacity
(int size) Make sure that in attributes temporary array is enough space.protected void
Make sure that we have enough space to keep element stack if passed size.protected void
protected void
ensureLocalNamespacesCapacity
(int size) protected void
ensureNamespacesCapacity
(int size) 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
fillBuf()
int
getAttributeLocalName
(int index) getAttributeName
(int index) getAttributeNamespace
(int index) getAttributePrefix
(int index) getAttributeType
(int index) getAttributeValue
(int index) getAttributeValue
(String namespace, String name) int
int
int
getDepth()
int
boolean
getFeature
(String name) Unknown properties arealways returned as false int
int
getName()
int
int
getNamespaceCount
(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[]
int
getTextCharacters
(int sourceStart, char[] target, int targetStart, int length) int
int
getValue()
boolean
boolean
hasName()
boolean
boolean
hasNext()
boolean
hasText()
internalGetNamespaces
(int depth, int namespaceCount) boolean
isAttributeSpecified
(int index) boolean
boolean
boolean
boolean
isEOF()
protected boolean
isNameChar
(char ch) protected boolean
isNameStartChar
(char ch) protected boolean
isS
(char ch) boolean
boolean
boolean
protected void
joinPC()
protected char[]
lookupEntityReplacement
(int entitNameLen) protected char
more()
boolean
boolean
moveToEndElement
(String localName) boolean
moveToEndElement
(String localName, String namespaceUri) boolean
boolean
moveToStartElement
(String localName) boolean
moveToStartElement
(String localName, String namespaceUri) protected String
newString
(char[] cbuf, int off, int len) protected String
newStringIntern
(char[] cbuf, int off, int len) int
next()
int
protected int
nextImpl()
int
nextTag()
nextText()
int
protected char
protected void
protected void
protected void
int
protected char[]
parseEntityRef
(boolean replace) protected int
protected boolean
parsePI()
protected int
int
protected void
parseXmlDecl
(char ch) protected void
parseXmlDeclWithVersion
(int versionStart, int versionEnd) protected String
printable
(char ch) protected String
protected void
void
recycle()
void
protected char
requireInput
(char ch, char[] input) protected char
protected void
void
void
setFeature
(String name, boolean state) Method setFeaturevoid
setInput
(InputStream in) void
setInput
(InputStream inputStream, String inputEncoding) void
void
setProperty
(String name, Object value) void
skip()
protected char
skipS
(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:
getNamespaceCount
in interfaceXMLStreamReader
-
getNamespaceCount
public int getNamespaceCount(int depth) -
getNamespacePrefix
- Specified by:
getNamespacePrefix
in interfaceXMLStreamReader
-
getNamespaceURI
- Specified by:
getNamespaceURI
in interfaceXMLStreamReader
-
getNamespaceURI
- Specified by:
getNamespaceURI
in 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:
getLineNumber
in interfaceLocation
-
getColumnNumber
public int getColumnNumber()- Specified by:
getColumnNumber
in interfaceLocation
-
getLocationURI
-
isWhiteSpace
public boolean isWhiteSpace()- Specified by:
isWhiteSpace
in interfaceXMLStreamReader
-
getNamespaceURI
- Specified by:
getNamespaceURI
in interfaceXMLStreamReader
-
getLocalName
- Specified by:
getLocalName
in interfaceXMLStreamReader
-
getPrefix
- Specified by:
getPrefix
in interfaceXMLStreamReader
-
isEmptyElementTag
- Throws:
XMLStreamException
-
getAttributeCount
public int getAttributeCount()- Specified by:
getAttributeCount
in interfaceXMLStreamReader
-
getAttributeNamespace
- Specified by:
getAttributeNamespace
in interfaceXMLStreamReader
-
getAttributeLocalName
- Specified by:
getAttributeLocalName
in interfaceXMLStreamReader
-
getAttributePrefix
- Specified by:
getAttributePrefix
in interfaceXMLStreamReader
-
getAttributeType
- Specified by:
getAttributeType
in interfaceXMLStreamReader
-
isAttributeSpecified
public boolean isAttributeSpecified(int index) - Specified by:
isAttributeSpecified
in interfaceXMLStreamReader
-
getAttributeValue
- Specified by:
getAttributeValue
in interfaceXMLStreamReader
-
getAttributeValue
- Specified by:
getAttributeValue
in interfaceXMLStreamReader
-
getEventType
public int getEventType()- Specified by:
getEventType
in interfaceXMLStreamReader
-
require
- Specified by:
require
in interfaceXMLStreamReader
- Throws:
XMLStreamException
-
nextText
- Throws:
XMLStreamException
-
nextTag
- Specified by:
nextTag
in interfaceXMLStreamReader
- Throws:
XMLStreamException
-
getElementText
- Specified by:
getElementText
in interfaceXMLStreamReader
- Throws:
XMLStreamException
-
next
- Specified by:
next
in interfaceXMLStreamReader
- Throws:
XMLStreamException
-
nextToken
- Throws:
XMLStreamException
-
nextElement
- Throws:
XMLStreamException
-
hasNext
- Specified by:
hasNext
in interfaceXMLStreamReader
- Throws:
XMLStreamException
-
skip
- Throws:
XMLStreamException
-
close
- Specified by:
close
in interfaceXMLStreamReader
- Throws:
XMLStreamException
-
isStartElement
public boolean isStartElement()- Specified by:
isStartElement
in interfaceXMLStreamReader
-
isEndElement
public boolean isEndElement()- Specified by:
isEndElement
in interfaceXMLStreamReader
-
isCharacters
public boolean isCharacters()- Specified by:
isCharacters
in 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:
getText
in interfaceXMLStreamReader
-
getTextCharacters
public int getTextCharacters(int sourceStart, char[] target, int targetStart, int length) throws XMLStreamException - Specified by:
getTextCharacters
in interfaceXMLStreamReader
- Throws:
XMLStreamException
-
getTextCharacters
public char[] getTextCharacters()- Specified by:
getTextCharacters
in interfaceXMLStreamReader
-
getTextStart
public int getTextStart()- Specified by:
getTextStart
in interfaceXMLStreamReader
-
getTextLength
public int getTextLength()- Specified by:
getTextLength
in interfaceXMLStreamReader
-
hasText
public boolean hasText()- Specified by:
hasText
in interfaceXMLStreamReader
-
getValue
-
getEncoding
- Specified by:
getEncoding
in interfaceXMLStreamReader
-
getCharacterOffset
public int getCharacterOffset()- Specified by:
getCharacterOffset
in interfaceLocation
-
getAttributeName
- Specified by:
getAttributeName
in interfaceXMLStreamReader
-
getName
- Specified by:
getName
in interfaceXMLStreamReader
-
hasName
public boolean hasName()- Specified by:
hasName
in interfaceXMLStreamReader
-
getVersion
- Specified by:
getVersion
in interfaceXMLStreamReader
-
isStandalone
public boolean isStandalone()- Specified by:
isStandalone
in interfaceXMLStreamReader
-
standaloneSet
public boolean standaloneSet()- Specified by:
standaloneSet
in interfaceXMLStreamReader
-
getCharacterEncodingScheme
- Specified by:
getCharacterEncodingScheme
in 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:
getPITarget
in interfaceXMLStreamReader
-
getPIData
- Specified by:
getPIData
in interfaceXMLStreamReader
-
getNamespaceContext
- Specified by:
getNamespaceContext
in 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:
XMLStreamException
EOFException
-
more
- Throws:
XMLStreamException
EOFException
-
printable
-
printable
-
ensurePC
protected void ensurePC(int end) -
joinPC
protected void joinPC() -
getLocation
- Specified by:
getLocation
in interfaceXMLStreamReader
-
getPublicId
- Specified by:
getPublicId
in interfaceLocation
-
getSystemId
- Specified by:
getSystemId
in interfaceLocation
-
setConfigurationContext
-
getConfigurationContext
-
getProperty
- Specified by:
getProperty
in interfaceXMLStreamReader
-