Class BasicStreamReader
- All Implemented Interfaces:
InputConfigFlags
,ParsingErrorMsgs
,InputProblemReporter
,StreamReaderImpl
,XMLStreamConstants
,XMLStreamReader
,org.codehaus.stax2.DTDInfo
,org.codehaus.stax2.LocationInfo
,org.codehaus.stax2.typed.TypedXMLStreamReader
,org.codehaus.stax2.validation.Validatable
,org.codehaus.stax2.XMLStreamReader2
- Direct Known Subclasses:
TypedStreamReader
XMLStreamReader2
consisting of
all functionality other than DTD-validation-specific parts, and
Typed Access API (Stax2 v3.0), which are implemented at
sub-classes.-
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final int
(package private) static final int
(package private) static final int
(package private) static final int
(package private) static final int
(package private) static final int
private static final int
private static final int
protected static final int
protected static final int
This mask covers all types for which basicgetText()
method can be called.protected static final int
This mask is used with Stax2 getText() method (one that takes Writer as an argument): accepts even wider range of event types.protected static final int
This mask covers all types for which extendsgetTextXxx
methods can be called; which is less than those for whichgetText()
can be called.protected final AttributeCollector
Object that stores information about currently accessible attributes.protected final boolean
protected final boolean
protected final boolean
protected int
Counter used for determining whether we are to try to heuristically "intern" white space that seems to be used for indentation purposesprotected final int
Set of locally stored configuration flagsprotected int
Sized of currentTextLength for CDATA, CHARACTERS, WHITESPACE.protected int
Current state of the stream, ie token value returned bygetEventType()
.protected int
Status about "stand-aloneness" of document; set to 'yes'/'no'/'unknown' based on whether there was xml declaration, and if so, whether it had standalone attribute.protected String
Public id of the DTD, if one exists and has been parsed.protected String
System id of the DTD, if one exists and has been parsed.protected final InputElementStack
Currently open element treeprotected Map
<String, EntityDecl> Entities parsed from internal/external DTD subsets.protected final ReaderCreator
Object to notify about shared stuff, such as symbol tables, as well as to query for additional config settings if necessary.protected int
Main parsing/tokenization state (STATE_xxx)protected XMLStreamException
Due to the way Stax API does not allow throwing stream exceptions from many methods for which Woodstox would need to throw one (especiallygetText
and its variations), we may need to delay throwing an exception untilnext()
is called next time.protected boolean
Configuration fromWstxInputProperties#RETURN_NULL_FOR_DEFAULT_NAMESPACE
protected String
Local name of root element, as dictated by DOCTYPE declaration; null if no DOCTYPE declaration.protected String
Prefix of root element, as dictated by DOCTYPE declaration; null if no DOCTYPE declaration, or no root prefixprotected int
Additional information sometimes stored (when generating dummy events in multi-doc mode, for example) temporarily whenmCurrToken
is already populated.protected final int
Minimum number of characters parser can return as partial text segment, IF it's not required to coalesce adjacent text segments.protected boolean
protected boolean
protected final int
Threshold value that defines tokenization state that needs to be achieved to "finish" current logical text segment (which may consist of adjacent CDATA and text segments; or be a complete physical segment; or just even a fragment of such a segment)protected final TextBuffer
TextBuffer mostly used to collect non-element textual content (text, CDATA, comment content, pi data)protected int
State of the current token; one of M_ - constants from above.protected boolean
Flag that indicates that textual content (CDATA, CHARACTERS) is to be validated within current element's scope.protected int
Mode information needed at this level; mostly to check what kind of textual content (if any) is allowed in current element context.protected int
Status of current (text) token's "whitespaceness", that is, whether it is or is not all white space.protected static final String
protected static final String
(package private) static final int
(package private) static final int
(package private) static final int
(package private) static final int
(package private) static final int
(package private) static final int
(package private) static final int
(package private) static final int
(package private) static final int
(package private) static final int
Fields inherited from class com.ctc.wstx.sr.StreamScanner
CHAR_CR_LF_OR_NULL, CHAR_FIRST_PURE_TEXT, CHAR_LOWEST_LEGAL_LOCALNAME_CHAR, INT_CR_LF_OR_NULL, mAllowXml11EscapedCharsInXml10, mCachedEntities, mCfgNsEnabled, mCfgReplaceEntities, mCfgTreatCharRefsAsEntities, mConfig, mCurrDepth, mCurrEntity, mCurrName, mDocInputEncoding, mDocXmlEncoding, mDocXmlVersion, mEntityExpansionCount, mEntityResolver, mInput, mInputTopDepth, mNameBuffer, mNormalizeLFs, mRootInput, mSymbols, mTokenInputCol, mTokenInputRow, mTokenInputTotal
Fields inherited from class com.ctc.wstx.io.WstxInputData
CHAR_NULL, CHAR_SPACE, INT_NULL, INT_SPACE, MAX_UNICODE_CHAR, mCurrInputProcessed, mCurrInputRow, mCurrInputRowStart, mInputBuffer, mInputEnd, mInputPtr, mXml11
Fields inherited from interface com.ctc.wstx.cfg.InputConfigFlags
CFG_ALLOW_XML11_ESCAPED_CHARS_IN_XML10, CFG_AUTO_CLOSE_INPUT, CFG_CACHE_DTDS, CFG_CACHE_DTDS_BY_PUBLIC_ID, CFG_COALESCE_TEXT, CFG_INTERN_NAMES, CFG_INTERN_NS_URIS, CFG_JAXP_FEATURE_SECURE_PROCESSING, CFG_LAZY_PARSING, CFG_NAMESPACE_AWARE, CFG_NORMALIZE_LFS, CFG_PRESERVE_LOCATION, CFG_REPLACE_ENTITY_REFS, CFG_REPORT_CDATA, CFG_REPORT_PROLOG_WS, CFG_SUPPORT_DTD, CFG_SUPPORT_DTDPP, CFG_SUPPORT_EXTERNAL_ENTITIES, CFG_TREAT_CHAR_REFS_AS_ENTS, CFG_VALIDATE_AGAINST_DTD, CFG_XMLID_TYPING, CFG_XMLID_UNIQ_CHECKS
Fields inherited from interface com.ctc.wstx.cfg.ParsingErrorMsgs
SUFFIX_EOF_EXP_NAME, SUFFIX_IN_ATTR_VALUE, SUFFIX_IN_CDATA, SUFFIX_IN_CLOSE_ELEMENT, SUFFIX_IN_COMMENT, SUFFIX_IN_DEF_ATTR_VALUE, SUFFIX_IN_DOC, SUFFIX_IN_DTD, SUFFIX_IN_DTD_EXTERNAL, SUFFIX_IN_DTD_INTERNAL, SUFFIX_IN_ELEMENT, SUFFIX_IN_ENTITY_REF, SUFFIX_IN_EPILOG, SUFFIX_IN_NAME, SUFFIX_IN_PROC_INSTR, SUFFIX_IN_PROLOG, SUFFIX_IN_TEXT, SUFFIX_IN_XML_DECL
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
Fields inherited from interface org.codehaus.stax2.XMLStreamReader2
FEATURE_DTD_OVERRIDE
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
BasicStreamReader
(InputBootstrapper bs, BranchingReaderSource input, ReaderCreator owner, ReaderConfig cfg, InputElementStack elemStack, boolean forER) -
Method Summary
Modifier and TypeMethodDescriptionprivate final char[]
_checkAttributeLimit
(TextBuilder tb, char[] outBuf, int outPtr, int currAttrSize, int maxAttrSize) protected org.codehaus.stax2.typed.TypedXMLStreamException
_constructTypeException
(String msg, String lexicalValue) protected XMLStreamException
_constructUnexpectedInTyped
(int nextToken) Method called to report a problem withprivate final char[]
_expandOutputForText
(int inputPtr, char[] outBuf, int shortestSegment) private final int
_outputLimit
(char[] outBuf, int offset, int maxAttrLen) protected void
private boolean
checkCDataEnd
(char[] outBuf, int outPtr) Method that will check, given the starting ']', whether there is ending ']]>' (including optional extra ']'s); if so, will updated output buffer with extra ]s, if not, will make sure input and output are positioned for further checking.protected String
checkKeyword
(char c, String expected) void
close()
Note: as per StAX 1.0 specs, this method does NOT close the underlying input reader.void
private int
Method called when advancing stream past the end tag that closes the root element of the open document.protected static InputElementStack
protected void
protected EntityDecl
findEntity
(String id, Object arg) Abstract method for sub-classes to implement, for finding a declared general or parsed entity.protected void
finishDTD
(boolean copyContents) This method gets called to handle remainder of DOCTYPE declaration, essentially the optional internal subset.protected void
finishToken
(boolean deferErrors) Method called to read in contents of the token completely, if not yet read.void
void
void
void
void
void
fireSaxStartElement
(ContentHandler h, Attributes attrs) Method needed by classes (like stream writer implementations) that want to have efficient direct access to attribute collector Object, for optimal attribute name and value access.int
org.codehaus.stax2.AttributeInfo
getAttributeLocalName
(int index) getAttributeName
(int index) getAttributeNamespace
(int index) getAttributePrefix
(int index) getAttributeType
(int index) getAttributeValue
(int index) getAttributeValue
(String nsURI, String localName) As per Stax (1.0) specs, needs to return whatever xml declaration claimed encoding is, if any; or null if no xml declaration found.int
getDepth()
org.codehaus.stax2.DTDInfo
Since this class implementsDTDInfo
, method can just returnthis
.private char[]
Internal method used by implementationFrom StAX specs: Reads the content of a text-only element, an exception is thrown if this is not a text-only element.As per Stax (1.0) specs, needs to return whatever parser determined the encoding was, if it was able to figure it out.long
long
final org.codehaus.stax2.XMLStreamLocation2
int
Returns type of the last event returned; or START_DOCUMENT before any events has been explicitly returned.getFeature
(String name) Deprecated.Method needed by classes (like stream writer implementations) that want to have efficient direct access to element stack implementationfinal Location
Returns location of last properly parsed token; as per StAX specs, apparently needs to be the end of current event, which is the same as the start of the following event (or EOF if that's next).final org.codehaus.stax2.LocationInfo
Location information is always accessible, for this reader.getName()
int
getNamespacePrefix
(int index) getNamespaceURI
(int index) getNamespaceURI
(String prefix) Note: DTD-handling sub-classes need to override this method.org.codehaus.stax2.validation.DTDValidationSchema
Sub-class will override this methodgetProperty
(String name) long
long
getText()
int
Method similar togetText()
, except that it just uses provided Writer to write all textual content.char[]
int
getTextCharacters
(int sourceStart, char[] target, int targetStart, int len) int
int
protected int
handleEOF
(boolean isProlog) private int
handleExtraRoot
(char c) Method called if a root-level element is found after the main root element was closed.protected void
This problem gets reported if an entity tries to expand to a close tag matching start tag that did not came from the same entity (but from parent).protected void
protected int
handleMultiDocStart
(int nextEvent) Method called when an event was encountered that indicates document boundary in multi-doc mode.protected void
private final boolean
handleNonNsAttrs
(char c) private final boolean
handleNsAttrs
(char c) protected void
handleRootElem
(char c) private final void
handleStartElem
(char c) Method that takes care of parsing of start elements; including full parsing of namespace declarations and attributes, as well as namespace resolution.protected void
This method gets called if a declaration for an entity was not found in entity expanding mode (enabled by default for xml reader, always enabled for dtd reader).protected final boolean
hasConfigFlags
(int flags) boolean
hasName()
boolean
hasNext()
boolean
hasText()
protected void
Method called right before the document root element is handled.boolean
isAttributeSpecified
(int index) boolean
boolean
boolean
boolean
boolean
isPropertySupported
(String name) boolean
boolean
boolean
05-Apr-2004, TSa: Could try to determine status when text is actually read.final int
next()
private int
Method called to get the next event when we are "multi-doc hack" mode, during which extra END_DOCUMENT/START_DOCUMENT events need to be returned.private boolean
nextFromProlog
(boolean isProlog) Method called to find type of next token in prolog; either reading just enough information to know the type (lazy parsing), or the full contents (non-lazy)private void
nextFromPrologBang
(boolean isProlog) Called after character sequence '<!' has been found; expectation is that it'll either be DOCTYPE declaration (if we are in prolog and haven't yet seen one), or a comment.private final int
Method called to parse beginning of the next event within document tree, and return its type.private int
Note: According to StAX 1.0, coalesced text events are always to be returned as CHARACTERS, never as CDATA.int
nextTag()
private final void
parseAttrValue
(char openingQuote, TextBuilder tb) Method that will parse an attribute value enclosed in quotes, using anTextBuilder
instance.protected final void
parseQuoted
(String name, char quoteChar, TextBuffer tbuf) Method called to parse quoted xml declaration pseudo-attribute values.private int
Method called to read the contents of the current (possibly partially read) CDATA event, and write all contents using the specified Writer.private int
readAndWriteCoalesced
(Writer w, boolean wasCData) private int
Method called to read the contents of the current CHARACTERS event, and write all contents using the specified Writer.private final boolean
readCDataPrimary
(char c) Method called to read in consecutive beginning parts of a CDATA segment, up to either end of the segment (]] and >) or until first 'hole' in text (buffer end, 2-char lf to convert, entity).protected boolean
readCDataSecondary
(int shortestSegment) protected void
readCoalescedText
(int currType, boolean deferErrors) Method called to read the content of both current CDATA/CHARACTERS events, and all following consequtive events into the text buffer.private void
private void
protected final void
Method called to completely read a close tag, and update element stack appropriately (including checking that tag matches etc).private final int
readIndentation
(char c, int ptr) Method called to try to parse and canonicalize white space that has a good chance of being white space with somewhat regular structure; specifically, something that looks like typical indentation.private void
readPI()
Method that parses a processing instruction's data portion; at this point target has been parsed.private void
readPI2
(TextBuffer tb) private final int
Method that reads the primary part of a PI, ie.private final boolean
readSpacePrimary
(char c, boolean prologWS) Reading whitespace should be very similar to reading normal text; although couple of simplifications can be made.private void
readSpaceSecondary
(boolean prologWS) This is very similar to readSecondaryText(); called when we need to read in rest of (ignorable) white space segment.private final boolean
readTextPrimary
(char c) Method called to read in consecutive beginning parts of a text segment, up to either end of the segment (lt char) or until first 'hole' in text (buffer end, 2-char lf to convert, entity).protected final boolean
readTextSecondary
(int shortestSegment, boolean deferErrors) private void
protected void
reportInvalidContent
(int evtType) Stub method implemented by validating parsers, to report content that's not valid for current element context.private void
reportWrongEndElem
(String prefix, String localName, int done) private void
reportWrongEndPrefix
(String prefix, String localName, int done) void
protected void
protected void
void
setFeature
(String name, Object value) Deprecated.boolean
setProperty
(String name, Object value) org.codehaus.stax2.validation.ValidationProblemHandler
setValidationProblemHandler
(org.codehaus.stax2.validation.ValidationProblemHandler h) private int
skipCoalescedText
(int i) Method called to skip past all following text and CDATA segments, until encountering something else (including a general entity, which may in turn expand to text).private void
skipCommentOrCData
(String errorMsg, char endChar, boolean preventDoubles) void
protected final char
skipEquals
(String name, String eofMsg) Method that checks that input following is of form '[S]* '=' [S]*' (as per XML specs, production #25).private int
Method called to skip last part of current token, when full token has not been parsed.private int
skipTokenText
(int i) protected final boolean
skipWS
(char c) Method that will skip any white space from input source(s)boolean
private void
startDTD()
Method called to parse through most of DOCTYPE declaration; excluding optional internal subset.org.codehaus.stax2.validation.XMLValidator
stopValidatingAgainst
(org.codehaus.stax2.validation.XMLValidationSchema schema) org.codehaus.stax2.validation.XMLValidator
stopValidatingAgainst
(org.codehaus.stax2.validation.XMLValidator validator) private void
throwNotTextual
(int type) protected void
throwNotTextualOrElem
(int type) private void
throwNotTextXxx
(int type) protected void
Method called when we get an EOF within content treeorg.codehaus.stax2.validation.XMLValidator
validateAgainst
(org.codehaus.stax2.validation.XMLValidationSchema schema) withStartElement
(ElemCallback cb, Location loc) Method called byDefaultEventAllocator
to get double-indirection necessary for constructing start element events.Methods inherited from class com.ctc.wstx.sr.StreamScanner
_reportProblem, _reportProblem, closeAllInput, constructFromIOE, constructLimitViolation, constructNullCharException, constructWfcException, ensureInput, expandBy50Pct, expandEntity, fullyResolveEntity, getConfig, getCurrentInput, getCurrentLocation, getIntEntity, getLastCharLocation, getNameBuffer, getNext, getNextAfterWS, getNextChar, getNextCharAfterWS, getNextCharFromCurrent, getNextInCurrAfterWS, getNextInCurrAfterWS, getSource, getStartLocation, getSystemId, initInputSource, inputInBuffer, loadMore, loadMore, loadMoreFromCurrent, loadMoreFromCurrent, markLF, markLF, parseEntityName, parseFNameForError, parseFullName, parseFullName, parseFullName2, parseLocalName, parseLocalName2, parsePublicId, parseSystemId, parseUntil, peekNext, pushback, reportProblem, reportProblem, reportValidationProblem, reportValidationProblem, reportValidationProblem, reportValidationProblem, reportValidationProblem, resolveCharOnlyEntity, resolveNonCharEntity, resolveSimpleEntity, skipCRLF, skipFullName, throwFromIOE, throwFromStrE, throwInvalidSpace, throwInvalidSpace, throwLazyError, throwNullChar, throwNullParent, throwParseError, throwParseError, throwUnexpectedChar, throwUnexpectedEOB, throwUnexpectedEOF, throwWfcException, tokenTypeDesc, verifyLimit
Methods inherited from class com.ctc.wstx.io.WstxInputData
copyBufferStateFrom, findIllegalNameChar, findIllegalNmtokenChar, getCharDesc, isNameChar, isNameChar, isNameStartChar, isNameStartChar, isSpaceChar
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.codehaus.stax2.LocationInfo
getCurrentLocation, getStartLocation
Methods inherited from interface org.codehaus.stax2.typed.TypedXMLStreamReader
getAttributeAs, getAttributeAsArray, getAttributeAsBinary, getAttributeAsBinary, getAttributeAsBoolean, getAttributeAsDecimal, getAttributeAsDouble, getAttributeAsDoubleArray, getAttributeAsFloat, getAttributeAsFloatArray, getAttributeAsInt, getAttributeAsIntArray, getAttributeAsInteger, getAttributeAsLong, getAttributeAsLongArray, getAttributeAsQName, getAttributeIndex, getElementAs, getElementAsBinary, getElementAsBinary, getElementAsBoolean, getElementAsDecimal, getElementAsDouble, getElementAsFloat, getElementAsInt, getElementAsInteger, getElementAsLong, getElementAsQName, readElementAsArray, readElementAsBinary, readElementAsBinary, readElementAsDoubleArray, readElementAsFloatArray, readElementAsIntArray, readElementAsLongArray
-
Field Details
-
DOC_STANDALONE_UNKNOWN
static final int DOC_STANDALONE_UNKNOWN- See Also:
-
DOC_STANDALONE_YES
static final int DOC_STANDALONE_YES- See Also:
-
DOC_STANDALONE_NO
static final int DOC_STANDALONE_NO- See Also:
-
STATE_PROLOG
static final int STATE_PROLOG- See Also:
-
STATE_TREE
static final int STATE_TREE- See Also:
-
STATE_EPILOG
static final int STATE_EPILOG- See Also:
-
STATE_MULTIDOC_HACK
static final int STATE_MULTIDOC_HACK- See Also:
-
STATE_CLOSED
static final int STATE_CLOSED- See Also:
-
TOKEN_NOT_STARTED
static final int TOKEN_NOT_STARTED- See Also:
-
TOKEN_STARTED
static final int TOKEN_STARTED- See Also:
-
TOKEN_PARTIAL_SINGLE
static final int TOKEN_PARTIAL_SINGLE- See Also:
-
TOKEN_FULL_SINGLE
static final int TOKEN_FULL_SINGLE- See Also:
-
TOKEN_FULL_COALESCED
static final int TOKEN_FULL_COALESCED- See Also:
-
MASK_GET_TEXT
protected static final int MASK_GET_TEXTThis mask covers all types for which basicgetText()
method can be called.- See Also:
-
MASK_GET_TEXT_XXX
protected static final int MASK_GET_TEXT_XXXThis mask covers all types for which extendsgetTextXxx
methods can be called; which is less than those for whichgetText()
can be called. Specifically,DTD
andENTITY_REFERENCE
types do not support these extended- See Also:
-
MASK_GET_TEXT_WITH_WRITER
protected static final int MASK_GET_TEXT_WITH_WRITERThis mask is used with Stax2 getText() method (one that takes Writer as an argument): accepts even wider range of event types.- See Also:
-
MASK_GET_ELEMENT_TEXT
protected static final int MASK_GET_ELEMENT_TEXT- See Also:
-
ALL_WS_UNKNOWN
static final int ALL_WS_UNKNOWN- See Also:
-
ALL_WS_YES
static final int ALL_WS_YES- See Also:
-
ALL_WS_NO
static final int ALL_WS_NO- See Also:
-
INDENT_CHECK_START
private static final int INDENT_CHECK_START- See Also:
-
INDENT_CHECK_MAX
private static final int INDENT_CHECK_MAX- See Also:
-
sPrefixXml
-
sPrefixXmlns
-
mConfigFlags
protected final int mConfigFlagsSet of locally stored configuration flags -
mCfgCoalesceText
protected final boolean mCfgCoalesceText -
mCfgReportTextAsChars
protected final boolean mCfgReportTextAsChars -
mCfgLazyParsing
protected final boolean mCfgLazyParsing -
mShortestTextSegment
protected final int mShortestTextSegmentMinimum number of characters parser can return as partial text segment, IF it's not required to coalesce adjacent text segments. -
mOwner
Object to notify about shared stuff, such as symbol tables, as well as to query for additional config settings if necessary. -
mDocStandalone
protected int mDocStandaloneStatus about "stand-aloneness" of document; set to 'yes'/'no'/'unknown' based on whether there was xml declaration, and if so, whether it had standalone attribute. -
mRootPrefix
Prefix of root element, as dictated by DOCTYPE declaration; null if no DOCTYPE declaration, or no root prefix -
mRootLName
Local name of root element, as dictated by DOCTYPE declaration; null if no DOCTYPE declaration. -
mDtdPublicId
Public id of the DTD, if one exists and has been parsed. -
mDtdSystemId
System id of the DTD, if one exists and has been parsed. -
mTextBuffer
TextBuffer mostly used to collect non-element textual content (text, CDATA, comment content, pi data) -
mElementStack
Currently open element tree -
mAttrCollector
Object that stores information about currently accessible attributes. -
mStDoctypeFound
protected boolean mStDoctypeFound -
mTokenState
protected int mTokenStateState of the current token; one of M_ - constants from above.Initially set to fully tokenized, since it's the virtual START_DOCUMENT event that we fully know by now (parsed by bootstrapper)
-
mStTextThreshold
protected final int mStTextThresholdThreshold value that defines tokenization state that needs to be achieved to "finish" current logical text segment (which may consist of adjacent CDATA and text segments; or be a complete physical segment; or just even a fragment of such a segment) -
mCurrTextLength
protected int mCurrTextLengthSized of currentTextLength for CDATA, CHARACTERS, WHITESPACE. When segmenting, this records to size of all the segments so we can track if the text length has exceeded limits. -
mStEmptyElem
protected boolean mStEmptyElem -
mParseState
protected int mParseStateMain parsing/tokenization state (STATE_xxx) -
mCurrToken
protected int mCurrTokenCurrent state of the stream, ie token value returned bygetEventType()
. Needs to be initialized to START_DOCUMENT, since that's the state it starts in. -
mSecondaryToken
protected int mSecondaryTokenAdditional information sometimes stored (when generating dummy events in multi-doc mode, for example) temporarily whenmCurrToken
is already populated. -
mWsStatus
protected int mWsStatusStatus of current (text) token's "whitespaceness", that is, whether it is or is not all white space. -
mValidateText
protected boolean mValidateTextFlag that indicates that textual content (CDATA, CHARACTERS) is to be validated within current element's scope. Enabled if one of validators returnsXMLValidator.CONTENT_ALLOW_VALIDATABLE_TEXT
, and will prevent lazy parsing of text. -
mCheckIndentation
protected int mCheckIndentationCounter used for determining whether we are to try to heuristically "intern" white space that seems to be used for indentation purposes -
mPendingException
Due to the way Stax API does not allow throwing stream exceptions from many methods for which Woodstox would need to throw one (especiallygetText
and its variations), we may need to delay throwing an exception untilnext()
is called next time. If so, this variable holds the pending stream exception. -
mGeneralEntities
Entities parsed from internal/external DTD subsets. Although it will remain null for this class, extended classes make use of it, plus, to be able to share some of entity resolution code, instance is left here even though it semantically belongs to the sub-class. -
mVldContent
protected int mVldContentMode information needed at this level; mostly to check what kind of textual content (if any) is allowed in current element context. Constants come fromXMLValidator
, (likeXMLValidator.CONTENT_ALLOW_VALIDATABLE_TEXT
). Only used inside tree; ignored for prolog/epilog (which have straight-forward static rules). -
mReturnNullForDefaultNamespace
protected boolean mReturnNullForDefaultNamespaceConfiguration fromWstxInputProperties#RETURN_NULL_FOR_DEFAULT_NAMESPACE
- Since:
- 4.1.2
-
-
Constructor Details
-
BasicStreamReader
protected BasicStreamReader(InputBootstrapper bs, BranchingReaderSource input, ReaderCreator owner, ReaderConfig cfg, InputElementStack elemStack, boolean forER) throws XMLStreamException - Parameters:
elemStack
- Input element stack to use; if null, will create instance locally.forER
- Override indicator; if true, this stream reader will be used by an event reader, and should modify some of the base config settings appropriately. If false, configuration settings are to be used as is.- Throws:
XMLStreamException
-
-
Method Details
-
createElementStack
-
getCharacterEncodingScheme
As per Stax (1.0) specs, needs to return whatever xml declaration claimed encoding is, if any; or null if no xml declaration found.Note: method name is rather confusing (compare to
getEncoding()
).- Specified by:
getCharacterEncodingScheme
in interfaceXMLStreamReader
-
getEncoding
As per Stax (1.0) specs, needs to return whatever parser determined the encoding was, if it was able to figure it out. If not (there are cases where this can not be found; specifically when being passed aReader
), it should return null.- Specified by:
getEncoding
in interfaceXMLStreamReader
-
getVersion
- Specified by:
getVersion
in interfaceXMLStreamReader
-
isStandalone
public boolean isStandalone()- Specified by:
isStandalone
in interfaceXMLStreamReader
-
standaloneSet
public boolean standaloneSet()- Specified by:
standaloneSet
in interfaceXMLStreamReader
-
getProperty
- Specified by:
getProperty
in interfaceXMLStreamReader
-
getAttributeCount
public int getAttributeCount()- Specified by:
getAttributeCount
in interfaceXMLStreamReader
-
getAttributeLocalName
- Specified by:
getAttributeLocalName
in interfaceXMLStreamReader
-
getAttributeName
- Specified by:
getAttributeName
in interfaceXMLStreamReader
-
getAttributeNamespace
- Specified by:
getAttributeNamespace
in interfaceXMLStreamReader
-
getAttributePrefix
- Specified by:
getAttributePrefix
in interfaceXMLStreamReader
-
getAttributeType
- Specified by:
getAttributeType
in interfaceXMLStreamReader
-
getAttributeValue
- Specified by:
getAttributeValue
in interfaceXMLStreamReader
-
getAttributeValue
- Specified by:
getAttributeValue
in interfaceXMLStreamReader
-
getElementText
From StAX specs:Reads the content of a text-only element, an exception is thrown if this is not a text-only element. Regardless of value of javax.xml.stream.isCoalescing this method always returns coalesced content.
Precondition: the current event is START_ELEMENT.
Postcondition: the current event is the corresponding END_ELEMENT.- Specified by:
getElementText
in interfaceXMLStreamReader
- Throws:
XMLStreamException
-
getEventType
public int getEventType()Returns type of the last event returned; or START_DOCUMENT before any events has been explicitly returned.- Specified by:
getEventType
in interfaceXMLStreamReader
-
getLocalName
- Specified by:
getLocalName
in interfaceXMLStreamReader
-
getName
- Specified by:
getName
in interfaceXMLStreamReader
-
getNamespaceContext
- Specified by:
getNamespaceContext
in interfaceXMLStreamReader
-
getNamespaceCount
public int getNamespaceCount()- Specified by:
getNamespaceCount
in interfaceXMLStreamReader
-
getNamespacePrefix
- Specified by:
getNamespacePrefix
in interfaceXMLStreamReader
-
getNamespaceURI
- Specified by:
getNamespaceURI
in interfaceXMLStreamReader
-
getNamespaceURI
- Specified by:
getNamespaceURI
in interfaceXMLStreamReader
-
getNamespaceURI
- Specified by:
getNamespaceURI
in interfaceXMLStreamReader
-
getPIData
- Specified by:
getPIData
in interfaceXMLStreamReader
-
getPITarget
- Specified by:
getPITarget
in interfaceXMLStreamReader
-
getPrefix
- Specified by:
getPrefix
in interfaceXMLStreamReader
-
getText
- Specified by:
getText
in interfaceXMLStreamReader
-
getTextCharacters
public char[] getTextCharacters()- Specified by:
getTextCharacters
in interfaceXMLStreamReader
-
getTextCharacters
public int getTextCharacters(int sourceStart, char[] target, int targetStart, int len) - Specified by:
getTextCharacters
in interfaceXMLStreamReader
-
getTextLength
public int getTextLength()- Specified by:
getTextLength
in interfaceXMLStreamReader
-
getTextStart
public int getTextStart()- Specified by:
getTextStart
in interfaceXMLStreamReader
-
hasName
public boolean hasName()- Specified by:
hasName
in interfaceXMLStreamReader
-
hasNext
public boolean hasNext()- Specified by:
hasNext
in interfaceXMLStreamReader
-
hasText
public boolean hasText()- Specified by:
hasText
in interfaceXMLStreamReader
-
isAttributeSpecified
public boolean isAttributeSpecified(int index) - Specified by:
isAttributeSpecified
in interfaceXMLStreamReader
-
isCharacters
public boolean isCharacters()- Specified by:
isCharacters
in interfaceXMLStreamReader
-
isEndElement
public boolean isEndElement()- Specified by:
isEndElement
in interfaceXMLStreamReader
-
isStartElement
public boolean isStartElement()- Specified by:
isStartElement
in interfaceXMLStreamReader
-
isWhiteSpace
public boolean isWhiteSpace()05-Apr-2004, TSa: Could try to determine status when text is actually read. That'd prevent double reads... but would it slow down that one reading so that net effect would be negative?
- Specified by:
isWhiteSpace
in interfaceXMLStreamReader
-
require
- Specified by:
require
in interfaceXMLStreamReader
- Throws:
XMLStreamException
-
next
- Specified by:
next
in interfaceXMLStreamReader
- Throws:
XMLStreamException
-
nextTag
- Specified by:
nextTag
in interfaceXMLStreamReader
- Throws:
XMLStreamException
-
close
Note: as per StAX 1.0 specs, this method does NOT close the underlying input reader. That is, unless the new StAX2 property
XMLInputFactory2.P_AUTO_CLOSE_INPUT
is set to true.- Specified by:
close
in interfaceXMLStreamReader
- Throws:
XMLStreamException
-
getFeature
Deprecated.- Specified by:
getFeature
in interfaceorg.codehaus.stax2.XMLStreamReader2
-
setFeature
Deprecated.- Specified by:
setFeature
in interfaceorg.codehaus.stax2.XMLStreamReader2
-
isPropertySupported
- Specified by:
isPropertySupported
in interfaceorg.codehaus.stax2.XMLStreamReader2
-
setProperty
- Specified by:
setProperty
in interfaceorg.codehaus.stax2.XMLStreamReader2
- Parameters:
name
- Name of the property to setvalue
- Value to set property to.- Returns:
- True, if the specified property was succesfully set to specified value; false if its value was not changed
-
skipElement
- Specified by:
skipElement
in interfaceorg.codehaus.stax2.XMLStreamReader2
- Throws:
XMLStreamException
-
getAttributeInfo
- Specified by:
getAttributeInfo
in interfaceorg.codehaus.stax2.XMLStreamReader2
- Throws:
XMLStreamException
-
getDTDInfo
Since this class implementsDTDInfo
, method can just returnthis
.- Specified by:
getDTDInfo
in interfaceorg.codehaus.stax2.XMLStreamReader2
- Throws:
XMLStreamException
-
getLocationInfo
public final org.codehaus.stax2.LocationInfo getLocationInfo()Location information is always accessible, for this reader.- Specified by:
getLocationInfo
in interfaceorg.codehaus.stax2.XMLStreamReader2
-
getText
Method similar togetText()
, except that it just uses provided Writer to write all textual content. For further optimization, it may also be allowed to do true pass-through, thus possibly avoiding one temporary copy of the data.TODO: try to optimize to allow completely streaming pass-through: currently will still read all data in memory buffers before outputting
- Specified by:
getText
in interfaceorg.codehaus.stax2.XMLStreamReader2
- Parameters:
w
- Writer to use for writing textual contentspreserveContents
- If true, reader has to preserve contents so that further calls togetText
will return proper conntets. If false, reader is allowed to skip creation of such copies: this can improve performance, but it also means that further calls togetText
is not guaranteed to return meaningful data.- Returns:
- Number of characters written to the reader
- Throws:
IOException
XMLStreamException
-
getDepth
public int getDepth()- Specified by:
getDepth
in interfaceorg.codehaus.stax2.XMLStreamReader2
- Returns:
- Number of open elements in the stack; 0 when parser is in prolog/epilog, 1 inside root element and so on.
-
isEmptyElement
- Specified by:
isEmptyElement
in interfaceorg.codehaus.stax2.XMLStreamReader2
- Returns:
- True, if cursor points to a start or end element that is
constructed from 'empty' element (ends with
'/>'
); false otherwise. - Throws:
XMLStreamException
-
getNonTransientNamespaceContext
- Specified by:
getNonTransientNamespaceContext
in interfaceorg.codehaus.stax2.XMLStreamReader2
-
getPrefixedName
- Specified by:
getPrefixedName
in interfaceorg.codehaus.stax2.XMLStreamReader2
-
closeCompletely
- Specified by:
closeCompletely
in interfaceorg.codehaus.stax2.XMLStreamReader2
- Throws:
XMLStreamException
-
getProcessedDTD
Note: DTD-handling sub-classes need to override this method.
- Specified by:
getProcessedDTD
in interfaceorg.codehaus.stax2.DTDInfo
-
getDTDRootName
- Specified by:
getDTDRootName
in interfaceorg.codehaus.stax2.DTDInfo
-
getDTDPublicId
- Specified by:
getDTDPublicId
in interfaceorg.codehaus.stax2.DTDInfo
-
getDTDSystemId
- Specified by:
getDTDSystemId
in interfaceorg.codehaus.stax2.DTDInfo
-
getDTDInternalSubset
- Specified by:
getDTDInternalSubset
in interfaceorg.codehaus.stax2.DTDInfo
- Returns:
- Internal subset portion of the DOCTYPE declaration, if any; empty String if none
-
getDTDInternalSubsetArray
private char[] getDTDInternalSubsetArray()Internal method used by implementation -
getProcessedDTDSchema
public org.codehaus.stax2.validation.DTDValidationSchema getProcessedDTDSchema()Sub-class will override this method- Specified by:
getProcessedDTDSchema
in interfaceorg.codehaus.stax2.DTDInfo
-
getStartingByteOffset
public long getStartingByteOffset()- Specified by:
getStartingByteOffset
in interfaceorg.codehaus.stax2.LocationInfo
-
getStartingCharOffset
public long getStartingCharOffset()- Specified by:
getStartingCharOffset
in interfaceorg.codehaus.stax2.LocationInfo
-
getEndingByteOffset
- Specified by:
getEndingByteOffset
in interfaceorg.codehaus.stax2.LocationInfo
- Throws:
XMLStreamException
-
getEndingCharOffset
- Specified by:
getEndingCharOffset
in interfaceorg.codehaus.stax2.LocationInfo
- Throws:
XMLStreamException
-
getLocation
Description copied from class:StreamScanner
Returns location of last properly parsed token; as per StAX specs, apparently needs to be the end of current event, which is the same as the start of the following event (or EOF if that's next).- Specified by:
getLocation
in interfaceInputProblemReporter
- Specified by:
getLocation
in interfaceorg.codehaus.stax2.LocationInfo
- Specified by:
getLocation
in interfaceXMLStreamReader
- Specified by:
getLocation
in classStreamScanner
-
getEndLocation
- Specified by:
getEndLocation
in interfaceorg.codehaus.stax2.LocationInfo
- Throws:
XMLStreamException
-
validateAgainst
public org.codehaus.stax2.validation.XMLValidator validateAgainst(org.codehaus.stax2.validation.XMLValidationSchema schema) throws XMLStreamException - Specified by:
validateAgainst
in interfaceorg.codehaus.stax2.validation.Validatable
- Throws:
XMLStreamException
-
stopValidatingAgainst
public org.codehaus.stax2.validation.XMLValidator stopValidatingAgainst(org.codehaus.stax2.validation.XMLValidationSchema schema) throws XMLStreamException - Specified by:
stopValidatingAgainst
in interfaceorg.codehaus.stax2.validation.Validatable
- Throws:
XMLStreamException
-
stopValidatingAgainst
public org.codehaus.stax2.validation.XMLValidator stopValidatingAgainst(org.codehaus.stax2.validation.XMLValidator validator) throws XMLStreamException - Specified by:
stopValidatingAgainst
in interfaceorg.codehaus.stax2.validation.Validatable
- Throws:
XMLStreamException
-
setValidationProblemHandler
public org.codehaus.stax2.validation.ValidationProblemHandler setValidationProblemHandler(org.codehaus.stax2.validation.ValidationProblemHandler h) - Specified by:
setValidationProblemHandler
in interfaceorg.codehaus.stax2.validation.Validatable
-
getCurrentEntityDecl
- Specified by:
getCurrentEntityDecl
in interfaceStreamReaderImpl
-
withStartElement
Method called byDefaultEventAllocator
to get double-indirection necessary for constructing start element events.- Specified by:
withStartElement
in interfaceStreamReaderImpl
- Returns:
- Null, if stream does not point to start element; whatever callback returns otherwise.
-
isNamespaceAware
public boolean isNamespaceAware()- Specified by:
isNamespaceAware
in interfaceStreamReaderImpl
-
getInputElementStack
Method needed by classes (like stream writer implementations) that want to have efficient direct access to element stack implementation- Specified by:
getInputElementStack
in interfaceStreamReaderImpl
-
getAttributeCollector
Method needed by classes (like stream writer implementations) that want to have efficient direct access to attribute collector Object, for optimal attribute name and value access.- Specified by:
getAttributeCollector
in interfaceStreamReaderImpl
-
fireSaxStartElement
- Throws:
SAXException
-
fireSaxEndElement
- Throws:
SAXException
-
fireSaxCharacterEvents
- Throws:
XMLStreamException
SAXException
-
fireSaxSpaceEvents
- Throws:
XMLStreamException
SAXException
-
fireSaxCommentEvent
- Throws:
XMLStreamException
SAXException
-
fireSaxPIEvent
- Throws:
XMLStreamException
SAXException
-
hasConfigFlags
protected final boolean hasConfigFlags(int flags) -
checkKeyword
- Returns:
- Null, if keyword matches ok; String that contains erroneous keyword if not.
- Throws:
XMLStreamException
-
checkCData
- Throws:
XMLStreamException
-
parseAttrValue
Method that will parse an attribute value enclosed in quotes, using anTextBuilder
instance. Will normalize white space inside attribute value using default XML rules (change linefeeds to spaces etc.; but won't use DTD information for further coalescing).- Parameters:
openingQuote
- Quote character (single or double quote) for this attribute valuetb
- TextBuilder into which attribute value will be added- Throws:
XMLStreamException
-
_outputLimit
private final int _outputLimit(char[] outBuf, int offset, int maxAttrLen) -
_checkAttributeLimit
private final char[] _checkAttributeLimit(TextBuilder tb, char[] outBuf, int outPtr, int currAttrSize, int maxAttrSize) throws XMLStreamException - Throws:
XMLStreamException
-
nextFromProlog
Method called to find type of next token in prolog; either reading just enough information to know the type (lazy parsing), or the full contents (non-lazy)- Returns:
- True if we hit EOI, false otherwise
- Throws:
XMLStreamException
-
handleRootElem
- Throws:
XMLStreamException
-
initValidation
Method called right before the document root element is handled. The default implementation is empty; validating stream readers should override the method and do whatever initialization is necessary- Throws:
XMLStreamException
-
handleEOF
- Throws:
XMLStreamException
-
handleExtraRoot
Method called if a root-level element is found after the main root element was closed. This is legal in multi-doc parsing mode (and in fragment mode), but not in the default single-doc mode.- Parameters:
c
- Character passed in (not currently used)- Returns:
- Token to return
- Throws:
XMLStreamException
-
handleMultiDocStart
protected int handleMultiDocStart(int nextEvent) Method called when an event was encountered that indicates document boundary in multi-doc mode. Needs to trigger dummy END_DOCUMENT/START_DOCUMENT event combination, followed by the handling of the original event.- Returns:
- Event type to return
-
nextFromMultiDocState
Method called to get the next event when we are "multi-doc hack" mode, during which extra END_DOCUMENT/START_DOCUMENT events need to be returned.- Throws:
XMLStreamException
-
handleMultiDocXmlDecl
- Throws:
XMLStreamException
-
skipEquals
Method that checks that input following is of form '[S]* '=' [S]*' (as per XML specs, production #25). Will push back non-white space characters as necessary, in case no equals char is encountered.- Throws:
XMLStreamException
-
parseQuoted
protected final void parseQuoted(String name, char quoteChar, TextBuffer tbuf) throws XMLStreamException Method called to parse quoted xml declaration pseudo-attribute values. Works similar to attribute value parsing, except no entities can be included, and in general need not be as picky (since caller is to verify contents). One exception is that we do check for linefeeds and lt chars, since they generally would indicate problems and are useful to catch early on (can happen if a quote is missed etc)Note: since it'll be called at most 3 times per document, this method is not optimized too much.
- Throws:
XMLStreamException
-
nextFromPrologBang
Called after character sequence '<!' has been found; expectation is that it'll either be DOCTYPE declaration (if we are in prolog and haven't yet seen one), or a comment. CDATA is not legal here; it would start same way otherwise.- Throws:
XMLStreamException
-
startDTD
Method called to parse through most of DOCTYPE declaration; excluding optional internal subset.- Throws:
XMLStreamException
-
finishDTD
This method gets called to handle remainder of DOCTYPE declaration, essentially the optional internal subset. This class implements the basic "ignore it" functionality, but can optionally still store copy of the contents to the read buffer.NOTE: Since this default implementation will be overridden by some sub-classes, make sure you do NOT change the method signature.
- Parameters:
copyContents
- If true, will copy contents of the internal subset of DOCTYPE declaration in the text buffer; if false, will just completely ignore the subset (if one found).- Throws:
XMLStreamException
-
nextFromTree
Method called to parse beginning of the next event within document tree, and return its type.- Throws:
XMLStreamException
-
closeContentTree
Method called when advancing stream past the end tag that closes the root element of the open document. Document can be either the singular one, in regular mode, or one of possibly multiple, in multi-doc mode: this method is never called in fragment mode. Method needs to update state properly and parse following epilog event (if any).- Returns:
- Event following end tag of the root elemennt, if any; END_DOCUMENT otherwis.e
- Throws:
XMLStreamException
-
handleStartElem
Method that takes care of parsing of start elements; including full parsing of namespace declarations and attributes, as well as namespace resolution.- Throws:
XMLStreamException
-
handleNsAttrs
- Returns:
- True if this is an empty element; false if not
- Throws:
XMLStreamException
-
handleNonNsAttrs
- Returns:
- True if this is an empty element; false if not
- Throws:
XMLStreamException
-
readEndElem
Method called to completely read a close tag, and update element stack appropriately (including checking that tag matches etc).- Throws:
XMLStreamException
-
reportExtraEndElem
- Throws:
XMLStreamException
-
reportWrongEndPrefix
private void reportWrongEndPrefix(String prefix, String localName, int done) throws XMLStreamException - Throws:
XMLStreamException
-
reportWrongEndElem
private void reportWrongEndElem(String prefix, String localName, int done) throws XMLStreamException - Throws:
XMLStreamException
-
nextFromTreeCommentOrCData
Note: According to StAX 1.0, coalesced text events are always to be returned as CHARACTERS, never as CDATA. And since at this point we don't really know if there's anything to coalesce (but there may be), let's convert CDATA if necessary.
- Throws:
XMLStreamException
-
skipToken
Method called to skip last part of current token, when full token has not been parsed. Generally happens when caller is not interested in current token and just calls next() to iterate to next token.Note: this method is to accurately update the location information to reflect where the next event will start (or, in case of EOF, where EOF was encountered, ie. where event would start, if there was one).
- Returns:
- Next character after node has been skipped, or -1 if EOF follows
- Throws:
XMLStreamException
-
skipCommentOrCData
private void skipCommentOrCData(String errorMsg, char endChar, boolean preventDoubles) throws XMLStreamException - Throws:
XMLStreamException
-
skipCoalescedText
Method called to skip past all following text and CDATA segments, until encountering something else (including a general entity, which may in turn expand to text).- Returns:
- Character following all the skipped text and CDATA segments, if any; or -1 to denote EOF
- Throws:
XMLStreamException
-
skipTokenText
- Throws:
XMLStreamException
-
ensureFinishToken
- Throws:
XMLStreamException
-
safeEnsureFinishToken
protected void safeEnsureFinishToken() -
safeFinishToken
protected void safeFinishToken() -
finishToken
Method called to read in contents of the token completely, if not yet read. Generally called when caller needs to access anything other than basic token type (except for elements), text contents or such.- Parameters:
deferErrors
- Flag to enable storing an exception to a variable, instead of immediately throwing it. If true, will just store the exception; if false, will not store, just throw.- Throws:
XMLStreamException
-
readComment
- Throws:
XMLStreamException
-
readComment2
- Throws:
XMLStreamException
-
readPIPrimary
Method that reads the primary part of a PI, ie. target, and also skips white space between target and data (if any data)- Returns:
- Usually
PROCESSING_INSTRUCTION
; but may be different in multi-doc mode, if we actually hit a secondary xml declaration. - Throws:
XMLStreamException
-
readPI
Method that parses a processing instruction's data portion; at this point target has been parsed.- Throws:
XMLStreamException
-
readPI2
- Throws:
XMLStreamException
-
readCoalescedText
Method called to read the content of both current CDATA/CHARACTERS events, and all following consequtive events into the text buffer. At this point the current type is known, prefix (for CDATA) skipped, and initial consequtive contents (if any) read in.- Parameters:
deferErrors
- Flag to enable storing an exception to a variable, instead of immediately throwing it. If true, will just store the exception; if false, will not store, just throw.- Throws:
XMLStreamException
-
readCDataPrimary
Method called to read in consecutive beginning parts of a CDATA segment, up to either end of the segment (]] and >) or until first 'hole' in text (buffer end, 2-char lf to convert, entity).When the method is called, it's expected that the first character has been read as is in the current input buffer just before current pointer
- Parameters:
c
- First character in the CDATA segment (possibly part of end marker for empty segments- Returns:
- True if the whole CDATA segment was completely read; this happens only if lt-char is hit; false if it's possible that it wasn't read (ie. end-of-buffer or entity encountered).
- Throws:
XMLStreamException
-
readCDataSecondary
- Returns:
- True if the whole CData section was completely read (we hit the end marker); false if a shorter segment was returned.
- Throws:
XMLStreamException
-
checkCDataEnd
Method that will check, given the starting ']', whether there is ending ']]>' (including optional extra ']'s); if so, will updated output buffer with extra ]s, if not, will make sure input and output are positioned for further checking.- Returns:
- True, if we hit the end marker; false if not.
- Throws:
XMLStreamException
-
readTextPrimary
Method called to read in consecutive beginning parts of a text segment, up to either end of the segment (lt char) or until first 'hole' in text (buffer end, 2-char lf to convert, entity).When the method is called, it's expected that the first character has been read as is in the current input buffer just before current pointer
- Parameters:
c
- First character of the text segment- Returns:
- True if the whole text segment was completely read; this happens only if lt-char is hit; false if it's possible that it wasn't read (ie. end-of-buffer or entity encountered).
- Throws:
XMLStreamException
-
readTextSecondary
protected final boolean readTextSecondary(int shortestSegment, boolean deferErrors) throws XMLStreamException - Parameters:
deferErrors
- Flag to enable storing an exception to a variable, instead of immediately throwing it. If true, will just store the exception; if false, will not store, just throw.- Returns:
- True if the text segment was completely read (
'<'
was hit, or in non-entity-expanding mode, a non-char entity); false if it may still continue - Throws:
XMLStreamException
-
_expandOutputForText
private final char[] _expandOutputForText(int inputPtr, char[] outBuf, int shortestSegment) -
readIndentation
Method called to try to parse and canonicalize white space that has a good chance of being white space with somewhat regular structure; specifically, something that looks like typical indentation.Note: Caller guarantees that there will be at least 2 characters available in the input buffer. And method has to ensure that if it does not find a match, it will return pointer value such that there is at least one valid character remaining.
- Returns:
- -1, if the content was determined to be canonicalizable (indentation) white space; and thus fully parsed. Otherwise pointer (value to set to mInputPtr) to the next character to process (not processed by this method)
- Throws:
XMLStreamException
-
readSpacePrimary
Reading whitespace should be very similar to reading normal text; although couple of simplifications can be made. Further, since this method is very unlikely to be of much performance concern, some optimizations are left out, where it simplifies code.- Parameters:
c
- First white space characters; known to contain white space at this pointprologWS
- If true, is reading white space outside XML tree, and as such can get EOF. If false, should not get EOF, nor be followed by any other char than <- Returns:
- True if the whole white space segment was read; false if something prevented that (end of buffer, replaceable 2-char lf)
- Throws:
XMLStreamException
-
readSpaceSecondary
This is very similar to readSecondaryText(); called when we need to read in rest of (ignorable) white space segment.- Parameters:
prologWS
- True if the ignorable white space is within prolog (or epilog); false if it's within xml tree.- Throws:
XMLStreamException
-
readAndWriteText
Method called to read the contents of the current CHARACTERS event, and write all contents using the specified Writer.- Parameters:
w
- Writer to use for writing out textual content parsed- Returns:
- Total number of characters written using the writer
- Throws:
IOException
XMLStreamException
-
readAndWriteCData
Method called to read the contents of the current (possibly partially read) CDATA event, and write all contents using the specified Writer.- Parameters:
w
- Writer to use for writing out textual content parsed- Returns:
- Total number of characters written using the writer for the current CDATA event
- Throws:
IOException
XMLStreamException
-
readAndWriteCoalesced
private int readAndWriteCoalesced(Writer w, boolean wasCData) throws IOException, XMLStreamException - Returns:
- Number of characters written to Writer during the call
- Throws:
IOException
XMLStreamException
-
skipWS
Method that will skip any white space from input source(s)- Returns:
- true If at least one white space was skipped; false if not (character passed was not white space)
- Throws:
XMLStreamException
-
findEntity
Description copied from class:StreamScanner
Abstract method for sub-classes to implement, for finding a declared general or parsed entity.- Specified by:
findEntity
in classStreamScanner
- Parameters:
id
- Identifier of the entity to findarg
- Optional argument passed from caller; needed by DTD reader.- Throws:
XMLStreamException
-
handleUndeclaredEntity
Description copied from class:StreamScanner
This method gets called if a declaration for an entity was not found in entity expanding mode (enabled by default for xml reader, always enabled for dtd reader).- Specified by:
handleUndeclaredEntity
in classStreamScanner
- Throws:
XMLStreamException
-
handleIncompleteEntityProblem
- Specified by:
handleIncompleteEntityProblem
in classStreamScanner
- Throws:
XMLStreamException
-
handleGreedyEntityProblem
This problem gets reported if an entity tries to expand to a close tag matching start tag that did not came from the same entity (but from parent).- Throws:
XMLStreamException
-
throwNotTextual
private void throwNotTextual(int type) -
throwNotTextXxx
private void throwNotTextXxx(int type) -
throwNotTextualOrElem
protected void throwNotTextualOrElem(int type) -
throwUnexpectedEOF
Method called when we get an EOF within content tree- Throws:
WstxException
-
_constructUnexpectedInTyped
Method called to report a problem with -
_constructTypeException
-
reportInvalidContent
Stub method implemented by validating parsers, to report content that's not valid for current element context. Defined at this level since some such problems need to be caught at low-level; however, details of error reports are not needed here.- Parameters:
evtType
- Type of event that contained unexpected content- Throws:
XMLStreamException
-