Class MXParser
java.lang.Object
org.codehaus.plexus.metadata.merge.MXParser
- All Implemented Interfaces:
org.codehaus.plexus.util.xml.pull.XmlPullParser
Absolutely minimal implementation of XMLPULL V1 API. Encoding handling done with XmlReader
- See Also:
-
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[]protected intprotected intprotected intprotected intprotected intprotected char[]protected intprotected intprotected String[]protected int[]protected String[]protected char[][]protected int[]protected int[]protected String[]protected booleanprotected intprotected String[]protected char[][]protected int[]protected Stringprotected String[]protected char[][]protected intprotected static final Stringprotected static final Stringprotected Stringprotected intprotected Stringprotected static final intprotected static final charprotected static boolean[]protected static boolean[]protected intprotected String[]protected int[]protected String[]protected static final char[]protected static final char[]protected booleanprotected char[]protected intprotected intprotected intprotected intprotected intprotected booleanprotected booleanprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected booleanprotected static final intprotected Readerprotected static final Stringprotected booleanprotected booleanprotected booleanprotected booleanprotected booleanprotected booleanprotected booleanprotected static final char[]protected Stringprotected booleanprivate static final booleanprotected booleanprotected static final char[]protected static final Stringprotected Stringprotected Booleanprotected Stringprotected static final Stringprotected static final char[]Fields inherited from interface org.codehaus.plexus.util.xml.pull.XmlPullParser
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddefineEntityReplacementText(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 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()private static intfindFragment(int bufMinPos, char[] b, int start, int end) intgetAttributeName(int index) getAttributeNamespace(int index) getAttributePrefix(int index) getAttributeType(int index) getAttributeValue(int index) getAttributeValue(String namespace, String name) intintgetDepth()intbooleangetFeature(String name) Unknown properties are always returned as falseintgetName()getNamespace(String prefix) intgetNamespaceCount(int depth) getNamespacePrefix(int pos) getNamespaceUri(int pos) Return string describing current position of parsers as text 'STATE [seen %s...] @line:column'.getProperty(String name) getText()char[]getTextCharacters(int[] holderForStartAndLength) booleanisAttributeDefault(int index) booleanprotected booleanisNameChar(char ch) protected booleanisNameStartChar(char ch) protected booleanisS(char ch) booleanprotected 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()nextText()intprotected charprotected voidparseCDSect(boolean hadCharData) protected voidprotected voidintprotected char[]protected intprotected booleanparsePI()protected intintprotected voidparseXmlDecl(char ch) protected voidparseXmlDeclWithVersion(int versionStart, int versionEnd) protected Stringprintable(char ch) protected Stringvoidprotected charrequireInput(char ch, char[] input) protected charprotected voidreset()protected voidvoidsetFeature(String name, boolean state) Method setFeaturevoidsetInput(InputStream inputStream, String inputEncoding) voidprivate static final voidsetName(char ch) private static final voidsetNameStart(char ch) voidsetProperty(String name, Object value) protected charskipS(char ch) voidSkip sub tree that is currently porser positioned on.
-
Field Details
-
XML_URI
- See Also:
-
XMLNS_URI
- See Also:
-
FEATURE_XML_ROUNDTRIP
- See Also:
-
FEATURE_NAMES_INTERNED
- See Also:
-
PROPERTY_XMLDECL_VERSION
- See Also:
-
PROPERTY_XMLDECL_STANDALONE
- See Also:
-
PROPERTY_XMLDECL_CONTENT
- See Also:
-
PROPERTY_LOCATION
- See Also:
-
REPORT_NAMESPACE_PREFIXES
- See Also:
-
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!
-
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
-
entityRefName
-
xmlDeclVersion
-
xmlDeclStandalone
-
xmlDeclContent
-
processNamespaces
protected boolean processNamespaces -
roundtripSupported
protected boolean roundtripSupported -
location
-
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 -
elRawNameLine
protected int[] elRawNameLine -
elName
-
elPrefix
-
elUri
-
elNamespaceCount
protected int[] elNamespaceCount -
READ_CHUNK_SIZE
protected static final int READ_CHUNK_SIZE- See Also:
-
reader
-
inputEncoding
-
bufLoadFactor
protected int bufLoadFactor -
buf
protected char[] buf -
bufSoftLimit
protected int bufSoftLimit -
preventBufferCompaction
protected boolean preventBufferCompaction -
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 -
TRACE_SIZING
private static final boolean TRACE_SIZING- See Also:
-
attributeCount
protected int attributeCount -
attributeName
-
attributeNameHash
protected int[] attributeNameHash -
attributePrefix
-
attributeUri
-
attributeValue
-
namespaceEnd
protected int namespaceEnd -
namespacePrefix
-
namespacePrefixHash
protected int[] namespacePrefixHash -
namespaceUri
-
entityEnd
protected int entityEnd -
entityName
-
entityNameBuf
protected char[][] entityNameBuf -
entityReplacement
-
entityReplacementBuf
protected char[][] entityReplacementBuf -
entityNameHash
protected int[] entityNameHash -
charRefOneCharBuf
protected char[] charRefOneCharBuf -
VERSION
protected static final char[] VERSION -
NCODING
protected static final char[] NCODING -
TANDALONE
protected static final char[] TANDALONE -
YES
protected static final char[] YES -
NO
protected static final char[] NO -
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
-
-
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 -
ensureAttributesCapacity
protected void ensureAttributesCapacity(int size) Make sure that in attributes temporary array is enough space.- Parameters:
size- The size.
-
ensureNamespacesCapacity
protected void ensureNamespacesCapacity(int size) -
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 ...- Parameters:
ch- The characters.off- The offset.len- The length.- Returns:
- the hash.
-
ensureEntityCapacity
protected void ensureEntityCapacity() -
reset
protected void reset() -
setFeature
public void setFeature(String name, boolean state) throws org.codehaus.plexus.util.xml.pull.XmlPullParserException Method setFeature- Specified by:
setFeaturein interfaceorg.codehaus.plexus.util.xml.pull.XmlPullParser- Parameters:
name- a Stringstate- a boolean- Throws:
org.codehaus.plexus.util.xml.pull.XmlPullParserException- in case of an error.
-
getFeature
Unknown properties are always returned as false- Specified by:
getFeaturein interfaceorg.codehaus.plexus.util.xml.pull.XmlPullParser
-
setProperty
public void setProperty(String name, Object value) throws org.codehaus.plexus.util.xml.pull.XmlPullParserException - Specified by:
setPropertyin interfaceorg.codehaus.plexus.util.xml.pull.XmlPullParser- Throws:
org.codehaus.plexus.util.xml.pull.XmlPullParserException
-
getProperty
- Specified by:
getPropertyin interfaceorg.codehaus.plexus.util.xml.pull.XmlPullParser
-
setInput
- Specified by:
setInputin interfaceorg.codehaus.plexus.util.xml.pull.XmlPullParser- Throws:
org.codehaus.plexus.util.xml.pull.XmlPullParserException
-
setInput
public void setInput(InputStream inputStream, String inputEncoding) throws org.codehaus.plexus.util.xml.pull.XmlPullParserException - Specified by:
setInputin interfaceorg.codehaus.plexus.util.xml.pull.XmlPullParser- Throws:
org.codehaus.plexus.util.xml.pull.XmlPullParserException
-
getInputEncoding
- Specified by:
getInputEncodingin interfaceorg.codehaus.plexus.util.xml.pull.XmlPullParser
-
defineEntityReplacementText
public void defineEntityReplacementText(String entityName, String replacementText) throws org.codehaus.plexus.util.xml.pull.XmlPullParserException - Specified by:
defineEntityReplacementTextin interfaceorg.codehaus.plexus.util.xml.pull.XmlPullParser- Throws:
org.codehaus.plexus.util.xml.pull.XmlPullParserException
-
getNamespaceCount
public int getNamespaceCount(int depth) throws org.codehaus.plexus.util.xml.pull.XmlPullParserException - Specified by:
getNamespaceCountin interfaceorg.codehaus.plexus.util.xml.pull.XmlPullParser- Throws:
org.codehaus.plexus.util.xml.pull.XmlPullParserException
-
getNamespacePrefix
public String getNamespacePrefix(int pos) throws org.codehaus.plexus.util.xml.pull.XmlPullParserException - Specified by:
getNamespacePrefixin interfaceorg.codehaus.plexus.util.xml.pull.XmlPullParser- Throws:
org.codehaus.plexus.util.xml.pull.XmlPullParserException
-
getNamespaceUri
public String getNamespaceUri(int pos) throws org.codehaus.plexus.util.xml.pull.XmlPullParserException - Specified by:
getNamespaceUriin interfaceorg.codehaus.plexus.util.xml.pull.XmlPullParser- Throws:
org.codehaus.plexus.util.xml.pull.XmlPullParserException
-
getNamespace
- Specified by:
getNamespacein interfaceorg.codehaus.plexus.util.xml.pull.XmlPullParser
-
getDepth
public int getDepth()- Specified by:
getDepthin interfaceorg.codehaus.plexus.util.xml.pull.XmlPullParser
-
findFragment
private static int findFragment(int bufMinPos, char[] b, int start, int end) -
getPositionDescription
Return string describing current position of parsers as text 'STATE [seen %s...] @line:column'.- Specified by:
getPositionDescriptionin interfaceorg.codehaus.plexus.util.xml.pull.XmlPullParser
-
getLineNumber
public int getLineNumber()- Specified by:
getLineNumberin interfaceorg.codehaus.plexus.util.xml.pull.XmlPullParser
-
getColumnNumber
public int getColumnNumber()- Specified by:
getColumnNumberin interfaceorg.codehaus.plexus.util.xml.pull.XmlPullParser
-
isWhitespace
public boolean isWhitespace() throws org.codehaus.plexus.util.xml.pull.XmlPullParserException- Specified by:
isWhitespacein interfaceorg.codehaus.plexus.util.xml.pull.XmlPullParser- Throws:
org.codehaus.plexus.util.xml.pull.XmlPullParserException
-
getText
- Specified by:
getTextin interfaceorg.codehaus.plexus.util.xml.pull.XmlPullParser
-
getTextCharacters
public char[] getTextCharacters(int[] holderForStartAndLength) - Specified by:
getTextCharactersin interfaceorg.codehaus.plexus.util.xml.pull.XmlPullParser
-
getNamespace
- Specified by:
getNamespacein interfaceorg.codehaus.plexus.util.xml.pull.XmlPullParser
-
getName
- Specified by:
getNamein interfaceorg.codehaus.plexus.util.xml.pull.XmlPullParser
-
getPrefix
- Specified by:
getPrefixin interfaceorg.codehaus.plexus.util.xml.pull.XmlPullParser
-
isEmptyElementTag
public boolean isEmptyElementTag() throws org.codehaus.plexus.util.xml.pull.XmlPullParserException- Specified by:
isEmptyElementTagin interfaceorg.codehaus.plexus.util.xml.pull.XmlPullParser- Throws:
org.codehaus.plexus.util.xml.pull.XmlPullParserException
-
getAttributeCount
public int getAttributeCount()- Specified by:
getAttributeCountin interfaceorg.codehaus.plexus.util.xml.pull.XmlPullParser
-
getAttributeNamespace
- Specified by:
getAttributeNamespacein interfaceorg.codehaus.plexus.util.xml.pull.XmlPullParser
-
getAttributeName
- Specified by:
getAttributeNamein interfaceorg.codehaus.plexus.util.xml.pull.XmlPullParser
-
getAttributePrefix
- Specified by:
getAttributePrefixin interfaceorg.codehaus.plexus.util.xml.pull.XmlPullParser
-
getAttributeType
- Specified by:
getAttributeTypein interfaceorg.codehaus.plexus.util.xml.pull.XmlPullParser
-
isAttributeDefault
public boolean isAttributeDefault(int index) - Specified by:
isAttributeDefaultin interfaceorg.codehaus.plexus.util.xml.pull.XmlPullParser
-
getAttributeValue
- Specified by:
getAttributeValuein interfaceorg.codehaus.plexus.util.xml.pull.XmlPullParser
-
getAttributeValue
- Specified by:
getAttributeValuein interfaceorg.codehaus.plexus.util.xml.pull.XmlPullParser
-
getEventType
public int getEventType() throws org.codehaus.plexus.util.xml.pull.XmlPullParserException- Specified by:
getEventTypein interfaceorg.codehaus.plexus.util.xml.pull.XmlPullParser- Throws:
org.codehaus.plexus.util.xml.pull.XmlPullParserException
-
require
public void require(int type, String namespace, String name) throws org.codehaus.plexus.util.xml.pull.XmlPullParserException, IOException - Specified by:
requirein interfaceorg.codehaus.plexus.util.xml.pull.XmlPullParser- Throws:
org.codehaus.plexus.util.xml.pull.XmlPullParserExceptionIOException
-
skipSubTree
public void skipSubTree() throws org.codehaus.plexus.util.xml.pull.XmlPullParserException, IOExceptionSkip 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
- Throws:
org.codehaus.plexus.util.xml.pull.XmlPullParserException- in case of an error.IOException- in case of an error.
-
nextText
public String nextText() throws org.codehaus.plexus.util.xml.pull.XmlPullParserException, IOException- Specified by:
nextTextin interfaceorg.codehaus.plexus.util.xml.pull.XmlPullParser- Throws:
org.codehaus.plexus.util.xml.pull.XmlPullParserExceptionIOException
-
nextTag
- Specified by:
nextTagin interfaceorg.codehaus.plexus.util.xml.pull.XmlPullParser- Throws:
org.codehaus.plexus.util.xml.pull.XmlPullParserExceptionIOException
-
next
- Specified by:
nextin interfaceorg.codehaus.plexus.util.xml.pull.XmlPullParser- Throws:
org.codehaus.plexus.util.xml.pull.XmlPullParserExceptionIOException
-
nextToken
- Specified by:
nextTokenin interfaceorg.codehaus.plexus.util.xml.pull.XmlPullParser- Throws:
org.codehaus.plexus.util.xml.pull.XmlPullParserExceptionIOException
-
nextImpl
protected int nextImpl() throws org.codehaus.plexus.util.xml.pull.XmlPullParserException, IOException- Throws:
org.codehaus.plexus.util.xml.pull.XmlPullParserExceptionIOException
-
parseProlog
protected int parseProlog() throws org.codehaus.plexus.util.xml.pull.XmlPullParserException, IOException- Throws:
org.codehaus.plexus.util.xml.pull.XmlPullParserExceptionIOException
-
parseEpilog
protected int parseEpilog() throws org.codehaus.plexus.util.xml.pull.XmlPullParserException, IOException- Throws:
org.codehaus.plexus.util.xml.pull.XmlPullParserExceptionIOException
-
parseEndTag
public int parseEndTag() throws org.codehaus.plexus.util.xml.pull.XmlPullParserException, IOException- Throws:
org.codehaus.plexus.util.xml.pull.XmlPullParserExceptionIOException
-
parseStartTag
public int parseStartTag() throws org.codehaus.plexus.util.xml.pull.XmlPullParserException, IOException- Throws:
org.codehaus.plexus.util.xml.pull.XmlPullParserExceptionIOException
-
parseAttribute
protected char parseAttribute() throws org.codehaus.plexus.util.xml.pull.XmlPullParserException, IOException- Throws:
org.codehaus.plexus.util.xml.pull.XmlPullParserExceptionIOException
-
parseEntityRef
protected char[] parseEntityRef() throws org.codehaus.plexus.util.xml.pull.XmlPullParserException, IOException- Throws:
org.codehaus.plexus.util.xml.pull.XmlPullParserExceptionIOException
-
lookuEntityReplacement
protected char[] lookuEntityReplacement(int entitNameLen) throws org.codehaus.plexus.util.xml.pull.XmlPullParserException, IOException - Throws:
org.codehaus.plexus.util.xml.pull.XmlPullParserExceptionIOException
-
parseComment
protected void parseComment() throws org.codehaus.plexus.util.xml.pull.XmlPullParserException, IOException- Throws:
org.codehaus.plexus.util.xml.pull.XmlPullParserExceptionIOException
-
parsePI
protected boolean parsePI() throws org.codehaus.plexus.util.xml.pull.XmlPullParserException, IOException- Throws:
org.codehaus.plexus.util.xml.pull.XmlPullParserExceptionIOException
-
parseXmlDecl
protected void parseXmlDecl(char ch) throws org.codehaus.plexus.util.xml.pull.XmlPullParserException, IOException - Throws:
org.codehaus.plexus.util.xml.pull.XmlPullParserExceptionIOException
-
parseXmlDeclWithVersion
protected void parseXmlDeclWithVersion(int versionStart, int versionEnd) throws org.codehaus.plexus.util.xml.pull.XmlPullParserException, IOException - Throws:
org.codehaus.plexus.util.xml.pull.XmlPullParserExceptionIOException
-
parseDocdecl
protected void parseDocdecl() throws org.codehaus.plexus.util.xml.pull.XmlPullParserException, IOException- Throws:
org.codehaus.plexus.util.xml.pull.XmlPullParserExceptionIOException
-
parseCDSect
protected void parseCDSect(boolean hadCharData) throws org.codehaus.plexus.util.xml.pull.XmlPullParserException, IOException - Throws:
org.codehaus.plexus.util.xml.pull.XmlPullParserExceptionIOException
-
fillBuf
protected void fillBuf() throws IOException, org.codehaus.plexus.util.xml.pull.XmlPullParserException- Throws:
IOExceptionorg.codehaus.plexus.util.xml.pull.XmlPullParserException
-
more
- Throws:
IOExceptionorg.codehaus.plexus.util.xml.pull.XmlPullParserException
-
ensurePC
protected void ensurePC(int end) -
joinPC
protected void joinPC() -
requireInput
protected char requireInput(char ch, char[] input) throws org.codehaus.plexus.util.xml.pull.XmlPullParserException, IOException - Throws:
org.codehaus.plexus.util.xml.pull.XmlPullParserExceptionIOException
-
requireNextS
protected char requireNextS() throws org.codehaus.plexus.util.xml.pull.XmlPullParserException, IOException- Throws:
org.codehaus.plexus.util.xml.pull.XmlPullParserExceptionIOException
-
skipS
protected char skipS(char ch) throws org.codehaus.plexus.util.xml.pull.XmlPullParserException, IOException - Throws:
org.codehaus.plexus.util.xml.pull.XmlPullParserExceptionIOException
-
setName
private static final void setName(char ch) -
setNameStart
private static final void setNameStart(char ch) -
isNameStartChar
protected boolean isNameStartChar(char ch) -
isNameChar
protected boolean isNameChar(char ch) -
isS
protected boolean isS(char ch) -
printable
-
printable
-