|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.fasterxml.aalto.in.XmlScanner
public abstract class XmlScanner
This is the abstract base class for all scanner implementations, defining operations the actual parser requires from the low-level scanners. Scanners are encoding and input type (byte, char / stream, block) specific, so there are many implementations.
Field Summary | |
---|---|
protected AttributeCollector |
_attrCollector
|
protected int |
_attrCount
|
protected boolean |
_cfgCoalescing
|
protected boolean |
_cfgLazyParsing
|
protected ReaderConfig |
_config
|
protected ElementScope |
_currElem
Information about the current element on the stack |
protected int |
_currNsCount
This is a temporary state variable, valid during START_ELEMENT event. |
protected int |
_currRow
The row on which the character to read next is on. |
protected int |
_currToken
|
protected com.fasterxml.aalto.in.NsBinding |
_defaultNs
Default namespace binding is a per-document singleton, like explicit bindings, and used for elements (never for attributes). |
protected int |
_depth
Number of START_ELEMENT events returned for which no END_ELEMENT has been returned; including current event. |
protected boolean |
_entityPending
Flag set to indicate that an entity is pending |
protected boolean |
_isEmptyTag
Flag that is used if the current state is START_ELEMENT
or END_ELEMENT , to indicate if the underlying physical
tag is a so-called empty tag (one ending with "/>") |
protected FixedNsContext |
_lastNsContext
Last returned NamespaceContext , created for a call
to getNonTransientNamespaceContext() , iff this would
still be a valid context. |
protected NsDeclaration |
_lastNsDecl
Pointer to the last namespace declaration encountered. |
protected char[] |
_nameBuffer
Similarly, need a char buffer for actual String construction (in future, could perhaps use StringBuilder?). |
protected PName[] |
_nsBindingCache
Although unbound pname instances can be easily and safely reused, bound ones are per-document. |
protected int |
_nsBindingCount
|
protected com.fasterxml.aalto.in.NsBinding[] |
_nsBindings
Array containing all prefix bindings needed within the current document, so far (if any). |
protected int |
_nsBindMisses
|
protected String |
_publicId
Public id of the current event (DTD), if any. |
protected String |
_systemId
System id of the current event (DTD), if any. |
protected TextBuilder |
_textBuilder
Textual content of the current event |
protected boolean |
_tokenIncomplete
|
protected PName |
_tokenName
Current name associated with the token, if any. |
protected boolean |
_xml11
Whether validity checks (wrt. |
protected String |
CDATA_STR
String that identifies CDATA section (after " |
protected static int |
INT_0
|
protected static int |
INT_9
|
protected static int |
INT_a
|
protected static int |
INT_A
|
protected static int |
INT_AMP
|
protected static int |
INT_APOS
|
protected static int |
INT_COLON
|
protected static int |
INT_CR
|
protected static int |
INT_EQ
|
protected static int |
INT_EXCL
|
protected static int |
INT_f
|
protected static int |
INT_F
|
protected static int |
INT_GT
|
protected static int |
INT_HYPHEN
|
protected static int |
INT_LBRACKET
|
protected static int |
INT_LF
|
protected static int |
INT_LT
|
protected static int |
INT_NULL
|
protected static int |
INT_QMARK
|
protected static int |
INT_QUOTE
|
protected static int |
INT_RBRACKET
|
protected static int |
INT_SLASH
|
protected static int |
INT_SPACE
|
protected static int |
INT_TAB
|
protected static int |
INT_z
|
protected static int |
MAX_UNICODE_CHAR
This constant defines the highest Unicode character allowed in XML content. |
static int |
TOKEN_EOI
This token type signifies end-of-input, in cases where it can be returned. |
Fields inherited from interface com.fasterxml.aalto.util.XmlConsts |
---|
CHAR_CR, CHAR_LF, CHAR_NULL, CHAR_SPACE, STAX_DEFAULT_OUTPUT_ENCODING, STAX_DEFAULT_OUTPUT_VERSION, XML_DECL_KW_ENCODING, XML_DECL_KW_STANDALONE, XML_DECL_KW_VERSION, XML_SA_NO, XML_SA_YES, XML_V_10, XML_V_10_STR, XML_V_11, XML_V_11_STR, XML_V_UNKNOWN |
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 | |
---|---|
protected |
XmlScanner(ReaderConfig cfg)
|
Method Summary | |
---|---|
protected abstract void |
_closeSource()
|
protected void |
_releaseBuffers()
|
protected PName |
bindName(PName name,
String prefix)
This method is called to find/create a fully qualified (bound) name (element / attribute), for a name with prefix. |
protected void |
bindNs(PName name,
String uri)
Method called when we are ready to bind a declared namespace. |
protected void |
checkImmutableBinding(String prefix,
String uri)
Method called when an immutable ns prefix (xml, xmlns) is encountered. |
void |
close(boolean forceCloseSource)
Method called at point when the parsing process has ended (either by encountering end of the input, or via explicit close), and buffers can and should be released. |
byte[] |
decodeAttrBinaryValue(int index,
org.codehaus.stax2.typed.Base64Variant v,
org.codehaus.stax2.ri.typed.CharArrayBase64Decoder dec)
|
void |
decodeAttrValue(int index,
org.codehaus.stax2.typed.TypedValueDecoder tvd)
|
int |
decodeAttrValues(int index,
org.codehaus.stax2.typed.TypedArrayDecoder tad)
Method called to decode the attribute value that consists of zero or more space-separated tokens. |
int |
decodeElements(org.codehaus.stax2.typed.TypedArrayDecoder tad,
boolean reset)
Method called by the stream reader to decode space-separated tokens that are part of the current text event, using given decoder. |
int |
findAttrIndex(String nsURI,
String localName)
|
protected com.fasterxml.aalto.in.NsBinding |
findOrCreateBinding(String prefix)
Method called when a namespace declaration needs to find the binding object (essentially a per-prefix-per-document canonical container object) |
protected abstract void |
finishCData()
|
protected abstract void |
finishCharacters()
|
protected abstract void |
finishComment()
|
protected abstract void |
finishDTD(boolean copyContents)
|
protected abstract void |
finishPI()
|
protected abstract void |
finishSpace()
|
protected void |
finishToken()
This token is called to ensure that the current token/event has been completely parsed, such that we have all the data needed to return it (textual content, PI data, comment text etc) |
void |
fireSaxCharacterEvents(ContentHandler h)
|
void |
fireSaxCommentEvent(LexicalHandler h)
|
void |
fireSaxEndElement(ContentHandler h)
|
void |
fireSaxPIEvent(ContentHandler h)
|
void |
fireSaxSpaceEvents(ContentHandler h)
|
void |
fireSaxStartElement(ContentHandler h,
Attributes attrs)
|
AttributeCollector |
getAttrCollector()
|
int |
getAttrCount()
|
String |
getAttrLocalName(int index)
|
String |
getAttrNsURI(int index)
|
String |
getAttrPrefix(int index)
|
String |
getAttrPrefixedName(int index)
|
QName |
getAttrQName(int index)
|
String |
getAttrType(int index)
|
String |
getAttrValue(int index)
|
String |
getAttrValue(String nsURI,
String localName)
|
ReaderConfig |
getConfig()
|
abstract int |
getCurrentColumnNr()
|
abstract int |
getCurrentLineNr()
|
abstract org.codehaus.stax2.XMLStreamLocation2 |
getCurrentLocation()
|
int |
getDepth()
|
String |
getDTDPublicId()
|
String |
getDTDSystemId()
|
org.codehaus.stax2.XMLStreamLocation2 |
getEndLocation()
|
String |
getInputPublicId()
|
String |
getInputSystemId()
|
PName |
getName()
|
String |
getNamespacePrefix(int index)
|
String |
getNamespaceURI()
|
String |
getNamespaceURI(int index)
|
String |
getNamespaceURI(String prefix)
|
NamespaceContext |
getNonTransientNamespaceContext()
|
int |
getNsCount()
|
String |
getPrefix(String nsURI)
|
Iterator<String> |
getPrefixes(String nsURI)
|
QName |
getQName()
|
org.codehaus.stax2.XMLStreamLocation2 |
getStartLocation()
|
String |
getText()
|
int |
getText(Writer w,
boolean preserveContents)
|
char[] |
getTextCharacters()
|
int |
getTextCharacters(int srcStart,
char[] target,
int targetStart,
int len)
|
int |
getTextLength()
|
boolean |
hasEmptyStack()
|
boolean |
isAttrSpecified(int index)
|
boolean |
isEmptyTag()
|
boolean |
isTextWhitespace()
|
protected abstract boolean |
loadMore()
|
protected void |
loadMoreGuaranteed()
Method that tries to load at least one more byte into buffer; and if that fails, throws an appropriate EOI exception. |
protected void |
loadMoreGuaranteed(int tt)
|
abstract int |
nextFromProlog(boolean isProlog)
|
abstract int |
nextFromTree()
|
protected void |
reportDoubleHyphenInComments()
|
protected void |
reportDuplicateNsDecl(String prefix)
|
protected void |
reportEntityOverflow()
|
protected void |
reportEofInName(char[] cbuf,
int clen)
|
protected void |
reportIllegalCDataEnd()
|
protected void |
reportIllegalNsDecl(String prefix)
|
protected void |
reportIllegalNsDecl(String prefix,
String uri)
|
protected void |
reportInputProblem(String msg)
|
protected void |
reportInvalidNameChar(int ch,
int index)
|
protected void |
reportInvalidNsIndex(int index)
|
protected void |
reportInvalidXmlChar(int ch)
|
protected void |
reportMissingPISpace(int ch)
Called when there's an unexpected char after PI target (non-ws, not part of '?>' end marker |
protected void |
reportMultipleColonsInName()
|
protected void |
reportPrologProblem(boolean isProlog,
String msg)
|
protected void |
reportPrologUnexpChar(boolean isProlog,
int ch,
String msg)
|
protected void |
reportTreeUnexpChar(int ch,
String msg)
|
protected void |
reportUnboundPrefix(PName name,
boolean isAttr)
|
protected void |
reportUnexpandedEntityInAttr(PName name,
boolean isNsDecl)
Method called when a call to expand an entity within attribute value fails to expand it. |
protected void |
reportUnexpectedEndTag(String expName)
|
void |
resetForDecoding(org.codehaus.stax2.typed.Base64Variant v,
org.codehaus.stax2.ri.typed.CharArrayBase64Decoder dec,
boolean firstChunk)
Method called by the stream reader to reset given base64 decoder with data from the current text event. |
protected abstract void |
skipCData()
|
protected abstract boolean |
skipCharacters()
|
protected abstract boolean |
skipCoalescedText()
Secondary skip method called after primary text segment has been skipped, and we are in coalescing mode. |
protected abstract void |
skipComment()
|
protected abstract void |
skipPI()
|
protected abstract void |
skipSpace()
|
protected boolean |
skipToken()
This method is called to essentially skip remaining of the current token (data of PI etc) |
protected void |
throwInvalidSpace(int i)
|
protected void |
throwInvalidXmlChar(int i)
|
protected void |
throwNullChar()
|
protected void |
throwUnexpectedChar(int i,
String msg)
|
protected void |
verifyXmlChar(int value)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final String CDATA_STR
public static final int TOKEN_EOI
protected static final int MAX_UNICODE_CHAR
protected static final int INT_NULL
protected static final int INT_CR
protected static final int INT_LF
protected static final int INT_TAB
protected static final int INT_SPACE
protected static final int INT_HYPHEN
protected static final int INT_QMARK
protected static final int INT_AMP
protected static final int INT_LT
protected static final int INT_GT
protected static final int INT_QUOTE
protected static final int INT_APOS
protected static final int INT_EXCL
protected static final int INT_COLON
protected static final int INT_LBRACKET
protected static final int INT_RBRACKET
protected static final int INT_SLASH
protected static final int INT_EQ
protected static final int INT_A
protected static final int INT_F
protected static final int INT_a
protected static final int INT_f
protected static final int INT_z
protected static final int INT_0
protected static final int INT_9
protected final ReaderConfig _config
protected final boolean _xml11
protected final boolean _cfgCoalescing
protected boolean _cfgLazyParsing
protected int _currToken
protected boolean _tokenIncomplete
protected int _depth
protected final TextBuilder _textBuilder
protected boolean _entityPending
protected char[] _nameBuffer
protected PName _tokenName
protected boolean _isEmptyTag
START_ELEMENT
or END_ELEMENT
, to indicate if the underlying physical
tag is a so-called empty tag (one ending with "/>")
protected ElementScope _currElem
protected String _publicId
protected String _systemId
protected NsDeclaration _lastNsDecl
protected int _currNsCount
protected com.fasterxml.aalto.in.NsBinding _defaultNs
protected com.fasterxml.aalto.in.NsBinding[] _nsBindings
protected int _nsBindingCount
protected PName[] _nsBindingCache
protected int _nsBindMisses
protected FixedNsContext _lastNsContext
NamespaceContext
, created for a call
to getNonTransientNamespaceContext()
, iff this would
still be a valid context.
protected final AttributeCollector _attrCollector
protected int _attrCount
protected int _currRow
Constructor Detail |
---|
protected XmlScanner(ReaderConfig cfg)
Method Detail |
---|
public final void close(boolean forceCloseSource) throws XMLStreamException
forceCloseSource
- True if the underlying input source is
to be closed, independent of whether auto-close has been set
to true via configuration (or if the scanner manages the input
source)
XMLStreamException
protected void _releaseBuffers()
protected abstract void _closeSource() throws IOException
IOException
public ReaderConfig getConfig()
public AttributeCollector getAttrCollector()
public abstract int nextFromProlog(boolean isProlog) throws XMLStreamException
XMLStreamException
public abstract int nextFromTree() throws XMLStreamException
XMLStreamException
protected final void finishToken() throws XMLStreamException
XMLStreamException
protected final boolean skipToken() throws XMLStreamException
XMLStreamException
public abstract org.codehaus.stax2.XMLStreamLocation2 getCurrentLocation()
public org.codehaus.stax2.XMLStreamLocation2 getStartLocation()
public org.codehaus.stax2.XMLStreamLocation2 getEndLocation() throws XMLStreamException
XMLStreamException
public abstract int getCurrentLineNr()
public abstract int getCurrentColumnNr()
public final String getInputSystemId()
public final String getInputPublicId()
public final boolean hasEmptyStack()
public final int getDepth()
public final boolean isEmptyTag()
public final PName getName()
public final QName getQName()
public final String getDTDPublicId()
public final String getDTDSystemId()
public final String getText() throws XMLStreamException
XMLStreamException
public final int getTextLength() throws XMLStreamException
XMLStreamException
public final char[] getTextCharacters() throws XMLStreamException
XMLStreamException
public final int getTextCharacters(int srcStart, char[] target, int targetStart, int len) throws XMLStreamException
XMLStreamException
public final int getText(Writer w, boolean preserveContents) throws XMLStreamException
XMLStreamException
public final boolean isTextWhitespace() throws XMLStreamException
XMLStreamException
public final int decodeElements(org.codehaus.stax2.typed.TypedArrayDecoder tad, boolean reset) throws XMLStreamException
reset
- If true, need to tell text buffer to reset its decoding
state; if false, shouldn't
XMLStreamException
public final void resetForDecoding(org.codehaus.stax2.typed.Base64Variant v, org.codehaus.stax2.ri.typed.CharArrayBase64Decoder dec, boolean firstChunk) throws XMLStreamException
XMLStreamException
public void fireSaxStartElement(ContentHandler h, Attributes attrs) throws SAXException
SAXException
public void fireSaxEndElement(ContentHandler h) throws SAXException
SAXException
public void fireSaxCharacterEvents(ContentHandler h) throws XMLStreamException, SAXException
XMLStreamException
SAXException
public void fireSaxSpaceEvents(ContentHandler h) throws XMLStreamException, SAXException
XMLStreamException
SAXException
public void fireSaxCommentEvent(LexicalHandler h) throws XMLStreamException, SAXException
XMLStreamException
SAXException
public void fireSaxPIEvent(ContentHandler h) throws XMLStreamException, SAXException
XMLStreamException
SAXException
public final int getAttrCount()
public final String getAttrLocalName(int index)
public final QName getAttrQName(int index)
public final String getAttrPrefixedName(int index)
public final String getAttrNsURI(int index)
public final String getAttrPrefix(int index)
public final String getAttrValue(int index)
public final String getAttrValue(String nsURI, String localName)
public final void decodeAttrValue(int index, org.codehaus.stax2.typed.TypedValueDecoder tvd) throws XMLStreamException
XMLStreamException
public final int decodeAttrValues(int index, org.codehaus.stax2.typed.TypedArrayDecoder tad) throws XMLStreamException
XMLStreamException
public final byte[] decodeAttrBinaryValue(int index, org.codehaus.stax2.typed.Base64Variant v, org.codehaus.stax2.ri.typed.CharArrayBase64Decoder dec) throws XMLStreamException
XMLStreamException
public final int findAttrIndex(String nsURI, String localName)
public final String getAttrType(int index)
public final boolean isAttrSpecified(int index)
public final int getNsCount()
public final String getNamespacePrefix(int index)
public final String getNamespaceURI(int index)
public final String getNamespaceURI()
public final NamespaceContext getNonTransientNamespaceContext()
public String getNamespaceURI(String prefix)
getNamespaceURI
in interface NamespaceContext
public String getPrefix(String nsURI)
getPrefix
in interface NamespaceContext
public Iterator<String> getPrefixes(String nsURI)
getPrefixes
in interface NamespaceContext
protected abstract void finishCharacters() throws XMLStreamException
XMLStreamException
protected abstract void finishCData() throws XMLStreamException
XMLStreamException
protected abstract void finishComment() throws XMLStreamException
XMLStreamException
protected abstract void finishDTD(boolean copyContents) throws XMLStreamException
XMLStreamException
protected abstract void finishPI() throws XMLStreamException
XMLStreamException
protected abstract void finishSpace() throws XMLStreamException
XMLStreamException
protected abstract boolean skipCharacters() throws XMLStreamException
XMLStreamException
protected abstract void skipCData() throws XMLStreamException
XMLStreamException
protected abstract void skipComment() throws XMLStreamException
XMLStreamException
protected abstract void skipPI() throws XMLStreamException
XMLStreamException
protected abstract void skipSpace() throws XMLStreamException
XMLStreamException
protected abstract boolean skipCoalescedText() throws XMLStreamException
XMLStreamException
protected abstract boolean loadMore() throws XMLStreamException
XMLStreamException
protected final PName bindName(PName name, String prefix)
protected final com.fasterxml.aalto.in.NsBinding findOrCreateBinding(String prefix) throws XMLStreamException
XMLStreamException
protected final void bindNs(PName name, String uri) throws XMLStreamException
XMLStreamException
protected final void checkImmutableBinding(String prefix, String uri) throws XMLStreamException
XMLStreamException
protected final void loadMoreGuaranteed() throws XMLStreamException
XMLStreamException
protected final void loadMoreGuaranteed(int tt) throws XMLStreamException
XMLStreamException
protected final void verifyXmlChar(int value) throws XMLStreamException
XMLStreamException
protected void reportInputProblem(String msg) throws XMLStreamException
XMLStreamException
protected void reportUnexpandedEntityInAttr(PName name, boolean isNsDecl) throws XMLStreamException
XMLStreamException
protected void reportPrologUnexpChar(boolean isProlog, int ch, String msg) throws XMLStreamException
XMLStreamException
protected void reportPrologProblem(boolean isProlog, String msg) throws XMLStreamException
XMLStreamException
protected void reportTreeUnexpChar(int ch, String msg) throws XMLStreamException
XMLStreamException
protected void reportInvalidNameChar(int ch, int index) throws XMLStreamException
XMLStreamException
protected void reportInvalidXmlChar(int ch) throws XMLStreamException
XMLStreamException
protected void reportEofInName(char[] cbuf, int clen) throws XMLStreamException
XMLStreamException
protected void reportMissingPISpace(int ch) throws XMLStreamException
XMLStreamException
protected void reportDoubleHyphenInComments() throws XMLStreamException
XMLStreamException
protected void reportMultipleColonsInName() throws XMLStreamException
XMLStreamException
protected void reportEntityOverflow() throws XMLStreamException
XMLStreamException
protected void reportInvalidNsIndex(int index)
protected void reportUnboundPrefix(PName name, boolean isAttr) throws XMLStreamException
XMLStreamException
protected void reportDuplicateNsDecl(String prefix) throws XMLStreamException
XMLStreamException
protected void reportIllegalNsDecl(String prefix) throws XMLStreamException
XMLStreamException
protected void reportIllegalNsDecl(String prefix, String uri) throws XMLStreamException
XMLStreamException
protected void reportUnexpectedEndTag(String expName) throws XMLStreamException
XMLStreamException
protected void reportIllegalCDataEnd() throws XMLStreamException
XMLStreamException
protected void throwUnexpectedChar(int i, String msg) throws XMLStreamException
XMLStreamException
protected void throwNullChar() throws XMLStreamException
XMLStreamException
protected void throwInvalidXmlChar(int i) throws XMLStreamException
XMLStreamException
protected void throwInvalidSpace(int i) throws XMLStreamException
XMLStreamException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |