public class XMLReaderImpl
extends java.lang.Object
implements javax.xml.stream.XMLStreamReader
Modifier and Type | Field and Description |
---|---|
protected static java.lang.String |
ENTITY_MANAGER
Property identifier: entity manager.
|
protected static java.lang.String |
ERROR_REPORTER
Property identifier: Error Reporter.
|
protected XMLEntityManager |
fEntityManager |
protected XMLEntityReaderImpl |
fEntityScanner
Entity scanner, this alwasy works on last entity that was opened.
|
protected StaxErrorReporter |
fErrorReporter |
protected org.apache.xerces.xni.parser.XMLInputSource |
fInputSource
Input Source
|
protected org.apache.xerces.util.NamespaceContextWrapper |
fNamespaceContextWrapper |
protected PropertyManager |
fPropertyManager
Store properties
|
protected XMLNSDocumentScannerImpl |
fScanner
Document scanner.
|
protected static java.lang.String |
SYMBOL_TABLE
Property identifier: Symbol table.
|
Constructor and Description |
---|
XMLReaderImpl(java.io.InputStream inputStream,
PropertyManager props) |
XMLReaderImpl(java.io.InputStream inputStream,
java.lang.String encoding,
PropertyManager props) |
XMLReaderImpl(java.io.Reader reader,
PropertyManager props) |
XMLReaderImpl(java.lang.String systemid,
PropertyManager props) |
XMLReaderImpl(org.apache.xerces.xni.parser.XMLInputSource inputSource,
PropertyManager props) |
Modifier and Type | Method and Description |
---|---|
boolean |
canReuse()
This function tells if this instances is available for reuse.
|
void |
close()
Frees any resources associated with this Reader.
|
javax.xml.namespace.QName |
convertXNIQNametoJavaxQName(org.apache.xerces.xni.QName qname) |
int |
getAttributeCount()
Returns the count of attributes on this START_ELEMENT,
this method is only valid on a START_ELEMENT or ATTRIBUTE.
|
java.lang.String |
getAttributeLocalName(int index) |
javax.xml.namespace.QName |
getAttributeName(int index)
Returns the localName of the attribute at the provided
index
|
java.lang.String |
getAttributeNamespace(int index)
Returns the namespace of the attribute at the provided
index
|
java.lang.String |
getAttributePrefix(int index)
Returns the prefix of this attribute at the
provided index
|
javax.xml.namespace.QName |
getAttributeQName(int index)
Returns the qname of the attribute at the provided index
|
java.lang.String |
getAttributeType(int index)
Returns the XML type of the attribute at the provided
index
|
java.lang.String |
getAttributeValue(int index)
Returns the value of the attribute at the
index
|
java.lang.String |
getAttributeValue(java.lang.String namespaceURI,
java.lang.String localName) |
java.lang.String |
getCharacterEncodingScheme()
Returns the character encoding declared on the xml declaration Returns null if none was declared
|
int |
getColumnNumber() |
java.lang.String |
getElementText()
Reads the content of a text-only element.
|
java.lang.String |
getEncoding()
Return input encoding if known or null if unknown.
|
protected java.util.List |
getEntityDecls() |
int |
getEventType()
Returns the current value of the parse event as a string, this returns the string value of a CHARACTERS event, returns the value of a COMMENT, the replacement value for an ENTITY_REFERENCE, the string value of a CDATA section, the string value for a SPACE event, or the String value of the internal subset of the DTD.
|
int |
getLineNumber() |
java.lang.String |
getLocalName() |
javax.xml.stream.Location |
getLocation()
Return the current location of the processor.
|
javax.xml.namespace.QName |
getName()
Returns a QName for the current START_ELEMENT or END_ELEMENT event
|
javax.xml.namespace.NamespaceContext |
getNamespaceContext()
Returns a read only namespace context for the current
position.
|
int |
getNamespaceCount()
Returns the count of namespaces declared on this START_ELEMENT or END_ELEMENT,
this method is only valid on a START_ELEMENT, END_ELEMENT or NAMESPACE.
|
java.lang.String |
getNamespacePrefix(int index)
Returns the prefix for the namespace declared at the
index.
|
java.lang.String |
getNamespaceURI() |
java.lang.String |
getNamespaceURI(int index)
Returns the uri for the namespace declared at the
index.
|
java.lang.String |
getNamespaceURI(java.lang.String prefix)
Return the uri for the given prefix.
|
protected java.util.List |
getNotationDecls() |
java.lang.String |
getPIData()
Get the data section of a processing instruction
|
java.lang.String |
getPITarget()
Get the target of a processing instruction
|
java.lang.String |
getPrefix()
Returns the prefix of the current event, or null if the event does
not have a prefix.
|
java.lang.Object |
getProperty(java.lang.String name)
Get the value of a feature/property from the underlying implementation
|
protected PropertyManager |
getPropertyManager() |
java.lang.String |
getText()
Returns the current value of the parse event as a string,
this returns the string value of a CHARACTERS event,
returns the value of a COMMENT, the replacement value
for an ENTITY_REFERENCE,
or the String value of the DTD
|
char[] |
getTextCharacters() |
int |
getTextCharacters(int sourceStart,
char[] target,
int targetStart,
int length)
Gets the the text associated with a CHARACTERS, SPACE or CDATA event.
|
int |
getTextLength() |
int |
getTextStart() |
java.lang.String |
getValue() |
java.lang.String |
getVersion()
Get the XML language version of the current document being parsed
|
boolean |
hasAttributes() |
boolean |
hasName()
this Funtion returns true if the current event has name
|
boolean |
hasNext() |
boolean |
hasText()
Return true if the current event has text, false otherwise
The following events have text:
CHARACTERS,DTD ,ENTITY_REFERENCE, COMMENT
|
boolean |
hasValue() |
boolean |
isAttributeSpecified(int index)
Returns a boolean which indicates if this
attribute was created by default
|
boolean |
isCharacters()
Returns true if the cursor points to a character data event
|
boolean |
isEndElement() |
boolean |
isStandalone() |
boolean |
isStartElement() |
boolean |
isWhiteSpace()
Returns true if the cursor points to a character data event that consists of all whitespace
Application calling this method needs to cache the value and avoid calling this method again
for the same event.
|
int |
next() |
int |
nextTag()
Skips any insignificant events (COMMENT and PROCESSING_INSTRUCTION)
until a START_ELEMENT or
END_ELEMENT is reached.
|
void |
require(int type,
java.lang.String namespaceURI,
java.lang.String localName)
Test if the current event is of the given type and if the namespace and name match the current namespace and name of the current event.
|
void |
reset()
Resets this instance so that this instance is ready for reuse.
|
void |
setInputSource(org.xml.sax.InputSource inputSource)
Set the InputSource on this instance.
|
void |
setInputSource(org.apache.xerces.xni.parser.XMLInputSource inputSource) |
protected void |
setPropertyManager(PropertyManager propertyManager) |
boolean |
standaloneSet()
Checks if standalone was set in the document
|
protected static final java.lang.String ENTITY_MANAGER
protected static final java.lang.String ERROR_REPORTER
protected static final java.lang.String SYMBOL_TABLE
protected XMLNSDocumentScannerImpl fScanner
protected org.apache.xerces.util.NamespaceContextWrapper fNamespaceContextWrapper
protected XMLEntityManager fEntityManager
protected StaxErrorReporter fErrorReporter
protected XMLEntityReaderImpl fEntityScanner
protected org.apache.xerces.xni.parser.XMLInputSource fInputSource
protected PropertyManager fPropertyManager
public XMLReaderImpl(java.io.InputStream inputStream, PropertyManager props) throws javax.xml.stream.XMLStreamException
inputStream
- props
- javax.xml.stream.XMLStreamException
public XMLReaderImpl(java.lang.String systemid, PropertyManager props) throws javax.xml.stream.XMLStreamException
systemid
- props
- javax.xml.stream.XMLStreamException
public XMLReaderImpl(java.io.InputStream inputStream, java.lang.String encoding, PropertyManager props) throws javax.xml.stream.XMLStreamException
inputStream
- encoding
- props
- javax.xml.stream.XMLStreamException
public XMLReaderImpl(java.io.Reader reader, PropertyManager props) throws javax.xml.stream.XMLStreamException
reader
- props
- javax.xml.stream.XMLStreamException
public XMLReaderImpl(org.apache.xerces.xni.parser.XMLInputSource inputSource, PropertyManager props) throws javax.xml.stream.XMLStreamException
inputSource
- props
- javax.xml.stream.XMLStreamException
public void setInputSource(org.apache.xerces.xni.parser.XMLInputSource inputSource) throws javax.xml.stream.XMLStreamException
inputSource
- javax.xml.stream.XMLStreamException
public void setInputSource(org.xml.sax.InputSource inputSource) throws javax.xml.stream.XMLStreamException
InputSource
- InputSource encapsulating information about XML Source.javax.xml.stream.XMLStreamException
- Throws XMLStreamException if there is a problem setting InputSourcepublic boolean canReuse()
public void reset()
public void close() throws javax.xml.stream.XMLStreamException
close
in interface javax.xml.stream.XMLStreamReader
javax.xml.stream.XMLStreamException
- if there are errors freeing associated resourcespublic java.lang.String getCharacterEncodingScheme()
getCharacterEncodingScheme
in interface javax.xml.stream.XMLStreamReader
public int getColumnNumber()
public java.lang.String getEncoding()
getEncoding
in interface javax.xml.stream.XMLStreamReader
public int getEventType()
getEventType
in interface javax.xml.stream.XMLStreamReader
public int getLineNumber()
public java.lang.String getLocalName()
getLocalName
in interface javax.xml.stream.XMLStreamReader
public java.lang.String getNamespaceURI()
getNamespaceURI
in interface javax.xml.stream.XMLStreamReader
public java.lang.String getPIData()
getPIData
in interface javax.xml.stream.XMLStreamReader
public java.lang.String getPITarget()
getPITarget
in interface javax.xml.stream.XMLStreamReader
public java.lang.String getPrefix()
getPrefix
in interface javax.xml.stream.XMLStreamReader
public char[] getTextCharacters()
getTextCharacters
in interface javax.xml.stream.XMLStreamReader
public int getTextLength()
getTextLength
in interface javax.xml.stream.XMLStreamReader
public int getTextStart()
getTextStart
in interface javax.xml.stream.XMLStreamReader
public java.lang.String getValue()
public java.lang.String getVersion()
getVersion
in interface javax.xml.stream.XMLStreamReader
public boolean hasAttributes()
public boolean hasName()
hasName
in interface javax.xml.stream.XMLStreamReader
public boolean hasNext() throws javax.xml.stream.XMLStreamException
hasNext
in interface javax.xml.stream.XMLStreamReader
javax.xml.stream.XMLStreamException
public boolean hasValue()
public boolean isEndElement()
isEndElement
in interface javax.xml.stream.XMLStreamReader
public boolean isStandalone()
isStandalone
in interface javax.xml.stream.XMLStreamReader
public boolean isStartElement()
isStartElement
in interface javax.xml.stream.XMLStreamReader
public boolean isWhiteSpace()
isWhiteSpace
in interface javax.xml.stream.XMLStreamReader
public int next() throws javax.xml.stream.XMLStreamException
next
in interface javax.xml.stream.XMLStreamReader
javax.xml.stream.XMLStreamException
public int getAttributeCount()
getAttributeCount
in interface javax.xml.stream.XMLStreamReader
java.lang.IllegalStateException
- if this is not a START_ELEMENT or ATTRIBUTEpublic javax.xml.namespace.QName getAttributeName(int index)
getAttributeName
in interface javax.xml.stream.XMLStreamReader
index
- the position of the attributejava.lang.IllegalStateException
- if this is not a START_ELEMENT or ATTRIBUTEpublic java.lang.String getAttributeLocalName(int index)
getAttributeLocalName
in interface javax.xml.stream.XMLStreamReader
index
- public java.lang.String getAttributeNamespace(int index)
getAttributeNamespace
in interface javax.xml.stream.XMLStreamReader
index
- the position of the attributejava.lang.IllegalStateException
- if this is not a START_ELEMENT or ATTRIBUTEpublic java.lang.String getAttributePrefix(int index)
getAttributePrefix
in interface javax.xml.stream.XMLStreamReader
index
- the position of the attributejava.lang.IllegalStateException
- if this is not a START_ELEMENT or ATTRIBUTEpublic javax.xml.namespace.QName getAttributeQName(int index)
index
- the position of the attributejava.lang.IllegalStateException
- if this is not a START_ELEMENT or ATTRIBUTEpublic java.lang.String getAttributeType(int index)
getAttributeType
in interface javax.xml.stream.XMLStreamReader
index
- the position of the attributejava.lang.IllegalStateException
- if this is not a START_ELEMENT or ATTRIBUTEpublic java.lang.String getAttributeValue(int index)
getAttributeValue
in interface javax.xml.stream.XMLStreamReader
index
- the position of the attributejava.lang.IllegalStateException
- if this is not a START_ELEMENT or ATTRIBUTEpublic java.lang.String getAttributeValue(java.lang.String namespaceURI, java.lang.String localName)
getAttributeValue
in interface javax.xml.stream.XMLStreamReader
namespaceURI
- localName
- public java.lang.String getElementText() throws javax.xml.stream.XMLStreamException
getElementText
in interface javax.xml.stream.XMLStreamReader
javax.xml.stream.XMLStreamException
- if the current event is not a START_ELEMENT or if
a non text element is encounteredpublic javax.xml.stream.Location getLocation()
getLocation
in interface javax.xml.stream.XMLStreamReader
public javax.xml.namespace.QName getName()
getName
in interface javax.xml.stream.XMLStreamReader
public javax.xml.namespace.NamespaceContext getNamespaceContext()
getNamespaceContext
in interface javax.xml.stream.XMLStreamReader
public int getNamespaceCount()
getNamespaceCount
in interface javax.xml.stream.XMLStreamReader
java.lang.IllegalStateException
- if this is not a START_ELEMENT, END_ELEMENT or NAMESPACEpublic java.lang.String getNamespacePrefix(int index)
getNamespacePrefix
in interface javax.xml.stream.XMLStreamReader
index
- the position of the namespace declarationjava.lang.IllegalStateException
- if this is not a START_ELEMENT, END_ELEMENT or NAMESPACEpublic java.lang.String getNamespaceURI(int index)
getNamespaceURI
in interface javax.xml.stream.XMLStreamReader
index
- the position of the namespace declarationjava.lang.IllegalStateException
- if this is not a START_ELEMENT, END_ELEMENT or NAMESPACEpublic java.lang.Object getProperty(java.lang.String name) throws java.lang.IllegalArgumentException
getProperty
in interface javax.xml.stream.XMLStreamReader
name
- The name of the property, may not be nulljava.lang.IllegalArgumentException
- if name is nullpublic java.lang.String getText()
getText
in interface javax.xml.stream.XMLStreamReader
java.lang.IllegalStateException
- if this state is not
a valid text state.public void require(int type, java.lang.String namespaceURI, java.lang.String localName) throws javax.xml.stream.XMLStreamException
require
in interface javax.xml.stream.XMLStreamReader
type
- the event typenamespaceURI
- the uri of the event, may be nulllocalName
- the localName of the event, may be nulljavax.xml.stream.XMLStreamException
- if the required values are not matched.public int getTextCharacters(int sourceStart, char[] target, int targetStart, int length) throws javax.xml.stream.XMLStreamException
int length = 1024;
char[] myBuffer = new char[ length ];
for ( int sourceStart = 0 ; ; sourceStart += length )
{
int nCopied = stream.getTextCharacters( sourceStart, myBuffer, 0, length );
if (nCopied < length)
break;
}
XMLStreamException may be thrown if there are any XML errors in the underlying source.
The "targetStart" argument must be greater than or equal to 0 and less than the length of "target",
Length must be greater than 0 and "targetStart + length" must be less than or equal to length of "target".getTextCharacters
in interface javax.xml.stream.XMLStreamReader
sourceStart
- the index of the first character in the source array to copytarget
- the destination arraytargetStart
- the start offset in the target arraylength
- the number of characters to copyjavax.xml.stream.XMLStreamException
- if the underlying XML source is not well-formedjava.lang.IndexOutOfBoundsException
- if targetStart < 0 or > than the length of targetIndexOutOfBoundwhile(isCharacters())
- ;sException if length < 0 or targetStart + length > length of targetjava.lang.UnsupportedOperationException
- if this method is not supportedjava.lang.NullPointerException
- is if target is nullpublic boolean hasText()
hasText
in interface javax.xml.stream.XMLStreamReader
public boolean isAttributeSpecified(int index)
isAttributeSpecified
in interface javax.xml.stream.XMLStreamReader
index
- the position of the attributejava.lang.IllegalStateException
- if this is not a START_ELEMENT or ATTRIBUTEpublic boolean isCharacters()
isCharacters
in interface javax.xml.stream.XMLStreamReader
public int nextTag() throws javax.xml.stream.XMLStreamException
nextTag
in interface javax.xml.stream.XMLStreamReader
javax.xml.stream.XMLStreamException
- if the current event is not white spacepublic boolean standaloneSet()
standaloneSet
in interface javax.xml.stream.XMLStreamReader
public javax.xml.namespace.QName convertXNIQNametoJavaxQName(org.apache.xerces.xni.QName qname)
qname
- public java.lang.String getNamespaceURI(java.lang.String prefix)
NOTE:The 'xml' prefix is bound as defined in Namespaces in XML specification to "http://www.w3.org/XML/1998/namespace".
NOTE: The 'xmlns' prefix must be resolved to following namespace http://www.w3.org/2000/xmlns/
getNamespaceURI
in interface javax.xml.stream.XMLStreamReader
prefix
- The prefix to lookup, may not be nulljava.lang.IllegalStateException
- if the prefix is nullprotected void setPropertyManager(PropertyManager propertyManager)
protected PropertyManager getPropertyManager()
protected java.util.List getEntityDecls()
protected java.util.List getNotationDecls()
Copyright ? 2002-2003 Apache XML Project. All Rights Reserved.