Top Description Fields Constructors Methods
com.fasterxml.aalto.in

public abstract Class XmlScanner

extends Object
implements XmlConsts, XMLStreamConstants, NamespaceContext
Class Inheritance
All Implemented Interfaces
javax.xml.namespace.NamespaceContext, javax.xml.stream.XMLStreamConstants, com.fasterxml.aalto.util.XmlConsts
Known Direct Subclasses
com.fasterxml.aalto.in.ByteBasedScanner, com.fasterxml.aalto.in.ReaderScanner
Imports
java.io.*, java.util.ArrayList, .Iterator, org.xml.sax.Attributes, .ContentHandler, .SAXException, org.xml.sax.ext.LexicalHandler, javax.xml.XMLConstants, javax.xml.namespace.NamespaceContext, .QName, javax.xml.stream.Location, .XMLStreamConstants, .XMLStreamException, org.codehaus.stax2.XMLStreamLocation2, org.codehaus.stax2.typed.Base64Variant, .TypedArrayDecoder, .TypedValueDecoder, .TypedXMLStreamException, org.codehaus.stax2.ri.typed.CharArrayBase64Decoder, com.fasterxml.aalto.WFCException, com.fasterxml.aalto.impl.*, com.fasterxml.aalto.util.*

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

Modifier and TypeField and Description
protected final AttributeCollector
protected int
protected final boolean
protected boolean
protected final ReaderConfig
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
protected 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
protected NsBinding[]
_nsBindings

Array containing all prefix bindings needed within the current document, so far (if any).

protected int
protected long
_pastBytesOrChars

Number of bytes that were read and processed before the contents of the current buffer; used for calculating absolute offsets.

protected String
_publicId

Public id of the current event (DTD), if any.

protected int
_rowStartOffset

Offset used to calculate the column value given current input buffer pointer.

protected long
_startColumn

Current column at start of current (last returned) token

protected long
_startRawOffset

Offset (in chars or bytes) at start of current token

protected long
_startRow

Current row at start of current (last returned) token

protected String
_systemId

System id of the current event (DTD), if any.

protected final TextBuilder
_textBuilder

Textual content of the current event

protected boolean
protected PName
_tokenName

Current name associated with the token, if any.

protected final boolean
_xml11

Whether validity checks (wrt.

private static final int
private static final int
BIND_CACHE_SIZE

Size of the bind cache can be reasonably small, and should still get high enough hit rate

private static final int
BIND_MISSES_TO_ACTIVATE_CACHE

Let's activate cache quite soon, no need to wait for hundreds of misses; just try to avoid cache construction if all we get is soap envelope element or such.

protected final String
CDATA_STR

String that identifies CDATA section (after "<![" prefix)

protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
MAX_UNICODE_CHAR

Hides com.fasterxml.aalto.util.XmlConsts.MAX_UNICODE_CHAR.

This constant defines the highest Unicode character allowed in XML content.
public static final int
TOKEN_EOI

This token type signifies end-of-input, in cases where it can be returned.

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
protected abstract void
protected void
protected final 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 final void
bindNs(PName name, String uri)

Method called when we are ready to bind a declared namespace.

protected final void
checkImmutableBinding(String prefix, String uri)

Method called when an immutable ns prefix (xml, xmlns) is encountered.

public final void
close(boolean
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)
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.

public final byte[]
public final void
public final int

Returns:

Number of tokens decoded
decodeAttrValues
(int index, TypedArrayDecoder tad)

Method called to decode the attribute value that consists of zero or more space-separated tokens.

public final int
decodeElements(TypedArrayDecoder tad, boolean
If true, need to tell text buffer to reset its decoding state; if false, shouldn't
reset
)

Method called by the stream reader to decode space-separated tokens that are part of the current text event, using given decoder.

public final int
findAttrIndex(String nsURI, String localName)

private NsDeclaration
findCurrNsDecl(int index)

protected final 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
protected abstract void
protected abstract void
protected abstract void
finishDTD(boolean copyContents)

protected abstract void
protected abstract void
protected abstract void
finishToken()

This method 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)

public void
public void
public void
public void
public void
public void
public AttributeCollector
public final int
public final String
getAttrLocalName(int index)

public final String
getAttrNsURI(int index)

public final String
getAttrPrefix(int index)

public final String
public final QName
getAttrQName(int index)

public final String
getAttrType(int index)

public final String
getAttrValue(int index)

public final String
getAttrValue(String nsURI, String localName)

public ReaderConfig
public abstract int
public final int
public abstract XMLStreamLocation2

Returns:

Current input location
getCurrentLocation
()

public final int
public final String
public final String
public abstract long
public abstract long
public XMLStreamLocation2
public final String
public final String
public final PName
public final String
getNamespacePrefix(int index)

public final String
getNamespaceURI(int index)

public final String
public String
getNamespaceURI(String
prefix to look up
prefix
)

Implements javax.xml.namespace.NamespaceContext.getNamespaceURI.

Get Namespace URI bound to a prefix in the current scope.
public final NamespaceContext
public final int
public String
getPrefix(String
URI of Namespace to lookup
nsURI
)

Implements javax.xml.namespace.NamespaceContext.getPrefix.

Get prefix bound to Namespace URI in the current scope.
public Iterator<String>
getPrefixes(String
URI of Namespace to lookup
nsURI
)

Implements javax.xml.namespace.NamespaceContext.getPrefixes.

Get all prefixes bound to a Namespace URI in the current scope.
public final QName
public abstract long
public abstract long
public final XMLStreamLocation2
public final String
public final int
getText(Writer w, boolean preserveContents)

public final char[]
public final int
getTextCharacters(int srcStart, char[] target, int targetStart, int len)

public final int
protected char
public final boolean
public final boolean
isAttrSpecified(int index)

public final boolean
public final boolean
protected abstract boolean
protected final void
loadMoreGuaranteed()

Method that tries to load at least one more byte into buffer; and if that fails, throws an appropriate EOI exception.

protected final void
public abstract int
nextFromProlog(boolean isProlog)

public abstract int
protected void
protected void
protected void
protected void
reportEofInName(char[] cbuf, int clen)

protected void
protected void
protected void
protected void
protected void
reportInvalidNameChar(int ch, int index)

protected void
protected void
protected void
reportMissingPISpace(int ch)

Called when there's an unexpected char after PI target (non-ws, not part of '?

protected void
protected void
reportPrologProblem(boolean isProlog, String msg)

protected void
reportPrologUnexpChar(boolean isProlog, int ch, String msg)

protected void
reportPrologUnexpElement(boolean isProlog, int ch)

protected void
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
public final void
resetForDecoding(Base64Variant v, 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
protected abstract boolean

Returns:

True, if an unexpanded entity was encountered (and is now pending)
skipCharacters
()

protected abstract boolean

Returns:

True, if an unexpanded entity was encountered (and is now pending)
skipCoalescedText
()

Secondary skip method called after primary text segment has been skipped, and we are in coalescing mode.

protected abstract void
protected abstract void
protected abstract void
protected final boolean

Returns:

True If by skipping we also figured out following event type (and assigned its type to _currToken); false if that remains to be done
skipToken
()

This method is called to essentially skip remaining of the current token (data of PI etc)

protected void
protected void
protected void
protected final void
verifyXmlChar(int value)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait