com.bea.xml.stream
Class MXParser

java.lang.Object
  extended bycom.bea.xml.stream.MXParser
All Implemented Interfaces:
Location, XMLStreamConstants, XMLStreamReader

public class MXParser
extends Object
implements XMLStreamReader, Location


Field Summary
protected  boolean allStringsInterned
          Implementation notice: the is instance variable that controls if newString() is interning.
protected  int attributeCount
           
protected  String[] attributeName
           
protected  int[] attributeNameHash
           
protected  String[] attributePrefix
           
protected  String[] attributeUri
           
protected  String[] attributeValue
           
protected  char[] buf
           
protected  int bufAbsoluteStart
           
protected  int bufEnd
           
protected  int bufLoadFactor
           
protected  int bufSoftLimit
           
protected  int bufStart
           
protected  String charEncodingScheme
           
protected  char[] charRefOneCharBuf
           
protected  int columnNumber
           
protected  HashMap defaultAttributes
           
protected  int depth
           
protected  String[] elName
           
protected  int[] elNamespaceCount
           
protected  String[] elPrefix
           
protected  char[][] elRawName
           
protected  int[] elRawNameEnd
           
protected  String[] elUri
           
protected  boolean emptyElementTag
           
protected static char[] ENCODING
           
protected  int entityEnd
           
protected  String[] entityName
           
protected  char[][] entityNameBuf
           
protected  int[] entityNameHash
           
protected  String entityRefName
           
protected  String[] entityReplacement
           
protected  char[][] entityReplacementBuf
           
protected  int eventType
           
protected static String FEATURE_NAMES_INTERNED
           
static String FEATURE_PROCESS_DOCDECL
           
static String FEATURE_PROCESS_NAMESPACES
           
protected static String FEATURE_XML_ROUNDTRIP
           
protected  String inputEncoding
           
protected  int lineNumber
           
protected  int localNamespaceEnd
           
protected  String[] localNamespacePrefix
           
protected  int[] localNamespacePrefixHash
           
protected  String[] localNamespaceUri
           
protected static int LOOKUP_MAX
           
protected static char LOOKUP_MAX_CHAR
           
protected static boolean[] lookupNameChar
           
protected static boolean[] lookupNameStartChar
           
protected  int namespaceEnd
           
protected  String[] namespacePrefix
           
protected  int[] namespacePrefixHash
           
protected  String[] namespaceUri
           
protected static char[] NO
           
static String NO_NAMESPACE
           
protected  boolean pastEndTag
           
protected  char[] pc
           
protected  int pcEnd
           
protected  int pcStart
           
protected  String piData
           
protected  String piTarget
           
protected  int pos
           
protected  int posEnd
           
protected  int posStart
           
protected  boolean processNamespaces
           
protected  boolean reachedEnd
           
protected static int READ_CHUNK_SIZE
           
protected  Reader reader
           
protected  boolean roundtripSupported
           
protected  boolean seenAmpersand
           
protected  boolean seenDocdecl
           
protected  boolean seenEndTag
           
protected  boolean seenMarkup
           
protected  boolean seenRoot
           
protected  boolean seenStartTag
           
protected  boolean standalone
           
protected static char[] STANDALONE
           
protected  boolean standaloneSet
           
protected  String text
           
protected  boolean tokenize
           
static String[] TYPES
           
protected  boolean usePC
           
protected static char[] VERSION
           
protected static String XML_URI
           
protected static String XMLNS_URI
           
protected  String xmlVersion
           
protected static char[] YES
           
 
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
MXParser()
           
 
Method Summary
protected  void addDefaultAttributes(String elementName)
           
 boolean checkForXMLDecl()
           
 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 ensureElementsCapacity()
          Make sure that we have enough space to keep element stack if passed size.
protected  void ensureEntityCapacity()
           
