public class XMLStreamReaderImpl extends Object implements XMLStreamReader
| Modifier and Type | Field and Description |
|---|---|
protected static String |
ENTITY_MANAGER
Property identifier: entity manager.
|
protected static String |
ERROR_REPORTER
Property identifier: Error Reporter.
|
protected XMLEntityManager |
fEntityManager |
protected XMLEntityScanner |
fEntityScanner
Entity scanner, this alwasy works on last entity that was opened.
|
protected StaxErrorReporter |
fErrorReporter |
protected XMLInputSource |
fInputSource
Input Source
|
protected NamespaceContextWrapper |
fNamespaceContextWrapper |
protected PropertyManager |
fPropertyManager
Store properties
|
protected XMLDocumentScannerImpl |
fScanner
Document scanner.
|
protected static String |
READER_IN_DEFINED_STATE |
protected static String |
SYMBOL_TABLE
Property identifier: Symbol table.
|
ATTRIBUTE, CDATA, CHARACTERS, COMMENT, DTD, END_DOCUMENT, END_ELEMENT, ENTITY_DECLARATION, ENTITY_REFERENCE, NAMESPACE, NOTATION_DECLARATION, PROCESSING_INSTRUCTION, SPACE, START_DOCUMENT, START_ELEMENT| Constructor and Description |
|---|
XMLStreamReaderImpl(InputStream inputStream,
PropertyManager props) |
XMLStreamReaderImpl(InputStream inputStream,
String encoding,
PropertyManager props) |
XMLStreamReaderImpl(Reader reader,
PropertyManager props) |
XMLStreamReaderImpl(String systemid,
PropertyManager props) |
XMLStreamReaderImpl(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.
|
QName |
convertXNIQNametoJavaxQName(QName qname) |
int |
getAttributeCount()
Returns the count of attributes on this START_ELEMENT,
this method is only valid on a START_ELEMENT or ATTRIBUTE.
|
String |
getAttributeLocalName(int index) |
QName |
getAttributeName(int index)
Returns the localName of the attribute at the provided
index
|
String |
getAttributeNamespace(int index)
Returns the namespace of the attribute at the provided
index
|
String |
getAttributePrefix(int index)
Returns the prefix of this attribute at the
provided index
|
QName |
getAttributeQName(int index)
Returns the qname of the attribute at the provided index
|
String |
getAttributeType(int index)
Returns the XML type of the attribute at the provided
index
|
String |
getAttributeValue(int index)
Returns the value of the attribute at the
index
|
String |
getAttributeValue(String namespaceURI,
String localName) |
String |
getCharacterEncodingScheme()
Returns the character encoding declared on the xml declaration Returns null if none was declared
|
int |
getColumnNumber() |
String |
getElementText()
Reads the content of a text-only element.
|
String |
getEncoding()
Return input encoding if known or null if unknown.
|
protected 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() |
String |
getLocalName() |
Location |
getLocation()
Return the current location of the processor.
|
QName |
getName()
Returns a QName for the current START_ELEMENT or END_ELEMENT event
|
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.
|
String |
getNamespacePrefix(int index)
Returns the prefix for the namespace declared at the
index.
|
String |
getNamespaceURI() |
String |
getNamespaceURI(int index)
Returns the uri for the namespace declared at the
index.
|
String |
getNamespaceURI(String prefix)
Return the uri for the given prefix.
|
protected List |
getNotationDecls() |
String |
getPIData()
Get the data section of a processing instruction
|
String |
getPITarget()
Get the target of a processing instruction
|
String |
getPrefix() |
Object |
getProperty(String name)
Get the value of a feature/property from the underlying implementation
|
protected PropertyManager |
getPropertyManager() |
XMLDocumentScannerImpl |
getScanner() |
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() |
String |
getValue() |
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,
String namespaceURI,
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(XMLInputSource inputSource) |
protected void |
setPropertyManager(PropertyManager propertyManager) |
boolean |
standaloneSet()
Checks if standalone was set in the document
|
protected static final String ENTITY_MANAGER
protected static final String ERROR_REPORTER
protected static final String SYMBOL_TABLE
protected static final String READER_IN_DEFINED_STATE
protected XMLDocumentScannerImpl fScanner
protected NamespaceContextWrapper fNamespaceContextWrapper
protected XMLEntityManager fEntityManager
protected StaxErrorReporter fErrorReporter
protected XMLEntityScanner fEntityScanner
protected XMLInputSource fInputSource
protected PropertyManager fPropertyManager
public XMLStreamReaderImpl(InputStream inputStream, PropertyManager props) throws XMLStreamException
inputStream - props - XMLStreamExceptionpublic XMLStreamReaderImpl(String systemid, PropertyManager props) throws XMLStreamException
systemid - props - XMLStreamExceptionpublic XMLStreamReaderImpl(InputStream inputStream, String encoding, PropertyManager props) throws XMLStreamException
inputStream - encoding - props - XMLStreamExceptionpublic XMLStreamReaderImpl(Reader reader, PropertyManager props) throws XMLStreamException
reader - props - XMLStreamExceptionpublic XMLStreamReaderImpl(XMLInputSource inputSource, PropertyManager props) throws XMLStreamException
inputSource - props - XMLStreamExceptionpublic XMLDocumentScannerImpl getScanner()
public void setInputSource(XMLInputSource inputSource) throws XMLStreamException
inputSource - XMLStreamExceptionpublic boolean canReuse()
public void reset()
public void close()
throws XMLStreamException
close in interface XMLStreamReaderXMLStreamException - if there are errors freeing associated resourcespublic String getCharacterEncodingScheme()
getCharacterEncodingScheme in interface XMLStreamReaderpublic int getColumnNumber()
public String getEncoding()
getEncoding in interface XMLStreamReaderpublic int getEventType()
getEventType in interface XMLStreamReaderpublic int getLineNumber()
public String getLocalName()
getLocalName in interface XMLStreamReaderpublic String getNamespaceURI()
getNamespaceURI in interface XMLStreamReaderpublic String getPIData()
getPIData in interface XMLStreamReaderpublic String getPITarget()
getPITarget in interface XMLStreamReaderpublic String getPrefix()
getPrefix in interface XMLStreamReaderpublic char[] getTextCharacters()
getTextCharacters in interface XMLStreamReaderpublic int getTextLength()
getTextLength in interface XMLStreamReaderpublic int getTextStart()
getTextStart in interface XMLStreamReaderpublic String getValue()
public String getVersion()
getVersion in interface XMLStreamReaderpublic boolean hasAttributes()
public boolean hasName()
hasName in interface XMLStreamReaderpublic boolean hasNext()
throws XMLStreamException
hasNext in interface XMLStreamReaderXMLStreamExceptionpublic boolean hasValue()
public boolean isEndElement()
isEndElement in interface XMLStreamReaderpublic boolean isStandalone()
isStandalone in interface XMLStreamReaderpublic boolean isStartElement()
isStartElement in interface XMLStreamReaderpublic boolean isWhiteSpace()
isWhiteSpace in interface XMLStreamReaderpublic int next()
throws XMLStreamException
next in interface XMLStreamReaderXMLStreamExceptionpublic int getAttributeCount()
getAttributeCount in interface XMLStreamReaderIllegalStateException - if this is not a START_ELEMENT or ATTRIBUTEpublic QName getAttributeName(int index)
getAttributeName in interface XMLStreamReaderindex - the position of the attributeIllegalStateException - if this is not a START_ELEMENT or ATTRIBUTEpublic String getAttributeLocalName(int index)
getAttributeLocalName in interface XMLStreamReaderindex - public String getAttributeNamespace(int index)
getAttributeNamespace in interface XMLStreamReaderindex - the position of the attributeIllegalStateException - if this is not a START_ELEMENT or ATTRIBUTEpublic String getAttributePrefix(int index)
getAttributePrefix in interface XMLStreamReaderindex - the position of the attributeIllegalStateException - if this is not a START_ELEMENT or ATTRIBUTEpublic QName getAttributeQName(int index)
index - the position of the attributeIllegalStateException - if this is not a START_ELEMENT or ATTRIBUTEpublic String getAttributeType(int index)
getAttributeType in interface XMLStreamReaderindex - the position of the attributeIllegalStateException - if this is not a START_ELEMENT or ATTRIBUTEpublic String getAttributeValue(int index)
getAttributeValue in interface XMLStreamReaderindex - the position of the attributeIllegalStateException - if this is not a START_ELEMENT or ATTRIBUTEpublic String getAttributeValue(String namespaceURI, String localName)
getAttributeValue in interface XMLStreamReadernamespaceURI - localName - public String getElementText() throws XMLStreamException
getElementText in interface XMLStreamReaderXMLStreamException - if the current event is not a START_ELEMENT or if
a non text element is encounteredpublic Location getLocation()
getLocation in interface XMLStreamReaderpublic QName getName()
getName in interface XMLStreamReaderpublic NamespaceContext getNamespaceContext()
getNamespaceContext in interface XMLStreamReaderpublic int getNamespaceCount()
getNamespaceCount in interface XMLStreamReaderIllegalStateException - if this is not a START_ELEMENT, END_ELEMENT or NAMESPACEpublic String getNamespacePrefix(int index)
getNamespacePrefix in interface XMLStreamReaderindex - the position of the namespace declarationIllegalStateException - if this is not a START_ELEMENT, END_ELEMENT or NAMESPACEpublic String getNamespaceURI(int index)
getNamespaceURI in interface XMLStreamReaderindex - the position of the namespace declarationIllegalStateException - if this is not a START_ELEMENT, END_ELEMENT or NAMESPACEpublic Object getProperty(String name) throws IllegalArgumentException
getProperty in interface XMLStreamReadername - The name of the property, may not be nullIllegalArgumentException - if name is nullpublic String getText()
getText in interface XMLStreamReaderIllegalStateException - if this state is not
a valid text state.public void require(int type,
String namespaceURI,
String localName)
throws XMLStreamException
require in interface XMLStreamReadertype - the event typenamespaceURI - the uri of the event, may be nulllocalName - the localName of the event, may be nullXMLStreamException - if the required values are not matched.public int getTextCharacters(int sourceStart,
char[] target,
int targetStart,
int length)
throws 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 XMLStreamReadersourceStart - 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 copyXMLStreamException - if the underlying XML source is not well-formedIndexOutOfBoundsException - if targetStart < 0 or > than the length of targetIndexOutOfBoundwhile(isCharacters()) - ;sException if length < 0 or targetStart + length > length of targetUnsupportedOperationException - if this method is not supportedNullPointerException - is if target is nullpublic boolean hasText()
hasText in interface XMLStreamReaderpublic boolean isAttributeSpecified(int index)
isAttributeSpecified in interface XMLStreamReaderindex - the position of the attributeIllegalStateException - if this is not a START_ELEMENT or ATTRIBUTEpublic boolean isCharacters()
isCharacters in interface XMLStreamReaderpublic int nextTag()
throws XMLStreamException
nextTag in interface XMLStreamReaderXMLStreamException - if the current event is not white spacepublic boolean standaloneSet()
standaloneSet in interface XMLStreamReaderpublic QName convertXNIQNametoJavaxQName(QName qname)
qname - public String getNamespaceURI(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 XMLStreamReaderprefix - The prefix to lookup, may not be nullIllegalStateException - - if the prefix is nullprotected void setPropertyManager(PropertyManager propertyManager)
protected PropertyManager getPropertyManager()
protected List getEntityDecls()
protected List getNotationDecls()
Copyright © 2018–2021 mhoffrogge. All rights reserved.