public class MXParser
extends java.lang.Object
implements org.codehaus.plexus.util.xml.pull.XmlPullParser
XmlReader| Modifier and Type | Field and Description |
|---|---|
protected boolean |
allStringsInterned
Implementation notice:
the is instance variable that controls if newString() is interning.
|
protected int |
attributeCount |
protected java.lang.String[] |
attributeName |
protected int[] |
attributeNameHash |
protected java.lang.String[] |
attributePrefix |
protected java.lang.String[] |
attributeUri |
protected java.lang.String[] |
attributeValue |
protected char[] |
buf |
protected int |
bufAbsoluteStart |
protected int |
bufEnd |
protected int |
bufLoadFactor |
protected int |
bufSoftLimit |
protected int |
bufStart |
protected char[] |
charRefOneCharBuf |
protected int |
columnNumber |
protected int |
depth |
protected java.lang.String[] |
elName |
protected int[] |
elNamespaceCount |
protected java.lang.String[] |
elPrefix |
protected char[][] |
elRawName |
protected int[] |
elRawNameEnd |
protected int[] |
elRawNameLine |
protected java.lang.String[] |
elUri |
protected boolean |
emptyElementTag |
protected int |
entityEnd |
protected java.lang.String[] |
entityName |
protected char[][] |
entityNameBuf |
protected int[] |
entityNameHash |
protected java.lang.String |
entityRefName |
protected java.lang.String[] |
entityReplacement |
protected char[][] |
entityReplacementBuf |
protected int |
eventType |
protected static java.lang.String |
FEATURE_NAMES_INTERNED |
protected static java.lang.String |
FEATURE_XML_ROUNDTRIP |
protected java.lang.String |
inputEncoding |
protected int |
lineNumber |
protected java.lang.String |
location |
protected static int |
LOOKUP_MAX |
protected static char |
LOOKUP_MAX_CHAR |
protected static boolean[] |
lookupNameChar |
protected static boolean[] |
lookupNameStartChar |
protected int |
namespaceEnd |
protected java.lang.String[] |
namespacePrefix |
protected int[] |
namespacePrefixHash |
protected java.lang.String[] |
namespaceUri |
protected static char[] |
NCODING |
protected static char[] |
NO |
protected boolean |
pastEndTag |
protected char[] |
pc |
protected int |
pcEnd |
protected int |
pcStart |
protected int |
pos |
protected int |
posEnd |
protected int |
posStart |
protected boolean |
preventBufferCompaction |
protected boolean |
processNamespaces |
protected static java.lang.String |
PROPERTY_LOCATION |
protected static java.lang.String |
PROPERTY_XMLDECL_CONTENT |
protected static java.lang.String |
PROPERTY_XMLDECL_STANDALONE |
protected static java.lang.String |
PROPERTY_XMLDECL_VERSION |
protected boolean |
reachedEnd |
protected static int |
READ_CHUNK_SIZE |
protected java.io.Reader |
reader |
protected static java.lang.String |
REPORT_NAMESPACE_PREFIXES |
protected boolean |
roundtripSupported |
protected boolean |
seenAmpersand |
protected boolean |
seenDocdecl |
protected boolean |
seenEndTag |
protected boolean |
seenMarkup |
protected boolean |
seenRoot |
protected boolean |
seenStartTag |
protected static char[] |
TANDALONE |
protected java.lang.String |
text |
protected boolean |
tokenize |
private static boolean |
TRACE_SIZING |
protected boolean |
usePC |
protected static char[] |
VERSION |
protected static java.lang.String |
XML_URI |
protected java.lang.String |
xmlDeclContent |
protected java.lang.Boolean |
xmlDeclStandalone |
protected java.lang.String |
xmlDeclVersion |
protected static java.lang.String |
XMLNS_URI |
protected static char[] |
YES |
CDSECT, COMMENT, DOCDECL, END_DOCUMENT, END_TAG, ENTITY_REF, FEATURE_PROCESS_DOCDECL, FEATURE_PROCESS_NAMESPACES, FEATURE_REPORT_NAMESPACE_ATTRIBUTES, FEATURE_VALIDATION, IGNORABLE_WHITESPACE, NO_NAMESPACE, PROCESSING_INSTRUCTION, START_DOCUMENT, START_TAG, TEXT, TYPES| Constructor and Description |
|---|
MXParser() |
| Modifier and Type | Method and Description |
|---|---|
void |
defineEntityReplacementText(java.lang.String entityName,
java.lang.String replacementText) |
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 |
ensureEntityCapacity() |
protected void |
ensureNamespacesCapacity(int size) |
protected void |
ensurePC(int end) |
protected static 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() |
private static int |
findFragment(int bufMinPos,
char[] b,
int start,
int end) |
int |
getAttributeCount() |
java.lang.String |
getAttributeName(int index) |
java.lang.String |
getAttributeNamespace(int index) |
java.lang.String |
getAttributePrefix(int index) |
java.lang.String |
getAttributeType(int index) |
java.lang.String |
getAttributeValue(int index) |
java.lang.String |
getAttributeValue(java.lang.String namespace,
java.lang.String name) |
int |
getColumnNumber() |
int |
getDepth() |
int |
getEventType() |
boolean |
getFeature(java.lang.String name)
Unknown properties are
|
java.lang.String |
getInputEncoding() |
int |
getLineNumber() |
java.lang.String |
getName() |
java.lang.String |
getNamespace() |
java.lang.String |
getNamespace(java.lang.String prefix) |
int |
getNamespaceCount(int depth) |
java.lang.String |
getNamespacePrefix(int pos) |
java.lang.String |
getNamespaceUri(int pos) |
java.lang.String |
getPositionDescription()
Return string describing current position of parsers as
text 'STATE [seen %s...] @line:column'.
|
java.lang.String |
getPrefix() |
java.lang.Object |
getProperty(java.lang.String name) |
java.lang.String |
getText() |
char[] |
getTextCharacters(int[] holderForStartAndLength) |
boolean |
isAttributeDefault(int index) |
boolean |
isEmptyElementTag() |
protected boolean |
isNameChar(char ch) |
protected boolean |
isNameStartChar(char ch) |
protected boolean |
isS(char ch) |
boolean |
isWhitespace() |
protected void |
joinPC() |
protected char[] |
lookuEntityReplacement(int entitNameLen) |
protected char |
more() |
protected java.lang.String |
newString(char[] cbuf,
int off,
int len) |
protected java.lang.String |
newStringIntern(char[] cbuf,
int off,
int len) |
int |
next() |
protected int |
nextImpl() |
int |
nextTag() |
java.lang.String |
nextText() |
int |
nextToken() |
protected char |
parseAttribute() |
protected void |
parseCDSect(boolean hadCharData) |
protected void |
parseComment() |
protected void |
parseDocdecl() |
int |
parseEndTag() |
protected char[] |
parseEntityRef() |
protected int |
parseEpilog() |
protected boolean |
parsePI() |
protected int |
parseProlog() |
int |
parseStartTag() |
protected void |
parseXmlDecl(char ch) |
protected void |
parseXmlDeclWithVersion(int versionStart,
int versionEnd) |
protected java.lang.String |
printable(char ch) |
protected java.lang.String |
printable(java.lang.String s) |
void |
require(int type,
java.lang.String namespace,
java.lang.String name) |
protected char |
requireInput(char ch,
char[] input) |
protected char |
requireNextS() |
protected void |
reset() |
protected void |
resetStringCache() |
void |
setFeature(java.lang.String name,
boolean state)
Method setFeature
|
void |
setInput(java.io.InputStream inputStream,
java.lang.String inputEncoding) |
void |
setInput(java.io.Reader in) |
private static void |
setName(char ch) |
private static void |
setNameStart(char ch) |
void |
setProperty(java.lang.String name,
java.lang.Object value) |
protected char |
skipS(char ch) |
void |
skipSubTree()
Skip sub tree that is currently porser positioned on.
|
protected static final java.lang.String XML_URI
protected static final java.lang.String XMLNS_URI
protected static final java.lang.String FEATURE_XML_ROUNDTRIP
protected static final java.lang.String FEATURE_NAMES_INTERNED
protected static final java.lang.String PROPERTY_XMLDECL_VERSION
protected static final java.lang.String PROPERTY_XMLDECL_STANDALONE
protected static final java.lang.String PROPERTY_XMLDECL_CONTENT
protected static final java.lang.String PROPERTY_LOCATION
protected static final java.lang.String REPORT_NAMESPACE_PREFIXES
protected boolean allStringsInterned
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!
protected boolean usePC
protected boolean seenStartTag
protected boolean seenEndTag
protected boolean pastEndTag
protected boolean seenAmpersand
protected boolean seenMarkup
protected boolean seenDocdecl
protected boolean tokenize
protected java.lang.String text
protected java.lang.String entityRefName
protected java.lang.String xmlDeclVersion
protected java.lang.Boolean xmlDeclStandalone
protected java.lang.String xmlDeclContent
protected boolean processNamespaces
protected boolean roundtripSupported
protected java.lang.String location
protected int lineNumber
protected int columnNumber
protected boolean seenRoot
protected boolean reachedEnd
protected int eventType
protected boolean emptyElementTag
protected int depth
protected char[][] elRawName
protected int[] elRawNameEnd
protected int[] elRawNameLine
protected java.lang.String[] elName
protected java.lang.String[] elPrefix
protected java.lang.String[] elUri
protected int[] elNamespaceCount
protected static final int READ_CHUNK_SIZE
protected java.io.Reader reader
protected java.lang.String inputEncoding
protected int bufLoadFactor
protected char[] buf
protected int bufSoftLimit
protected boolean preventBufferCompaction
protected int bufAbsoluteStart
protected int bufStart
protected int bufEnd
protected int pos
protected int posStart
protected int posEnd
protected char[] pc
protected int pcStart
protected int pcEnd
private static final boolean TRACE_SIZING
protected int attributeCount
protected java.lang.String[] attributeName
protected int[] attributeNameHash
protected java.lang.String[] attributePrefix
protected java.lang.String[] attributeUri
protected java.lang.String[] attributeValue
protected int namespaceEnd
protected java.lang.String[] namespacePrefix
protected int[] namespacePrefixHash
protected java.lang.String[] namespaceUri
protected int entityEnd
protected java.lang.String[] entityName
protected char[][] entityNameBuf
protected java.lang.String[] entityReplacement
protected char[][] entityReplacementBuf
protected int[] entityNameHash
protected char[] charRefOneCharBuf
protected static final char[] VERSION
protected static final char[] NCODING
protected static final char[] TANDALONE
protected static final char[] YES
protected static final char[] NO
protected static final int LOOKUP_MAX
protected static final char LOOKUP_MAX_CHAR
protected static boolean[] lookupNameStartChar
protected static boolean[] lookupNameChar
protected void resetStringCache()
protected java.lang.String newString(char[] cbuf,
int off,
int len)
protected java.lang.String newStringIntern(char[] cbuf,
int off,
int len)
protected void ensureElementsCapacity()
protected void ensureAttributesCapacity(int size)
protected void ensureNamespacesCapacity(int size)
protected static final int fastHash(char[] ch,
int off,
int len)
protected void ensureEntityCapacity()
protected void reset()
public void setFeature(java.lang.String name,
boolean state)
throws org.codehaus.plexus.util.xml.pull.XmlPullParserException
setFeature in interface org.codehaus.plexus.util.xml.pull.XmlPullParsername - a Stringstate - a booleanorg.codehaus.plexus.util.xml.pull.XmlPullParserExceptionpublic boolean getFeature(java.lang.String name)
getFeature in interface org.codehaus.plexus.util.xml.pull.XmlPullParserpublic void setProperty(java.lang.String name,
java.lang.Object value)
throws org.codehaus.plexus.util.xml.pull.XmlPullParserException
setProperty in interface org.codehaus.plexus.util.xml.pull.XmlPullParserorg.codehaus.plexus.util.xml.pull.XmlPullParserExceptionpublic java.lang.Object getProperty(java.lang.String name)
getProperty in interface org.codehaus.plexus.util.xml.pull.XmlPullParserpublic void setInput(java.io.Reader in)
throws org.codehaus.plexus.util.xml.pull.XmlPullParserException
setInput in interface org.codehaus.plexus.util.xml.pull.XmlPullParserorg.codehaus.plexus.util.xml.pull.XmlPullParserExceptionpublic void setInput(java.io.InputStream inputStream,
java.lang.String inputEncoding)
throws org.codehaus.plexus.util.xml.pull.XmlPullParserException
setInput in interface org.codehaus.plexus.util.xml.pull.XmlPullParserorg.codehaus.plexus.util.xml.pull.XmlPullParserExceptionpublic java.lang.String getInputEncoding()
getInputEncoding in interface org.codehaus.plexus.util.xml.pull.XmlPullParserpublic void defineEntityReplacementText(java.lang.String entityName,
java.lang.String replacementText)
throws org.codehaus.plexus.util.xml.pull.XmlPullParserException
defineEntityReplacementText in interface org.codehaus.plexus.util.xml.pull.XmlPullParserorg.codehaus.plexus.util.xml.pull.XmlPullParserExceptionpublic int getNamespaceCount(int depth)
throws org.codehaus.plexus.util.xml.pull.XmlPullParserException
getNamespaceCount in interface org.codehaus.plexus.util.xml.pull.XmlPullParserorg.codehaus.plexus.util.xml.pull.XmlPullParserExceptionpublic java.lang.String getNamespacePrefix(int pos)
throws org.codehaus.plexus.util.xml.pull.XmlPullParserException
getNamespacePrefix in interface org.codehaus.plexus.util.xml.pull.XmlPullParserorg.codehaus.plexus.util.xml.pull.XmlPullParserExceptionpublic java.lang.String getNamespaceUri(int pos)
throws org.codehaus.plexus.util.xml.pull.XmlPullParserException
getNamespaceUri in interface org.codehaus.plexus.util.xml.pull.XmlPullParserorg.codehaus.plexus.util.xml.pull.XmlPullParserExceptionpublic java.lang.String getNamespace(java.lang.String prefix)
getNamespace in interface org.codehaus.plexus.util.xml.pull.XmlPullParserpublic int getDepth()
getDepth in interface org.codehaus.plexus.util.xml.pull.XmlPullParserprivate static int findFragment(int bufMinPos,
char[] b,
int start,
int end)
public java.lang.String getPositionDescription()
getPositionDescription in interface org.codehaus.plexus.util.xml.pull.XmlPullParserpublic int getLineNumber()
getLineNumber in interface org.codehaus.plexus.util.xml.pull.XmlPullParserpublic int getColumnNumber()
getColumnNumber in interface org.codehaus.plexus.util.xml.pull.XmlPullParserpublic boolean isWhitespace()
throws org.codehaus.plexus.util.xml.pull.XmlPullParserException
isWhitespace in interface org.codehaus.plexus.util.xml.pull.XmlPullParserorg.codehaus.plexus.util.xml.pull.XmlPullParserExceptionpublic java.lang.String getText()
getText in interface org.codehaus.plexus.util.xml.pull.XmlPullParserpublic char[] getTextCharacters(int[] holderForStartAndLength)
getTextCharacters in interface org.codehaus.plexus.util.xml.pull.XmlPullParserpublic java.lang.String getNamespace()
getNamespace in interface org.codehaus.plexus.util.xml.pull.XmlPullParserpublic java.lang.String getName()
getName in interface org.codehaus.plexus.util.xml.pull.XmlPullParserpublic java.lang.String getPrefix()
getPrefix in interface org.codehaus.plexus.util.xml.pull.XmlPullParserpublic boolean isEmptyElementTag()
throws org.codehaus.plexus.util.xml.pull.XmlPullParserException
isEmptyElementTag in interface org.codehaus.plexus.util.xml.pull.XmlPullParserorg.codehaus.plexus.util.xml.pull.XmlPullParserExceptionpublic int getAttributeCount()
getAttributeCount in interface org.codehaus.plexus.util.xml.pull.XmlPullParserpublic java.lang.String getAttributeNamespace(int index)
getAttributeNamespace in interface org.codehaus.plexus.util.xml.pull.XmlPullParserpublic java.lang.String getAttributeName(int index)
getAttributeName in interface org.codehaus.plexus.util.xml.pull.XmlPullParserpublic java.lang.String getAttributePrefix(int index)
getAttributePrefix in interface org.codehaus.plexus.util.xml.pull.XmlPullParserpublic java.lang.String getAttributeType(int index)
getAttributeType in interface org.codehaus.plexus.util.xml.pull.XmlPullParserpublic boolean isAttributeDefault(int index)
isAttributeDefault in interface org.codehaus.plexus.util.xml.pull.XmlPullParserpublic java.lang.String getAttributeValue(int index)
getAttributeValue in interface org.codehaus.plexus.util.xml.pull.XmlPullParserpublic java.lang.String getAttributeValue(java.lang.String namespace,
java.lang.String name)
getAttributeValue in interface org.codehaus.plexus.util.xml.pull.XmlPullParserpublic int getEventType()
throws org.codehaus.plexus.util.xml.pull.XmlPullParserException
getEventType in interface org.codehaus.plexus.util.xml.pull.XmlPullParserorg.codehaus.plexus.util.xml.pull.XmlPullParserExceptionpublic void require(int type,
java.lang.String namespace,
java.lang.String name)
throws org.codehaus.plexus.util.xml.pull.XmlPullParserException,
java.io.IOException
require in interface org.codehaus.plexus.util.xml.pull.XmlPullParserorg.codehaus.plexus.util.xml.pull.XmlPullParserExceptionjava.io.IOExceptionpublic void skipSubTree()
throws org.codehaus.plexus.util.xml.pull.XmlPullParserException,
java.io.IOException
org.codehaus.plexus.util.xml.pull.XmlPullParserExceptionjava.io.IOExceptionpublic java.lang.String nextText()
throws org.codehaus.plexus.util.xml.pull.XmlPullParserException,
java.io.IOException
nextText in interface org.codehaus.plexus.util.xml.pull.XmlPullParserorg.codehaus.plexus.util.xml.pull.XmlPullParserExceptionjava.io.IOExceptionpublic int nextTag()
throws org.codehaus.plexus.util.xml.pull.XmlPullParserException,
java.io.IOException
nextTag in interface org.codehaus.plexus.util.xml.pull.XmlPullParserorg.codehaus.plexus.util.xml.pull.XmlPullParserExceptionjava.io.IOExceptionpublic int next()
throws org.codehaus.plexus.util.xml.pull.XmlPullParserException,
java.io.IOException
next in interface org.codehaus.plexus.util.xml.pull.XmlPullParserorg.codehaus.plexus.util.xml.pull.XmlPullParserExceptionjava.io.IOExceptionpublic int nextToken()
throws org.codehaus.plexus.util.xml.pull.XmlPullParserException,
java.io.IOException
nextToken in interface org.codehaus.plexus.util.xml.pull.XmlPullParserorg.codehaus.plexus.util.xml.pull.XmlPullParserExceptionjava.io.IOExceptionprotected int nextImpl()
throws org.codehaus.plexus.util.xml.pull.XmlPullParserException,
java.io.IOException
org.codehaus.plexus.util.xml.pull.XmlPullParserExceptionjava.io.IOExceptionprotected int parseProlog()
throws org.codehaus.plexus.util.xml.pull.XmlPullParserException,
java.io.IOException
org.codehaus.plexus.util.xml.pull.XmlPullParserExceptionjava.io.IOExceptionprotected int parseEpilog()
throws org.codehaus.plexus.util.xml.pull.XmlPullParserException,
java.io.IOException
org.codehaus.plexus.util.xml.pull.XmlPullParserExceptionjava.io.IOExceptionpublic int parseEndTag()
throws org.codehaus.plexus.util.xml.pull.XmlPullParserException,
java.io.IOException
org.codehaus.plexus.util.xml.pull.XmlPullParserExceptionjava.io.IOExceptionpublic int parseStartTag()
throws org.codehaus.plexus.util.xml.pull.XmlPullParserException,
java.io.IOException
org.codehaus.plexus.util.xml.pull.XmlPullParserExceptionjava.io.IOExceptionprotected char parseAttribute()
throws org.codehaus.plexus.util.xml.pull.XmlPullParserException,
java.io.IOException
org.codehaus.plexus.util.xml.pull.XmlPullParserExceptionjava.io.IOExceptionprotected char[] parseEntityRef()
throws org.codehaus.plexus.util.xml.pull.XmlPullParserException,
java.io.IOException
org.codehaus.plexus.util.xml.pull.XmlPullParserExceptionjava.io.IOExceptionprotected char[] lookuEntityReplacement(int entitNameLen)
throws org.codehaus.plexus.util.xml.pull.XmlPullParserException,
java.io.IOException
org.codehaus.plexus.util.xml.pull.XmlPullParserExceptionjava.io.IOExceptionprotected void parseComment()
throws org.codehaus.plexus.util.xml.pull.XmlPullParserException,
java.io.IOException
org.codehaus.plexus.util.xml.pull.XmlPullParserExceptionjava.io.IOExceptionprotected boolean parsePI()
throws org.codehaus.plexus.util.xml.pull.XmlPullParserException,
java.io.IOException
org.codehaus.plexus.util.xml.pull.XmlPullParserExceptionjava.io.IOExceptionprotected void parseXmlDecl(char ch)
throws org.codehaus.plexus.util.xml.pull.XmlPullParserException,
java.io.IOException
org.codehaus.plexus.util.xml.pull.XmlPullParserExceptionjava.io.IOExceptionprotected void parseXmlDeclWithVersion(int versionStart,
int versionEnd)
throws org.codehaus.plexus.util.xml.pull.XmlPullParserException,
java.io.IOException
org.codehaus.plexus.util.xml.pull.XmlPullParserExceptionjava.io.IOExceptionprotected void parseDocdecl()
throws org.codehaus.plexus.util.xml.pull.XmlPullParserException,
java.io.IOException
org.codehaus.plexus.util.xml.pull.XmlPullParserExceptionjava.io.IOExceptionprotected void parseCDSect(boolean hadCharData)
throws org.codehaus.plexus.util.xml.pull.XmlPullParserException,
java.io.IOException
org.codehaus.plexus.util.xml.pull.XmlPullParserExceptionjava.io.IOExceptionprotected void fillBuf()
throws java.io.IOException,
org.codehaus.plexus.util.xml.pull.XmlPullParserException
java.io.IOExceptionorg.codehaus.plexus.util.xml.pull.XmlPullParserExceptionprotected char more()
throws java.io.IOException,
org.codehaus.plexus.util.xml.pull.XmlPullParserException
java.io.IOExceptionorg.codehaus.plexus.util.xml.pull.XmlPullParserExceptionprotected void ensurePC(int end)
protected void joinPC()
protected char requireInput(char ch,
char[] input)
throws org.codehaus.plexus.util.xml.pull.XmlPullParserException,
java.io.IOException
org.codehaus.plexus.util.xml.pull.XmlPullParserExceptionjava.io.IOExceptionprotected char requireNextS()
throws org.codehaus.plexus.util.xml.pull.XmlPullParserException,
java.io.IOException
org.codehaus.plexus.util.xml.pull.XmlPullParserExceptionjava.io.IOExceptionprotected char skipS(char ch)
throws org.codehaus.plexus.util.xml.pull.XmlPullParserException,
java.io.IOException
org.codehaus.plexus.util.xml.pull.XmlPullParserExceptionjava.io.IOExceptionprivate static final void setName(char ch)
private static final void setNameStart(char ch)
protected boolean isNameStartChar(char ch)
protected boolean isNameChar(char ch)
protected boolean isS(char ch)
protected java.lang.String printable(char ch)
protected java.lang.String printable(java.lang.String s)