protected  void ensureLocalNamespacesCapacity(int size)
           
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()
           
 int getAttributeCount()
           
 String getAttributeLocalName(int index)
           
 QName getAttributeName(int index)
           
 String getAttributeNamespace(int index)
           
 String getAttributePrefix(int index)
           
 Iterator getAttributes()
           
 String getAttributeType(int index)
           
 String getAttributeValue(int index)
           
 String getAttributeValue(String namespace, String name)
           
 String getCharacterEncodingScheme()
           
 int getCharacterOffset()
           
 int getColumnNumber()
           
 ConfigurationContextBase getConfigurationContext()
           
 int getDepth()
           
 String getElementText()
           
 String getEncoding()
           
 int getEventType()
           
 boolean getFeature(String name)
          Unknown properties are always returned as false
 String getInputEncoding()
           
 int getLineNumber()
           
 String getLocalName()
           
 int getLocalNamespaceCount()
           
 Location getLocation()
           
 String getLocationURI()
           
 QName getName()
           
 NamespaceContext getNamespaceContext()
           
 int getNamespaceCount()
           
 int getNamespaceCount(int depth)
           
 String getNamespacePrefix(int pos)
           
 Iterator getNamespaces()
           
 String getNamespaceURI()
           
 String getNamespaceURI(int pos)
           
 String getNamespaceURI(String prefix)
           
 Iterator getOutOfScopeNamespaces()
           
 String getPIData()
           
 String getPITarget()
           
 String getPositionDescription()
          Return string describing current position of parsers as text 'STATE [seen %s...] @line:column'.
 String getPrefix()
           
 Object getProperty(String name)
           
 String getPublicId()
           
 String getSystemId()
           
 String getText()
           
 char[] getTextCharacters()
           
 int getTextCharacters(int sourceStart, char[] target, int targetStart, int length)
           
 int getTextLength()
           
 int getTextStart()
           
 Reader getTextStream()
           
 String getValue()
           
 String getVersion()
           
 boolean hasAttributes()
           
 boolean hasName()
           
 boolean hasNamespaces()
           
 boolean hasNext()
           
 boolean hasText()
           
 Iterator internalGetNamespaces(int depth, int namespaceCount)
           
 boolean isAttributeSpecified(int index)
           
 boolean isCharacters()
           
 boolean isEmptyElementTag()
           
 boolean isEndElement()
           
 boolean isEOF()
           
protected  boolean isNameChar(char ch)
           
protected  boolean isNameStartChar(char ch)
           
protected  boolean isS(char ch)
           
 boolean isStandalone()
           
 boolean isStartElement()
           
 boolean isWhiteSpace()
           
protected  void joinPC()
           
protected  char[] lookupEntityReplacement(int entitNameLen)
           
protected  char more()
           
 boolean moveToEndElement()
           
 boolean moveToEndElement(String localName)
           
 boolean moveToEndElement(String localName, String namespaceUri)
           
 boolean moveToStartElement()
           
 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 nextElement()
           
protected  int nextImpl()
           
 int nextTag()
           
 String nextText()
           
 int nextToken()
           
protected  char parseAttribute()
           
protected  void parseCDATA()
           
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  String printable(char ch)
           
protected  String printable(String s)
           
protected  void processDTD()
           
 void recycle()
           
 void require(int type, String namespace, String name)
           
protected  char requireInput(char ch, char[] input)
           
protected  char requireNextS()
           
protected  void resetStringCache()
           
 void setConfigurationContext(ConfigurationContextBase c)
           
 void setFeature(String name, boolean state)
          Method setFeature
 void setInput(InputStream in)
           
 void setInput(InputStream inputStream, String inputEncoding)
           
 void setInput(Reader in)
           
 void setProperty(String name, Object value)
           
 void skip()
           
protected  char skipS(char ch)
           
 boolean standaloneSet()
           
 XMLStreamReader subReader()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

XML_URI

protected static final String XML_URI
See Also:
Constant Field Values

XMLNS_URI

protected static final String XMLNS_URI
See Also:
Constant Field Values

FEATURE_XML_ROUNDTRIP

protected static final String FEATURE_XML_ROUNDTRIP
See Also:
Constant Field Values

FEATURE_NAMES_INTERNED

protected static final String FEATURE_NAMES_INTERNED
See Also:
Constant Field Values

FEATURE_PROCESS_DOCDECL

public static final String FEATURE_PROCESS_DOCDECL
See Also:
Constant Field Values

TYPES

public static final String[] TYPES

NO_NAMESPACE

public static final String NO_NAMESPACE
See Also:
Constant Field Values

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!


FEATURE_PROCESS_NAMESPACES

public static final String FEATURE_PROCESS_NAMESPACES
See Also:
Constant Field Values

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

protected String[] elName

elPrefix

protected String[] elPrefix

