Class BasicStreamReader
- java.lang.Object
-
- com.ctc.wstx.io.WstxInputData
-
- com.ctc.wstx.sr.StreamScanner
-
- com.ctc.wstx.sr.BasicStreamReader
-
- All Implemented Interfaces:
InputConfigFlags,ParsingErrorMsgs,InputProblemReporter,StreamReaderImpl,XMLStreamConstants,XMLStreamReader,DTDInfo,LocationInfo,TypedXMLStreamReader,Validatable,XMLStreamReader2
- Direct Known Subclasses:
TypedStreamReader
public abstract class BasicStreamReader extends StreamScanner implements StreamReaderImpl, DTDInfo, LocationInfo
Partial implementation ofXMLStreamReader2consisting of all functionality other than DTD-validation-specific parts, and Typed Access API (Stax2 v3.0), which are implemented at sub-classes.- Author:
- Tatu Saloranta
-
-
Field Summary
Fields Modifier and Type Field Description protected static intMASK_GET_ELEMENT_TEXTprotected static intMASK_GET_TEXTThis mask covers all types for which basicgetText()method can be called.protected static intMASK_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.protected static intMASK_GET_TEXT_XXXThis mask covers all types for which extendsgetTextXxxmethods can be called; which is less than those for whichgetText()can be called.protected AttributeCollectormAttrCollectorObject that stores information about currently accessible attributes.protected booleanmCfgCoalesceTextprotected booleanmCfgLazyParsingprotected booleanmCfgReportTextAsCharsprotected intmCheckIndentationCounter used for determining whether we are to try to heuristically "intern" white space that seems to be used for indentation purposesprotected intmConfigFlagsSet of locally stored configuration flagsprotected intmCurrTextLengthSized of currentTextLength for CDATA, CHARACTERS, WHITESPACE.protected intmCurrTokenCurrent state of the stream, ie token value returned bygetEventType().protected intmDocStandaloneStatus 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 StringmDtdPublicIdPublic id of the DTD, if one exists and has been parsed.protected StringmDtdSystemIdSystem id of the DTD, if one exists and has been parsed.protected InputElementStackmElementStackCurrently open element treeprotected Map<String,EntityDecl>mGeneralEntitiesEntities parsed from internal/external DTD subsets.protected ReaderCreatormOwnerObject to notify about shared stuff, such as symbol tables, as well as to query for additional config settings if necessary.protected intmParseStateMain parsing/tokenization state (STATE_xxx)protected XMLStreamExceptionmPendingExceptionDue to the way Stax API does not allow throwing stream exceptions from many methods for which Woodstox would need to throw one (especiallygetTextand its variations), we may need to delay throwing an exception untilnext()is called next time.protected booleanmReturnNullForDefaultNamespaceConfiguration fromXMLStreamProperties.RETURN_NULL_FOR_DEFAULT_NAMESPACEprotected StringmRootLNameLocal name of root element, as dictated by DOCTYPE declaration; null if no DOCTYPE declaration.protected StringmRootPrefixPrefix of root element, as dictated by DOCTYPE declaration; null if no DOCTYPE declaration, or no root prefixprotected intmSecondaryTokenAdditional information sometimes stored (when generating dummy events in multi-doc mode, for example) temporarily whenmCurrTokenis already populated.protected intmShortestTextSegmentMinimum number of characters parser can return as partial text segment, IF it's not required to coalesce adjacent text segments.protected booleanmStDoctypeFoundprotected booleanmStEmptyElemprotected intmStTextThresholdThreshold 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 TextBuffermTextBufferTextBuffer mostly used to collect non-element textual content (text, CDATA, comment content, pi data)protected intmTokenStateState of the current token; one of M_ - constants from above.protected booleanmValidateTextFlag that indicates that textual content (CDATA, CHARACTERS) is to be validated within current element's scope.protected intmVldContentMode information needed at this level; mostly to check what kind of textual content (if any) is allowed in current element context.protected intmWsStatusStatus of current (text) token's "whitespaceness", that is, whether it is or is not all white space.protected static StringsPrefixXmlprotected static StringsPrefixXmlns-
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, mCachedEntities, mCfgNsEnabled, mCfgReplaceEntities, mCfgTreatCharRefsAsEntities, mConfig, mCurrDepth, mCurrEntity, mCurrName, mDocInputEncoding, mDocXmlEncoding, mDocXmlVersion, mEntityExpansionCount, mEntityResolver, mInput, mInputTopDepth, mNameBuffer, mNormalizeLFs, mRootInput, 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_AUTO_CLOSE_INPUT, CFG_CACHE_DTDS, CFG_CACHE_DTDS_BY_PUBLIC_ID, CFG_COALESCE_TEXT, CFG_INTERN_NAMES, CFG_INTERN_NS_URIS, 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
Constructors Modifier Constructor Description protectedBasicStreamReader(InputBootstrapper bs, BranchingReaderSource input, ReaderCreator owner, ReaderConfig cfg, InputElementStack elemStack, boolean forER)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected TypedXMLStreamException_constructTypeException(String msg, String lexicalValue)protected XMLStreamException_constructUnexpectedInTyped(int nextToken)Method called to report a problem withprotected voidcheckCData()protected StringcheckKeyword(char c, String expected)voidclose()Note: as per StAX 1.0 specs, this method does NOT close the underlying input reader.voidcloseCompletely()Method similar toXMLStreamReader.close(), except that this method also does close the underlying input source if it has not yet been closed.protected static InputElementStackcreateElementStack(ReaderConfig cfg)protected voidensureFinishToken()protected EntityDeclfindEntity(String id, Object arg)Abstract method for sub-classes to implement, for finding a declared general or parsed entity.protected voidfinishDTD(boolean copyContents)This method gets called to handle remainder of DOCTYPE declaration, essentially the optional internal subset.protected voidfinishToken(boolean deferErrors)Method called to read in contents of the token completely, if not yet read.voidfireSaxCharacterEvents(ContentHandler h)voidfireSaxCommentEvent(LexicalHandler h)voidfireSaxEndElement(ContentHandler h)voidfireSaxPIEvent(ContentHandler h)voidfireSaxSpaceEvents(ContentHandler h)voidfireSaxStartElement(ContentHandler h, Attributes attrs)AttributeCollectorgetAttributeCollector()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.intgetAttributeCount()AttributeInfogetAttributeInfo()Method that can be called to get additional information about attributes related to the current start element, as well as related DTD-based information if available.StringgetAttributeLocalName(int index)QNamegetAttributeName(int index)StringgetAttributeNamespace(int index)StringgetAttributePrefix(int index)StringgetAttributeType(int index)StringgetAttributeValue(int index)StringgetAttributeValue(String nsURI, String localName)StringgetCharacterEncodingScheme()As per Stax (1.0) specs, needs to return whatever xml declaration claimed encoding is, if any; or null if no xml declaration found.EntityDeclgetCurrentEntityDecl()intgetDepth()Method that returns the number of open elements in the stack; 0 when the reader is in prolog/epilog, 1 inside root element (including when pointing at the root element itself) and so on.DTDInfogetDTDInfo()Since this class implementsDTDInfo, method can just returnthis.StringgetDTDInternalSubset()StringgetDTDPublicId()StringgetDTDRootName()StringgetDTDSystemId()StringgetElementText()From StAX specs: Reads the content of a text-only element, an exception is thrown if this is not a text-only element.StringgetEncoding()As per Stax (1.0) specs, needs to return whatever parser determined the encoding was, if it was able to figure it out.longgetEndingByteOffset()Method that can be used to get exact byte offset (number of bytes read from the stream right before getting to this location) in the stream that is pointed to by this reader, right after the end of the current event.longgetEndingCharOffset()Method that can be used to get exact character offset (number of chars read from the stream right before getting to this location) in the stream that is pointed to by this reader, right after the end of the current event.XMLStreamLocation2getEndLocation()An optional method that either returns the location object that points the ending position of the current event, or null if implementation does not keep track of it (some may return only start location; and some no location at all).intgetEventType()Returns type of the last event returned; or START_DOCUMENT before any events has been explicitly returned.ObjectgetFeature(String name)Deprecated.InputElementStackgetInputElementStack()Method needed by classes (like stream writer implementations) that want to have efficient direct access to element stack implementationStringgetLocalName()LocationgetLocation()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).LocationInfogetLocationInfo()Location information is always accessible, for this reader.QNamegetName()NamespaceContextgetNamespaceContext()intgetNamespaceCount()StringgetNamespacePrefix(int index)StringgetNamespaceURI()StringgetNamespaceURI(int index)StringgetNamespaceURI(String prefix)NamespaceContextgetNonTransientNamespaceContext()This method returns a namespace context object that contains information identical to that returned byXMLStreamReader.getNamespaceContext(), but one that is not transient.StringgetPIData()StringgetPITarget()StringgetPrefix()StringgetPrefixedName()This method returns "prefix-qualified" name of the current element.ObjectgetProcessedDTD()Note: DTD-handling sub-classes need to override this method.DTDValidationSchemagetProcessedDTDSchema()Sub-class will override this methodObjectgetProperty(String name)longgetStartingByteOffset()Method that can be used to get exact byte offset (number of bytes read from the stream right before getting to this location) in the stream that is pointed to by this reader, right before the start of the current event.longgetStartingCharOffset()Method that can be used to get exact character offset (number of chars read from the stream right before getting to this location) in the stream that is pointed to by this reader, right before the start of the current event.StringgetText()intgetText(Writer w, boolean preserveContents)Method similar togetText(), except that it just uses provided Writer to write all textual content.char[]getTextCharacters()intgetTextCharacters(int sourceStart, char[] target, int targetStart, int len)intgetTextLength()intgetTextStart()StringgetVersion()protected inthandleEOF(boolean isProlog)protected voidhandleGreedyEntityProblem(WstxInputSource input)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 voidhandleIncompleteEntityProblem(WstxInputSource closing)protected inthandleMultiDocStart(int nextEvent)Method called when an event was encountered that indicates document boundary in multi-doc mode.protected voidhandleMultiDocXmlDecl()protected voidhandleRootElem(char c)protected voidhandleUndeclaredEntity(String id)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 booleanhasConfigFlags(int flags)booleanhasName()booleanhasNext()booleanhasText()protected voidinitValidation()Method called right before the document root element is handled.booleanisAttributeSpecified(int index)booleanisCharacters()booleanisEmptyElement()Method that can be used to check whether current START_ELEMENT event was created for an empty element (xml short-hand notation where one tag implies start and end, ending with "/>"), or not.booleanisEndElement()booleanisNamespaceAware()booleanisPropertySupported(String name)Method similar toXMLInputFactory.isPropertySupported(java.lang.String), used to determine whether a property is supported by the Reader instance.booleanisStandalone()booleanisStartElement()booleanisWhiteSpace()05-Apr-2004, TSa: Could try to determine status when text is actually read.intnext()intnextTag()protected voidparseQuoted(String name, char quoteChar, TextBuffer tbuf)Method called to parse quoted xml declaration pseudo-attribute values.protected booleanreadCDataSecondary(int shortestSegment)protected voidreadCoalescedText(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.protected voidreadEndElem()Method called to completely read a close tag, and update element stack appropriately (including checking that tag matches etc).protected booleanreadTextSecondary(int shortestSegment, boolean deferErrors)protected voidreportInvalidContent(int evtType)Stub method implemented by validating parsers, to report content that's not valid for current element context.voidrequire(int type, String nsUri, String localName)protected voidsafeEnsureFinishToken()protected voidsafeFinishToken()voidsetFeature(String name, Object value)Deprecated.booleansetProperty(String name, Object value)Method that can be used to set per-reader properties; a subset of properties one can set via matchingXMLInputFactory2instance.ValidationProblemHandlersetValidationProblemHandler(ValidationProblemHandler h)Method that application can call to define a custom handler for validation problems encountered during validation process.voidskipElement()Method that will skip all the contents of the element that the stream currently points to.protected charskipEquals(String name, String eofMsg)Method that checks that input following is of form '[S]* '=' [S]*' (as per XML specs, production #25).protected booleanskipWS(char c)Method that will skip any white space from input source(s)booleanstandaloneSet()XMLValidatorstopValidatingAgainst(XMLValidationSchema schema)Method that can be called by application to stop validating output against a schema, for whichValidatable.validateAgainst(org.codehaus.stax2.validation.XMLValidationSchema)was called earlier.XMLValidatorstopValidatingAgainst(XMLValidator validator)Method that can be called by application to stop validating output using specified validator.protected voidthrowNotTextualOrElem(int type)protected voidthrowUnexpectedEOF()Method called when we get an EOF within content treeXMLValidatorvalidateAgainst(XMLValidationSchema schema)Method that will construct aXMLValidatorinstance from the given schema (unless a validator for that schema has already been added), initialize it if necessary, and make validatable object (reader, writer) call appropriate validation methods from this point on until the end of the document (that is, it's not scoped with sub-trees), or until validator is removed by an explicit call toValidatable.stopValidatingAgainst(org.codehaus.stax2.validation.XMLValidationSchema).ObjectwithStartElement(ElemCallback cb, Location loc)Method called byDefaultEventAllocatorto 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, 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 Detail
-
MASK_GET_TEXT
protected static final int MASK_GET_TEXT
This mask covers all types for which basicgetText()method can be called.- See Also:
- Constant Field Values
-
MASK_GET_TEXT_XXX
protected static final int MASK_GET_TEXT_XXX
This mask covers all types for which extendsgetTextXxxmethods can be called; which is less than those for whichgetText()can be called. Specifically,DTDandENTITY_REFERENCEtypes do not support these extended- See Also:
- Constant Field Values
-
MASK_GET_TEXT_WITH_WRITER
protected static final int MASK_GET_TEXT_WITH_WRITER
This mask is used with Stax2 getText() method (one that takes Writer as an argument): accepts even wider range of event types.- See Also:
- Constant Field Values
-
MASK_GET_ELEMENT_TEXT
protected static final int MASK_GET_ELEMENT_TEXT
- See Also:
- Constant Field Values
-
sPrefixXml
protected static final String sPrefixXml
-
sPrefixXmlns
protected static final String sPrefixXmlns
-
mConfigFlags
protected final int mConfigFlags
Set of locally stored configuration flags
-
mCfgCoalesceText
protected final boolean mCfgCoalesceText
-
mCfgReportTextAsChars
protected final boolean mCfgReportTextAsChars
-
mCfgLazyParsing
protected final boolean mCfgLazyParsing
-
mShortestTextSegment
protected final int mShortestTextSegment
Minimum number of characters parser can return as partial text segment, IF it's not required to coalesce adjacent text segments.
-
mOwner
protected final ReaderCreator 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 mDocStandalone
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.
-
mRootPrefix
protected String mRootPrefix
Prefix of root element, as dictated by DOCTYPE declaration; null if no DOCTYPE declaration, or no root prefix
-
mRootLName
protected String mRootLName
Local name of root element, as dictated by DOCTYPE declaration; null if no DOCTYPE declaration.
-
mDtdPublicId
protected String mDtdPublicId
Public id of the DTD, if one exists and has been parsed.
-
mDtdSystemId
protected String mDtdSystemId
System id of the DTD, if one exists and has been parsed.
-
mTextBuffer
protected final TextBuffer mTextBuffer
TextBuffer mostly used to collect non-element textual content (text, CDATA, comment content, pi data)
-
mElementStack
protected final InputElementStack mElementStack
Currently open element tree
-
mAttrCollector
protected final AttributeCollector mAttrCollector
Object that stores information about currently accessible attributes.
-
mStDoctypeFound
protected boolean mStDoctypeFound
-
mTokenState
protected int mTokenState
State 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 mStTextThreshold
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)
-
mCurrTextLength
protected int mCurrTextLength
Sized 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 mParseState
Main parsing/tokenization state (STATE_xxx)
-
mCurrToken
protected int mCurrToken
Current 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 mSecondaryToken
Additional information sometimes stored (when generating dummy events in multi-doc mode, for example) temporarily whenmCurrTokenis already populated.
-
mWsStatus
protected int mWsStatus
Status of current (text) token's "whitespaceness", that is, whether it is or is not all white space.
-
mValidateText
protected boolean mValidateText
Flag 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 mCheckIndentation
Counter used for determining whether we are to try to heuristically "intern" white space that seems to be used for indentation purposes
-
mPendingException
protected XMLStreamException mPendingException
Due to the way Stax API does not allow throwing stream exceptions from many methods for which Woodstox would need to throw one (especiallygetTextand 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
protected Map<String,EntityDecl> 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 mVldContent
Mode 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 mReturnNullForDefaultNamespace
Configuration fromXMLStreamProperties.RETURN_NULL_FOR_DEFAULT_NAMESPACE- Since:
- 4.1.2
-
-
Constructor Detail
-
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 Detail
-
createElementStack
protected static InputElementStack createElementStack(ReaderConfig cfg)
-
getCharacterEncodingScheme
public String 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:
getCharacterEncodingSchemein interfaceXMLStreamReader
-
getEncoding
public String 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:
getEncodingin interfaceXMLStreamReader
-
getVersion
public String getVersion()
- Specified by:
getVersionin interfaceXMLStreamReader
-
isStandalone
public boolean isStandalone()
- Specified by:
isStandalonein interfaceXMLStreamReader
-
standaloneSet
public boolean standaloneSet()
- Specified by:
standaloneSetin interfaceXMLStreamReader
-
getProperty
public Object getProperty(String name)
- Specified by:
getPropertyin interfaceXMLStreamReader
-
getAttributeCount
public int getAttributeCount()
- Specified by:
getAttributeCountin interfaceXMLStreamReader
-
getAttributeLocalName
public String getAttributeLocalName(int index)
- Specified by:
getAttributeLocalNamein interfaceXMLStreamReader
-
getAttributeName
public QName getAttributeName(int index)
- Specified by:
getAttributeNamein interfaceXMLStreamReader
-
getAttributeNamespace
public String getAttributeNamespace(int index)
- Specified by:
getAttributeNamespacein interfaceXMLStreamReader
-
getAttributePrefix
public String getAttributePrefix(int index)
- Specified by:
getAttributePrefixin interfaceXMLStreamReader
-
getAttributeType
public String getAttributeType(int index)
- Specified by:
getAttributeTypein interfaceXMLStreamReader
-
getAttributeValue
public String getAttributeValue(int index)
- Specified by:
getAttributeValuein interfaceXMLStreamReader
-
getAttributeValue
public String getAttributeValue(String nsURI, String localName)
- Specified by:
getAttributeValuein interfaceXMLStreamReader
-
getElementText
public String getElementText() throws XMLStreamException
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:
getElementTextin 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:
getEventTypein interfaceXMLStreamReader
-
getLocalName
public String getLocalName()
- Specified by:
getLocalNamein interfaceXMLStreamReader
-
getName
public QName getName()
- Specified by:
getNamein interfaceXMLStreamReader
-
getNamespaceContext
public NamespaceContext getNamespaceContext()
- Specified by:
getNamespaceContextin interfaceXMLStreamReader
-
getNamespaceCount
public int getNamespaceCount()
- Specified by:
getNamespaceCountin interfaceXMLStreamReader
-
getNamespacePrefix
public String getNamespacePrefix(int index)
- Specified by:
getNamespacePrefixin interfaceXMLStreamReader
-
getNamespaceURI
public String getNamespaceURI()
- Specified by:
getNamespaceURIin interfaceXMLStreamReader
-
getNamespaceURI
public String getNamespaceURI(int index)
- Specified by:
getNamespaceURIin interfaceXMLStreamReader
-
getNamespaceURI
public String getNamespaceURI(String prefix)
- Specified by:
getNamespaceURIin interfaceXMLStreamReader
-
getPIData
public String getPIData()
- Specified by:
getPIDatain interfaceXMLStreamReader
-
getPITarget
public String getPITarget()
- Specified by:
getPITargetin interfaceXMLStreamReader
-
getPrefix
public String getPrefix()
- Specified by:
getPrefixin interfaceXMLStreamReader
-
getText
public String getText()
- Specified by:
getTextin interfaceXMLStreamReader
-
getTextCharacters
public char[] getTextCharacters()
- Specified by:
getTextCharactersin interfaceXMLStreamReader
-
getTextCharacters
public int getTextCharacters(int sourceStart, char[] target, int targetStart, int len)- Specified by:
getTextCharactersin interfaceXMLStreamReader
-
getTextLength
public int getTextLength()
- Specified by:
getTextLengthin interfaceXMLStreamReader
-
getTextStart
public int getTextStart()
- Specified by:
getTextStartin interfaceXMLStreamReader
-
hasName
public boolean hasName()
- Specified by:
hasNamein interfaceXMLStreamReader
-
hasNext
public boolean hasNext()
- Specified by:
hasNextin interfaceXMLStreamReader
-
hasText
public boolean hasText()
- Specified by:
hasTextin interfaceXMLStreamReader
-
isAttributeSpecified
public boolean isAttributeSpecified(int index)
- Specified by:
isAttributeSpecifiedin interfaceXMLStreamReader
-
isCharacters
public boolean isCharacters()
- Specified by:
isCharactersin interfaceXMLStreamReader
-
isEndElement
public boolean isEndElement()
- Specified by:
isEndElementin interfaceXMLStreamReader
-
isStartElement
public boolean isStartElement()
- Specified by:
isStartElementin 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:
isWhiteSpacein interfaceXMLStreamReader
-
require
public void require(int type, String nsUri, String localName) throws XMLStreamException- Specified by:
requirein interfaceXMLStreamReader- Throws:
XMLStreamException
-
next
public final int next() throws XMLStreamException- Specified by:
nextin interfaceXMLStreamReader- Throws:
XMLStreamException
-
nextTag
public int nextTag() throws XMLStreamException- Specified by:
nextTagin interfaceXMLStreamReader- Throws:
XMLStreamException
-
close
public void close() throws XMLStreamExceptionNote: 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_INPUTis set to true.- Specified by:
closein interfaceXMLStreamReader- Throws:
XMLStreamException
-
getFeature
@Deprecated public Object getFeature(String name)
Deprecated.Description copied from interface:XMLStreamReader2Method that can be used to get per-reader values; both generic ones (names for which are defined as constants in this class), and implementation dependant ones.Note: although some feature names are shared with
XMLStreamReader2.setFeature(java.lang.String, java.lang.Object), not all are: some features are read-only, some write-only- Specified by:
getFeaturein interfaceXMLStreamReader2- Parameters:
name- Name of the feature of which value to get- Returns:
- Value of the feature (possibly null), if supported; null otherwise
-
setFeature
@Deprecated public void setFeature(String name, Object value)
Deprecated.Description copied from interface:XMLStreamReader2Method that can be used to set per-reader features such as configuration settings; both generic ones (names for which are defined as constants in this class), and implementation dependant ones.Note: although some feature names are shared with
XMLStreamReader2.getFeature(java.lang.String), not all are: some features are read-only, some write-only- Specified by:
setFeaturein interfaceXMLStreamReader2- Parameters:
name- Name of the feature to setvalue- Value to set feature to.
-
isPropertySupported
public boolean isPropertySupported(String name)
Description copied from interface:XMLStreamReader2Method similar toXMLInputFactory.isPropertySupported(java.lang.String), used to determine whether a property is supported by the Reader instance. This means that this method may return false for some properties that the input factory does support: specifically, it should only return true if the value is mutable on per-instance basis. False means that either the property is not recognized, or is not mutable via reader instance.- Specified by:
isPropertySupportedin interfaceXMLStreamReader2
-
setProperty
public boolean setProperty(String name, Object value)
Description copied from interface:XMLStreamReader2Method that can be used to set per-reader properties; a subset of properties one can set via matchingXMLInputFactory2instance. Exactly which methods are mutable is implementation specific.- Specified by:
setPropertyin interfaceXMLStreamReader2- 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
public void skipElement() throws XMLStreamExceptionDescription copied from interface:XMLStreamReader2Method that will skip all the contents of the element that the stream currently points to. Current event when calling the method has to be START_ELEMENT (or otherwiseIllegalStateExceptionis thrown); after the call the stream will point to the matching END_ELEMENT event, having skipped zero or more intervening events for the contents.- Specified by:
skipElementin interfaceXMLStreamReader2- Throws:
XMLStreamException
-
getAttributeInfo
public AttributeInfo getAttributeInfo() throws XMLStreamException
Description copied from interface:XMLStreamReader2Method that can be called to get additional information about attributes related to the current start element, as well as related DTD-based information if available. Note that the reader has to currently point to START_ELEMENT; if not, aIllegalStateExceptionwill be thrown.- Specified by:
getAttributeInfoin interfaceXMLStreamReader2- Throws:
XMLStreamException
-
getDTDInfo
public DTDInfo getDTDInfo() throws XMLStreamException
Since this class implementsDTDInfo, method can just returnthis.- Specified by:
getDTDInfoin interfaceXMLStreamReader2- Returns:
- Information object for accessing further DOCTYPE information, iff the reader currently points to DTD event, AND is operating in mode that parses such information (DTD-aware at least, and usually also validating)
- Throws:
XMLStreamException
-
getLocationInfo
public final LocationInfo getLocationInfo()
Location information is always accessible, for this reader.- Specified by:
getLocationInfoin interfaceXMLStreamReader2
-
getText
public int getText(Writer w, boolean preserveContents) throws IOException, XMLStreamException
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:
getTextin interfaceXMLStreamReader2- Parameters:
w- Writer to use for writing textual contentspreserveContents- If true, reader has to preserve contents so that further calls togetTextwill 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 togetTextis not guaranteed to return meaningful data.- Returns:
- Number of characters written to the reader
- Throws:
IOExceptionXMLStreamException
-
getDepth
public int getDepth()
Description copied from interface:XMLStreamReader2Method that returns the number of open elements in the stack; 0 when the reader is in prolog/epilog, 1 inside root element (including when pointing at the root element itself) and so on. Depth is same for matching start/end elements, as well as for the all children of an element.- Specified by:
getDepthin interfaceXMLStreamReader2- Returns:
- Number of open elements in the stack; 0 when parser is in prolog/epilog, 1 inside root element and so on.
-
isEmptyElement
public boolean isEmptyElement() throws XMLStreamExceptionDescription copied from interface:XMLStreamReader2Method that can be used to check whether current START_ELEMENT event was created for an empty element (xml short-hand notation where one tag implies start and end, ending with "/>"), or not.Note: method may need to read more data to know if the element is an empty one, and as such may throw an i/o or parsing exception (as
XMLStreamException); however, it won't throw exceptions for non-START_ELEMENT event types.- Specified by:
isEmptyElementin interfaceXMLStreamReader2- Returns:
- True, if cursor points to a start or end element that is constructed from 'empty' element (ends with '/>'); false otherwise.
- Throws:
XMLStreamException
-
getNonTransientNamespaceContext
public NamespaceContext getNonTransientNamespaceContext()
Description copied from interface:XMLStreamReader2This method returns a namespace context object that contains information identical to that returned byXMLStreamReader.getNamespaceContext(), but one that is not transient. That is, one that will remain valid and unchanged after its creation. This allows the namespace context to be used independent of its source documents life cycle. One possible use case is to use this namespace context for 'initializing' writers (especially ones that use repairing mode) with optimal/preferred name space bindings.- Specified by:
getNonTransientNamespaceContextin interfaceXMLStreamReader2- Returns:
- Non-transient namespace context as explained above.
-
getPrefixedName
public String getPrefixedName()
Description copied from interface:XMLStreamReader2This method returns "prefix-qualified" name of the current element. In general, this means character-by-character exact name of the element in XML content, and may be useful in informational purposes, as well as when interacting with packages and APIs that use such names (such as what SAX may use as qnames).Note: implementations are encouraged to provide an implementation that would be more efficient than calling
getLocalNameandgetPrefixseparately, but are not required to do so. Nonetheless it is usually at least as efficient (if not more) to call this method as to do it fully in calling code.- Specified by:
getPrefixedNamein interfaceXMLStreamReader2- Returns:
- Prefix-qualified name of the current element; essentially 'prefix:localName' if the element has a prefix, or 'localName' if it does not have one (belongs to the default namespace)
-
closeCompletely
public void closeCompletely() throws XMLStreamExceptionDescription copied from interface:XMLStreamReader2Method similar toXMLStreamReader.close(), except that this method also does close the underlying input source if it has not yet been closed. It is generally preferable to call this method if the parsing ends in an exception; and for some input sources (when passing aFileorURLfor factory method) it has to be called as the application does not have access to the actually input source (InputStreamopened from aURLand so on).- Specified by:
closeCompletelyin interfaceXMLStreamReader2- Throws:
XMLStreamException
-
getProcessedDTD
public Object getProcessedDTD()
Note: DTD-handling sub-classes need to override this method.
- Specified by:
getProcessedDTDin interfaceDTDInfo- Returns:
- If current event is DTD, DTD support is enabled, and reader supports DTD processing, returns an internal Object implementation uses for storing/processing DTD; otherwise returns null.
-
getDTDRootName
public String getDTDRootName()
- Specified by:
getDTDRootNamein interfaceDTDInfo- Returns:
- If current event is DTD, returns the full root name (including prefix, if any); otherwise returns null
-
getDTDPublicId
public String getDTDPublicId()
- Specified by:
getDTDPublicIdin interfaceDTDInfo- Returns:
- If current event is DTD, and has a public id, returns the public id; otherwise returns null.
-
getDTDSystemId
public String getDTDSystemId()
- Specified by:
getDTDSystemIdin interfaceDTDInfo- Returns:
- If current event is DTD, and has a system id, returns the system id; otherwise returns null.
-
getDTDInternalSubset
public String getDTDInternalSubset()
- Specified by:
getDTDInternalSubsetin interfaceDTDInfo- Returns:
- Internal subset portion of the DOCTYPE declaration, if any; empty String if none
-
getProcessedDTDSchema
public DTDValidationSchema getProcessedDTDSchema()
Sub-class will override this method- Specified by:
getProcessedDTDSchemain interfaceDTDInfo
-
getStartingByteOffset
public long getStartingByteOffset()
Description copied from interface:LocationInfoMethod that can be used to get exact byte offset (number of bytes read from the stream right before getting to this location) in the stream that is pointed to by this reader, right before the start of the current event.Note: this value MAY be the same as the one returned by
LocationInfo.getStartingCharOffset(), but usually only for single-byte character streams (Ascii, ISO-Latin).- Specified by:
getStartingByteOffsetin interfaceLocationInfo- Returns:
- Byte offset (== number of bytes reader so far) within the underlying stream, if the stream and stream reader are able to provide this (separate from the character offset, for variable-byte encodings); -1 if not.
-
getStartingCharOffset
public long getStartingCharOffset()
Description copied from interface:LocationInfoMethod that can be used to get exact character offset (number of chars read from the stream right before getting to this location) in the stream that is pointed to by this reader, right before the start of the current event.Note: this value MAY be the same as the one returned by
LocationInfo.getStartingByteOffset(); this is the case for single-byte character streams (Ascii, ISO-Latin), as well as for streams for which byte offset information is not available (Readers, Strings).- Specified by:
getStartingCharOffsetin interfaceLocationInfo- Returns:
- Character offset (== number of bytes reader so far) within the underlying stream, if the stream and stream reader are able to provide this (separate from byte offset, for variable-byte encodings); -1 if not.
-
getEndingByteOffset
public long getEndingByteOffset() throws XMLStreamExceptionDescription copied from interface:LocationInfoMethod that can be used to get exact byte offset (number of bytes read from the stream right before getting to this location) in the stream that is pointed to by this reader, right after the end of the current event.Note: this value MAY be the same as the one returned by
LocationInfo.getEndingCharOffset(), but usually only for single-byte character streams (Ascii, ISO-Latin).Note: for lazy-loading implementations, calling this method may require the underlying stream to be advanced and contents parsed; this is why it is possible that an exception be thrown.
- Specified by:
getEndingByteOffsetin interfaceLocationInfo- Returns:
- Byte offset (== number of bytes reader so far) within the underlying stream, if the stream and stream reader are able to provide this (separate from the character offset, for variable-byte encodings); -1 if not.
- Throws:
XMLStreamException
-
getEndingCharOffset
public long getEndingCharOffset() throws XMLStreamExceptionDescription copied from interface:LocationInfoMethod that can be used to get exact character offset (number of chars read from the stream right before getting to this location) in the stream that is pointed to by this reader, right after the end of the current event.Note: this value MAY be the same as the one returned by
LocationInfo.getEndingByteOffset(); this is the case for single-byte character streams (Ascii, ISO-Latin), as well as for streams for which byte offset information is not available (Readers, Strings).Note: for lazy-loading implementations, calling this method may require the underlying stream to be advanced and contents parsed; this is why it is possible that an exception be thrown.
- Specified by:
getEndingCharOffsetin interfaceLocationInfo- Returns:
- Character offset (== number of bytes reader so far) within the underlying stream, if the stream and stream reader are able to provide this (separate from byte offset, for variable-byte encodings); -1 if not.
- Throws:
XMLStreamException
-
getLocation
public final Location getLocation()
Description copied from class:StreamScannerReturns 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:
getLocationin interfaceInputProblemReporter- Specified by:
getLocationin interfaceLocationInfo- Specified by:
getLocationin interfaceXMLStreamReader- Specified by:
getLocationin classStreamScanner
-
getEndLocation
public final XMLStreamLocation2 getEndLocation() throws XMLStreamException
Description copied from interface:LocationInfoAn optional method that either returns the location object that points the ending position of the current event, or null if implementation does not keep track of it (some may return only start location; and some no location at all).Note: since some implementations may not yet know the end location (esp. ones that do lazy loading), this call may require further parsing. As a result, this method may throw a parsing or I/O errors.
- Specified by:
getEndLocationin interfaceLocationInfo- Returns:
- Location right after the end of the current event (which will also be the start location of the next event, if any, or of EOF otherwise).
- Throws:
XMLStreamException- If the stream reader had to advance to the end of the event (to find the location), it may encounter a parsing (or I/O) error; if so, that gets thrown
-
validateAgainst
public XMLValidator validateAgainst(XMLValidationSchema schema) throws XMLStreamException
Description copied from interface:ValidatableMethod that will construct aXMLValidatorinstance from the given schema (unless a validator for that schema has already been added), initialize it if necessary, and make validatable object (reader, writer) call appropriate validation methods from this point on until the end of the document (that is, it's not scoped with sub-trees), or until validator is removed by an explicit call toValidatable.stopValidatingAgainst(org.codehaus.stax2.validation.XMLValidationSchema).Note that while this method can be called at any point in output processing, validator instances are not required to be able to handle addition at other points than right before outputting the root element.
- Specified by:
validateAgainstin interfaceValidatable- Returns:
- Validator instance constructed, if validator was added, or null if a validator for the schema has already been constructed.
- Throws:
XMLStreamException
-
stopValidatingAgainst
public XMLValidator stopValidatingAgainst(XMLValidationSchema schema) throws XMLStreamException
Description copied from interface:ValidatableMethod that can be called by application to stop validating output against a schema, for whichValidatable.validateAgainst(org.codehaus.stax2.validation.XMLValidationSchema)was called earlier.- Specified by:
stopValidatingAgainstin interfaceValidatable- Returns:
- Validator instance created from the schema that was removed, if one was in use; null if no such schema in use.
- Throws:
XMLStreamException
-
stopValidatingAgainst
public XMLValidator stopValidatingAgainst(XMLValidator validator) throws XMLStreamException
Description copied from interface:ValidatableMethod that can be called by application to stop validating output using specified validator. The validator passed should be an earlier return value for a call toValidatable.validateAgainst(org.codehaus.stax2.validation.XMLValidationSchema).Note: the specified validator is compared for identity with validators in use, not for equality.
- Specified by:
stopValidatingAgainstin interfaceValidatable- Returns:
- Validator instance found (ie. argument
validator) if it was being used for validating current document; null if not. - Throws:
XMLStreamException
-
setValidationProblemHandler
public ValidationProblemHandler setValidationProblemHandler(ValidationProblemHandler h)
Description copied from interface:ValidatableMethod that application can call to define a custom handler for validation problems encountered during validation process.- Specified by:
setValidationProblemHandlerin interfaceValidatable- Parameters:
h- Handler to install, if non null; if null, indicates that the default (implementation-specific) handling should be used- Returns:
- Previously set validation problem handler, if any; null if none was set
-
getCurrentEntityDecl
public EntityDecl getCurrentEntityDecl()
- Specified by:
getCurrentEntityDeclin interfaceStreamReaderImpl
-
withStartElement
public Object withStartElement(ElemCallback cb, Location loc)
Method called byDefaultEventAllocatorto get double-indirection necessary for constructing start element events.- Specified by:
withStartElementin interfaceStreamReaderImpl- Returns:
- Null, if stream does not point to start element; whatever callback returns otherwise.
-
isNamespaceAware
public boolean isNamespaceAware()
- Specified by:
isNamespaceAwarein interfaceStreamReaderImpl
-
getInputElementStack
public InputElementStack getInputElementStack()
Method needed by classes (like stream writer implementations) that want to have efficient direct access to element stack implementation- Specified by:
getInputElementStackin interfaceStreamReaderImpl
-
getAttributeCollector
public AttributeCollector 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:
getAttributeCollectorin interfaceStreamReaderImpl
-
fireSaxStartElement
public void fireSaxStartElement(ContentHandler h, Attributes attrs) throws SAXException
- Throws:
SAXException
-
fireSaxEndElement
public void fireSaxEndElement(ContentHandler h) throws SAXException
- Throws:
SAXException
-
fireSaxCharacterEvents
public void fireSaxCharacterEvents(ContentHandler h) throws XMLStreamException, SAXException
- Throws:
XMLStreamExceptionSAXException
-
fireSaxSpaceEvents
public void fireSaxSpaceEvents(ContentHandler h) throws XMLStreamException, SAXException
- Throws:
XMLStreamExceptionSAXException
-
fireSaxCommentEvent
public void fireSaxCommentEvent(LexicalHandler h) throws XMLStreamException, SAXException
- Throws:
XMLStreamExceptionSAXException
-
fireSaxPIEvent
public void fireSaxPIEvent(ContentHandler h) throws XMLStreamException, SAXException
- Throws:
XMLStreamExceptionSAXException
-
hasConfigFlags
protected final boolean hasConfigFlags(int flags)
-
checkKeyword
protected String checkKeyword(char c, String expected) throws XMLStreamException
- Returns:
- Null, if keyword matches ok; String that contains erroneous keyword if not.
- Throws:
XMLStreamException
-
checkCData
protected void checkCData() throws XMLStreamException- Throws:
XMLStreamException
-
handleRootElem
protected void handleRootElem(char c) throws XMLStreamException- Throws:
XMLStreamException
-
initValidation
protected void initValidation() throws XMLStreamExceptionMethod 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
protected int handleEOF(boolean isProlog) throws XMLStreamException- 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
-
handleMultiDocXmlDecl
protected void handleMultiDocXmlDecl() throws XMLStreamException- Throws:
XMLStreamException
-
skipEquals
protected final char skipEquals(String name, String eofMsg) throws XMLStreamException
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
-
finishDTD
protected void finishDTD(boolean copyContents) throws XMLStreamExceptionThis 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
-
readEndElem
protected final void readEndElem() throws XMLStreamExceptionMethod called to completely read a close tag, and update element stack appropriately (including checking that tag matches etc).- Throws:
XMLStreamException
-
ensureFinishToken
protected void ensureFinishToken() throws XMLStreamException- Throws:
XMLStreamException
-
safeEnsureFinishToken
protected void safeEnsureFinishToken()
-
safeFinishToken
protected void safeFinishToken()
-
finishToken
protected void finishToken(boolean deferErrors) throws XMLStreamExceptionMethod 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
-
readCoalescedText
protected void readCoalescedText(int currType, boolean deferErrors) throws XMLStreamExceptionMethod 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
-
readCDataSecondary
protected boolean readCDataSecondary(int shortestSegment) throws XMLStreamException- Returns:
- True if the whole CData section was completely read (we hit the end marker); false if a shorter segment was returned.
- 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
-
skipWS
protected final boolean skipWS(char c) throws XMLStreamExceptionMethod 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
protected EntityDecl findEntity(String id, Object arg) throws XMLStreamException
Description copied from class:StreamScannerAbstract method for sub-classes to implement, for finding a declared general or parsed entity.- Specified by:
findEntityin classStreamScanner- Parameters:
id- Identifier of the entity to findarg- Optional argument passed from caller; needed by DTD reader.- Throws:
XMLStreamException
-
handleUndeclaredEntity
protected void handleUndeclaredEntity(String id) throws XMLStreamException
Description copied from class:StreamScannerThis 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:
handleUndeclaredEntityin classStreamScanner- Throws:
XMLStreamException
-
handleIncompleteEntityProblem
protected void handleIncompleteEntityProblem(WstxInputSource closing) throws XMLStreamException
- Specified by:
handleIncompleteEntityProblemin classStreamScanner- Throws:
XMLStreamException
-
handleGreedyEntityProblem
protected void handleGreedyEntityProblem(WstxInputSource input) throws XMLStreamException
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
-
throwNotTextualOrElem
protected void throwNotTextualOrElem(int type)
-
throwUnexpectedEOF
protected void throwUnexpectedEOF() throws WstxExceptionMethod called when we get an EOF within content tree- Throws:
WstxException
-
_constructUnexpectedInTyped
protected XMLStreamException _constructUnexpectedInTyped(int nextToken)
Method called to report a problem with
-
_constructTypeException
protected TypedXMLStreamException _constructTypeException(String msg, String lexicalValue)
-
reportInvalidContent
protected void reportInvalidContent(int evtType) throws XMLStreamExceptionStub 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
-
-