elUri

protected String[] elUri

elNamespaceCount

protected int[] elNamespaceCount

xmlVersion

protected String xmlVersion

standalone

protected boolean standalone

standaloneSet

protected boolean standaloneSet

charEncodingScheme

protected String charEncodingScheme

piTarget

protected String piTarget

piData

protected String piData

defaultAttributes

protected HashMap defaultAttributes

LOOKUP_MAX

protected static final int LOOKUP_MAX
See Also:
Constant Field Values

LOOKUP_MAX_CHAR

protected static final char LOOKUP_MAX_CHAR
See Also:
Constant Field Values

lookupNameStartChar

protected static boolean[] lookupNameStartChar

lookupNameChar

protected static boolean[] lookupNameChar

attributeCount

protected int attributeCount

attributeName

protected String[] attributeName

attributeNameHash

protected int[] attributeNameHash

attributePrefix

protected String[] attributePrefix

attributeUri

protected String[] attributeUri

attributeValue

protected String[] attributeValue

namespaceEnd

protected int namespaceEnd

namespacePrefix

protected String[] namespacePrefix

namespacePrefixHash

protected int[] namespacePrefixHash

namespaceUri

protected String[] namespaceUri

localNamespaceEnd

protected int localNamespaceEnd

localNamespacePrefix

protected String[] localNamespacePrefix

localNamespacePrefixHash

protected int[] localNamespacePrefixHash

localNamespaceUri

protected String[] localNamespaceUri

entityEnd

protected int entityEnd

entityName

protected String[] entityName

entityNameBuf

protected char[][] entityNameBuf

entityNameHash

protected int[] entityNameHash

entityReplacementBuf

protected char[][] entityReplacementBuf

entityReplacement

protected String[] entityReplacement

READ_CHUNK_SIZE

protected static final int READ_CHUNK_SIZE
See Also:
Constant Field Values

reader

protected Reader reader

inputEncoding

protected String inputEncoding

bufLoadFactor

protected int bufLoadFactor

buf

protected char[] buf

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

protected String text

entityRefName

protected String entityRefName

charRefOneCharBuf

protected char[] charRefOneCharBuf

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 Detail

MXParser

public MXParser()
Method Detail

resetStringCache

protected void resetStringCache()

newString

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

newStringIntern

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

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)

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

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

Parameters:
name - a String
state - a boolean
Throws:
XMLStreamException

getFeature

public boolean getFeature(String name)
Unknown properties are always returned as false


setProperty

public void setProperty(String name,
                        Object value)
                 throws XMLStreamException
Throws:
XMLStreamException

checkForXMLDecl

public boolean checkForXMLDecl()
                        throws XMLStreamException
Throws:
XMLStreamException

setInput

public void setInput(Reader in)
              throws XMLStreamException
Throws:
XMLStreamException

setInput

public void setInput(InputStream in)
              throws XMLStreamException
Throws:
XMLStreamException

setInput

public void setInput(InputStream inputStream,
                     String inputEncoding)
              throws XMLStreamException
Throws:
XMLStreamException

getInputEncoding

public String getInputEncoding()

defineEntityReplacementText

public void defineEntityReplacementText(String entityName,
                                        String replacementText)
                                 throws XMLStreamException
Throws:
XMLStreamException

getNamespaceCount

public int getNamespaceCount()
Specified by:
getNamespaceCount in interface XMLStreamReader

getNamespaceCount

public int getNamespaceCount(int depth)

getNamespacePrefix

public String getNamespacePrefix(int pos)
Specified by:
getNamespacePrefix in interface XMLStreamReader

getNamespaceURI

public String getNamespaceURI(int pos)
Specified by:
getNamespaceURI in interface XMLStreamReader

getNamespaceURI

public String getNamespaceURI(String prefix)
Specified by:
getNamespaceURI in interface XMLStreamReader

getDepth

public int getDepth()

getPositionDescription

public String getPositionDescription()
Return string describing current position of parsers as text 'STATE [seen %s...] @line:column'.


getLineNumber

public int getLineNumber()
Specified by:
getLineNumber in interface Location

getColumnNumber

public int getColumnNumber()
Specified by:
getColumnNumber in interface Location

getLocationURI

public String getLocationURI()

isWhiteSpace

public boolean isWhiteSpace()
Specified by: