|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.ctc.wstx.io.WstxInputData
com.ctc.wstx.sr.StreamScanner
com.ctc.wstx.sr.BasicStreamReader
public abstract class BasicStreamReader
Partial implementation of 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 | |
---|---|
protected static int |
MASK_GET_ELEMENT_TEXT
|
protected static int |
MASK_GET_TEXT
This mask covers all types for which basic getText() method
can be called. |
protected static 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. |
protected static int |
MASK_GET_TEXT_XXX
This mask covers all types for which extends getTextXxx
methods can be called; which is less than those for which
getText() can be called. |
protected AttributeCollector |
mAttrCollector
Object that stores information about currently accessible attributes. |
protected boolean |
mCfgCoalesceText
|
protected boolean |
mCfgLazyParsing
|
protected boolean |
mCfgReportTextAsChars
|
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 |
protected int |
mConfigFlags
Set of locally stored configuration flags |
protected int |
mCurrToken
Current state of the stream, ie token value returned by getEventType() . |
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. |
protected String |
mDtdPublicId
Public id of the DTD, if one exists and has been parsed. |
protected String |
mDtdSystemId
System id of the DTD, if one exists and has been parsed. |
protected InputElementStack |
mElementStack
Currently open element tree |
protected Map |
mGeneralEntities
Entities parsed from internal/external DTD subsets. |
protected ReaderCreator |
mOwner
Object to notify about shared stuff, such as symbol tables, as well as to query for additional config settings if necessary. |
protected int |
mParseState
Main parsing/tokenization state (STATE_xxx) |
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 (especially getText and its variations), we may need
to delay throwing an exception until next() is called next
time. |
protected boolean |
mReturnNullForDefaultNamespace
Configuration from XMLStreamProperties.RETURN_NULL_FOR_DEFAULT_NAMESPACE |
protected int |
mSecondaryToken
Additional information sometimes stored (when generating dummy events in multi-doc mode, for example) temporarily when mCurrToken is already populated. |
protected int |
mShortestTextSegment
Minimum number of characters parser can return as partial text segment, IF it's not required to coalesce adjacent text segments. |
protected boolean |
mStDoctypeFound
|
protected boolean |
mStEmptyElem
|
protected 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) |
protected TextBuffer |
mTextBuffer
TextBuffer mostly used to collect non-element textual content (text, CDATA, comment content, pi data) |
protected int |
mTokenState
State of the current token; one of M_ - constants from above. |
protected boolean |
mValidateText
Flag that indicates that textual content (CDATA, CHARACTERS) is to be validated within current element's scope. |
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. |
protected int |
mWsStatus
Status of current (text) token's "whitespaceness", that is, whether it is or is not all white space. |
protected static String |
sPrefixXml
|
protected static String |
sPrefixXmlns
|
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, mDocXmlVersion, 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 org.codehaus.stax2.XMLStreamReader2 |
---|
FEATURE_DTD_OVERRIDE |
Fields inherited from interface javax.xml.stream.XMLStreamConstants |
---|
ATTRIBUTE, CDATA, CHARACTERS, COMMENT, DTD, END_DOCUMENT, END_ELEMENT, ENTITY_DECLARATION, ENTITY_REFERENCE, NAMESPACE, NOTATION_DECLARATION, PROCESSING_INSTRUCTION, SPACE, START_DOCUMENT, START_ELEMENT |
Constructor Summary | |
---|---|
protected |
BasicStreamReader(InputBootstrapper bs,
BranchingReaderSource input,
ReaderCreator owner,
ReaderConfig cfg,
InputElementStack elemStack,
boolean forER)
|
Method Summary | |
---|---|
protected TypedXMLStreamException |
_constructTypeException(String msg,
String lexicalValue)
|
protected XMLStreamException |
_constructUnexpectedInTyped(int nextToken)
Method called to report a problem with |
protected void |
checkCData()
|
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 |
closeCompletely()
Method similar to XMLStreamReader.getNamespaceContext() ,
except that this method also does close the underlying input
source if it has not yet been closed. |
protected static InputElementStack |
createElementStack(ReaderConfig cfg)
|
protected void |
ensureFinishToken()
|
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 |
fireSaxCharacterEvents(ContentHandler h)
|
void |
fireSaxCommentEvent(LexicalHandler h)
|
void |
fireSaxEndElement(ContentHandler h)
|
void |
fireSaxPIEvent(ContentHandler h)
|
void |
fireSaxSpaceEvents(ContentHandler h)
|
void |
fireSaxStartElement(ContentHandler h,
Attributes attrs)
|
AttributeCollector |
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. |
int |
getAttributeCount()
|
AttributeInfo |
getAttributeInfo()
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. |
String |
getAttributeLocalName(int index)
|
QName |
getAttributeName(int index)
|
String |
getAttributeNamespace(int index)
|
String |
getAttributePrefix(int index)
|
String |
getAttributeType(int index)
|
String |
getAttributeValue(int index)
|
String |
getAttributeValue(String nsURI,
String localName)
|
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. |
EntityDecl |
getCurrentEntityDecl()
|
int |
getDepth()
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. |
DTDInfo |
getDTDInfo()
Since this class implements DTDInfo , method can just
return this . |
String |
getDTDInternalSubset()
|
String |
getDTDPublicId()
|
String |
getDTDRootName()
|
String |
getDTDSystemId()
|
String |
getElementText()
From StAX specs: Reads the content of a text-only element, an exception is thrown if this is not a text-only element. |
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. |
long |
getEndingByteOffset()
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. |
long |
getEndingCharOffset()
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. |
XMLStreamLocation2 |
getEndLocation()
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). |
int |
getEventType()
Returns type of the last event returned; or START_DOCUMENT before any events has been explicitly returned. |
Object |
getFeature(String name)
Method 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. |
InputElementStack |
getInputElementStack()
Method needed by classes (like stream writer implementations) that want to have efficient direct access to element stack implementation |
String |
getLocalName()
|
Location |
getLocation()
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). |
LocationInfo |
getLocationInfo()
Location information is always accessible, for this reader. |
QName |
getName()
|
NamespaceContext |
getNamespaceContext()
|
int |
getNamespaceCount()
|
String |
getNamespacePrefix(int index)
|
String |
getNamespaceURI()
|
String |
getNamespaceURI(int index)
|
String |
getNamespaceURI(String prefix)
|
NamespaceContext |
getNonTransientNamespaceContext()
This method returns a namespace context object that contains information identical to that returned by XMLStreamReader.getNamespaceContext() ,
but one that is
not transient. |
String |
getPIData()
|
String |
getPITarget()
|
String |
getPrefix()
|
String |
getPrefixedName()
This method returns "prefix-qualified" name of the current element. |
Object |
getProcessedDTD()
Note: DTD-handling sub-classes need to override this method. |
DTDValidationSchema |
getProcessedDTDSchema()
Sub-class will override this method |
Object |
getProperty(String name)
|
long |
getStartingByteOffset()
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. |
long |
getStartingCharOffset()
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. |
String |
getText()
|
int |
getText(Writer w,
boolean preserveContents)
Method similar to getText() , except
that it just uses provided Writer to write all textual content. |
char[] |
getTextCharacters()
|
int |
getTextCharacters(int sourceStart,
char[] target,
int targetStart,
int len)
|
int |
getTextLength()
|
int |
getTextStart()
|
String |
getVersion()
|
protected int |
handleEOF(boolean isProlog)
|
protected void |
handleGreedyEntityProblem(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 void |
handleIncompleteEntityProblem(WstxInputSource closing)
|
protected int |
handleMultiDocStart(int nextEvent)
Method called when an event was encountered that indicates document boundary in multi-doc mode. |
protected void |
handleMultiDocXmlDecl()
|
protected void |
handleRootElem(char c)
|
protected void |
handleUndeclaredEntity(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 boolean |
hasConfigFlags(int flags)
|
boolean |
hasName()
|
boolean |
hasNext()
|
boolean |
hasText()
|
protected void |
initValidation()
Method called right before the document root element is handled. |
boolean |
isAttributeSpecified(int index)
|
boolean |
isCharacters()
|
boolean |
isEmptyElement()
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. |
boolean |
isEndElement()
|
boolean |
isNamespaceAware()
|
boolean |
isPropertySupported(String name)
Method similar to XMLInputFactory.isPropertySupported(java.lang.String) , used
to determine whether a property is supported by the Reader
instance. |
boolean |
isStandalone()
|
boolean |
isStartElement()
|
boolean |
isWhiteSpace()
05-Apr-2004, TSa: Could try to determine status when text is actually read. |
int |
next()
|
int |
nextTag()
|
protected void |
parseQuoted(String name,
char quoteChar,
TextBuffer tbuf)
Method called to parse quoted xml declaration pseudo-attribute values. |
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. |
protected void |
readEndElem()
Method called to completely read a close tag, and update element stack appropriately (including checking that tag matches etc). |
protected boolean |
readTextSecondary(int shortestSegment,
boolean deferErrors)
|
protected void |
reportInvalidContent(int evtType)
Stub method implemented by validating parsers, to report content that's not valid for current element context. |
void |
require(int type,
String nsUri,
String localName)
|
protected void |
safeEnsureFinishToken()
|
protected void |
safeFinishToken()
|
void |
setFeature(String name,
Object value)
Method 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. |
boolean |
setProperty(String name,
Object value)
Method that can be used to set per-reader properties; a subset of properties one can set via matching XMLInputFactory2
instance. |
ValidationProblemHandler |
setValidationProblemHandler(ValidationProblemHandler h)
Method that application can call to define a custom handler for validation problems encountered during validation process. |
void |
skipElement()
Method that will skip all the contents of the element that the stream currently points to. |
protected char |
skipEquals(String name,
String eofMsg)
Method that checks that input following is of form '[S]* '=' [S]*' (as per XML specs, production #25). |
protected boolean |
skipWS(char c)
Method that will skip any white space from input source(s) |
boolean |
standaloneSet()
|
XMLValidator |
stopValidatingAgainst(XMLValidationSchema schema)
Method that can be called by application to stop validating output against a schema, for which Validatable.validateAgainst(org.codehaus.stax2.validation.XMLValidationSchema)
was called earlier. |
XMLValidator |
stopValidatingAgainst(XMLValidator validator)
Method that can be called by application to stop validating output using specified validator. |
protected void |
throwNotTextualOrElem(int type)
|
protected void |
throwUnexpectedEOF()
Method called when we get an EOF within content tree |
XMLValidator |
validateAgainst(XMLValidationSchema schema)
Method that will construct a XMLValidator instance 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 to
Validatable.stopValidatingAgainst(org.codehaus.stax2.validation.XMLValidationSchema) . |
Object |
withStartElement(ElemCallback cb,
Location loc)
Method called by DefaultEventAllocator
to get double-indirection necessary for constructing start element
events. |
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 |
Field Detail |
---|
protected static final int MASK_GET_TEXT
getText()
method
can be called.
protected static final int MASK_GET_TEXT_XXX
getTextXxx
methods can be called; which is less than those for which
getText()
can be called. Specifically, DTD
and
ENTITY_REFERENCE
types do not support these extended
protected static final int MASK_GET_TEXT_WITH_WRITER
protected static final int MASK_GET_ELEMENT_TEXT
protected static final String sPrefixXml
protected static final String sPrefixXmlns
protected final int mConfigFlags
protected final boolean mCfgCoalesceText
protected final boolean mCfgReportTextAsChars
protected final boolean mCfgLazyParsing
protected final int mShortestTextSegment
protected final ReaderCreator mOwner
protected int mDocStandalone
protected String mDtdPublicId
protected String mDtdSystemId
protected final TextBuffer mTextBuffer
protected final InputElementStack mElementStack
protected final AttributeCollector mAttrCollector
protected boolean mStDoctypeFound
protected int mTokenState
Initially set to fully tokenized, since it's the virtual START_DOCUMENT event that we fully know by now (parsed by bootstrapper)
protected final int mStTextThreshold
protected boolean mStEmptyElem
protected int mParseState
protected int mCurrToken
getEventType()
. Needs to be initialized to START_DOCUMENT,
since that's the state it starts in.
protected int mSecondaryToken
mCurrToken
is already populated.
protected int mWsStatus
protected boolean mValidateText
XMLValidator.CONTENT_ALLOW_VALIDATABLE_TEXT
,
and will prevent lazy parsing of text.
protected int mCheckIndentation
protected XMLStreamException mPendingException
getText
and its variations), we may need
to delay throwing an exception until next()
is called next
time. If so, this variable holds the pending stream exception.
protected Map mGeneralEntities
protected int mVldContent
XMLValidator
,
(like XMLValidator.CONTENT_ALLOW_VALIDATABLE_TEXT
).
Only used inside tree; ignored for prolog/epilog (which
have straight-forward static rules).
protected boolean mReturnNullForDefaultNamespace
XMLStreamProperties.RETURN_NULL_FOR_DEFAULT_NAMESPACE
Constructor Detail |
---|
protected BasicStreamReader(InputBootstrapper bs, BranchingReaderSource input, ReaderCreator owner, ReaderConfig cfg, InputElementStack elemStack, boolean forER) throws XMLStreamException
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.
XMLStreamException
Method Detail |
---|
protected static InputElementStack createElementStack(ReaderConfig cfg)
public String getCharacterEncodingScheme()
Note: method name is rather confusing (compare to getEncoding()
).
getCharacterEncodingScheme
in interface XMLStreamReader
public String getEncoding()
Reader
), it should return null.
getEncoding
in interface XMLStreamReader
public String getVersion()
getVersion
in interface XMLStreamReader
public boolean isStandalone()
isStandalone
in interface XMLStreamReader
public boolean standaloneSet()
standaloneSet
in interface XMLStreamReader
public Object getProperty(String name)
getProperty
in interface XMLStreamReader
public int getAttributeCount()
getAttributeCount
in interface XMLStreamReader
public String getAttributeLocalName(int index)
getAttributeLocalName
in interface XMLStreamReader
public QName getAttributeName(int index)
getAttributeName
in interface XMLStreamReader
public String getAttributeNamespace(int index)
getAttributeNamespace
in interface XMLStreamReader
public String getAttributePrefix(int index)
getAttributePrefix
in interface XMLStreamReader
public String getAttributeType(int index)
getAttributeType
in interface XMLStreamReader
public String getAttributeValue(int index)
getAttributeValue
in interface XMLStreamReader
public String getAttributeValue(String nsURI, String localName)
getAttributeValue
in interface XMLStreamReader
public String getElementText() throws XMLStreamException
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.
getElementText
in interface XMLStreamReader
XMLStreamException
public int getEventType()
getEventType
in interface XMLStreamReader
public String getLocalName()
getLocalName
in interface XMLStreamReader
public QName getName()
getName
in interface XMLStreamReader
public NamespaceContext getNamespaceContext()
getNamespaceContext
in interface XMLStreamReader
public int getNamespaceCount()
getNamespaceCount
in interface XMLStreamReader
public String getNamespacePrefix(int index)
getNamespacePrefix
in interface XMLStreamReader
public String getNamespaceURI()
getNamespaceURI
in interface XMLStreamReader
public String getNamespaceURI(int index)
getNamespaceURI
in interface XMLStreamReader
public String getNamespaceURI(String prefix)
getNamespaceURI
in interface XMLStreamReader
public String getPIData()
getPIData
in interface XMLStreamReader
public String getPITarget()
getPITarget
in interface XMLStreamReader
public String getPrefix()
getPrefix
in interface XMLStreamReader
public String getText()
getText
in interface XMLStreamReader
public char[] getTextCharacters()
getTextCharacters
in interface XMLStreamReader
public int getTextCharacters(int sourceStart, char[] target, int targetStart, int len)
getTextCharacters
in interface XMLStreamReader
public int getTextLength()
getTextLength
in interface XMLStreamReader
public int getTextStart()
getTextStart
in interface XMLStreamReader
public boolean hasName()
hasName
in interface XMLStreamReader
public boolean hasNext()
hasNext
in interface XMLStreamReader
public boolean hasText()
hasText
in interface XMLStreamReader
public boolean isAttributeSpecified(int index)
isAttributeSpecified
in interface XMLStreamReader
public boolean isCharacters()
isCharacters
in interface XMLStreamReader
public boolean isEndElement()
isEndElement
in interface XMLStreamReader
public boolean isStartElement()
isStartElement
in interface XMLStreamReader
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?
isWhiteSpace
in interface XMLStreamReader
public void require(int type, String nsUri, String localName) throws XMLStreamException
require
in interface XMLStreamReader
XMLStreamException
public final int next() throws XMLStreamException
next
in interface XMLStreamReader
XMLStreamException
public int nextTag() throws XMLStreamException
nextTag
in interface XMLStreamReader
XMLStreamException
public void close() throws XMLStreamException
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.
close
in interface XMLStreamReader
XMLStreamException
public Object getFeature(String name)
XMLStreamReader2
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
getFeature
in interface XMLStreamReader2
name
- Name of the feature of which value to get
public void setFeature(String name, Object value)
XMLStreamReader2
Note: although some feature names are shared with
XMLStreamReader2.getFeature(java.lang.String)
, not all are: some features are read-only,
some write-only
setFeature
in interface XMLStreamReader2
name
- Name of the feature to setvalue
- Value to set feature to.public boolean isPropertySupported(String name)
XMLStreamReader2
XMLInputFactory.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.
isPropertySupported
in interface XMLStreamReader2
public boolean setProperty(String name, Object value)
XMLStreamReader2
XMLInputFactory2
instance. Exactly which methods are mutable is implementation
specific.
setProperty
in interface XMLStreamReader2
name
- Name of the property to setvalue
- Value to set property to.
public void skipElement() throws XMLStreamException
XMLStreamReader2
IllegalStateException
is thrown); after the call the stream will point to the matching
END_ELEMENT event, having skipped zero or more intervening events
for the contents.
skipElement
in interface XMLStreamReader2
XMLStreamException
public AttributeInfo getAttributeInfo() throws XMLStreamException
XMLStreamReader2
IllegalStateException
will be thrown.
getAttributeInfo
in interface XMLStreamReader2
XMLStreamException
public DTDInfo getDTDInfo() throws XMLStreamException
DTDInfo
, method can just
return this
.
getDTDInfo
in interface XMLStreamReader2
XMLStreamException
public final LocationInfo getLocationInfo()
getLocationInfo
in interface XMLStreamReader2
public int getText(Writer w, boolean preserveContents) throws IOException, XMLStreamException
getText()
, 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
getText
in interface XMLStreamReader2
w
- Writer to use for writing textual contentspreserveContents
- If true, reader has to preserve contents
so that further calls to getText
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 to getText
is not guaranteed to
return meaningful data.
IOException
XMLStreamException
public int getDepth()
XMLStreamReader2
getDepth
in interface XMLStreamReader2
public boolean isEmptyElement() throws XMLStreamException
XMLStreamReader2
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.
isEmptyElement
in interface XMLStreamReader2
XMLStreamException
public NamespaceContext getNonTransientNamespaceContext()
XMLStreamReader2
XMLStreamReader.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.
getNonTransientNamespaceContext
in interface XMLStreamReader2
public String getPrefixedName()
XMLStreamReader2
Note: implementations are encouraged to provide an implementation
that would be more efficient than calling getLocalName
and getPrefix
separately, 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.
getPrefixedName
in interface XMLStreamReader2
public void closeCompletely() throws XMLStreamException
XMLStreamReader2
XMLStreamReader.getNamespaceContext()
,
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
a File
or URL
for factory
method) it has to be called as the application does not have
access to the actually input source (InputStream
opened from a URL
and so on).
closeCompletely
in interface XMLStreamReader2
XMLStreamException
public Object getProcessedDTD()
Note: DTD-handling sub-classes need to override this method.
getProcessedDTD
in interface DTDInfo
public String getDTDRootName()
getDTDRootName
in interface DTDInfo
public String getDTDPublicId()
getDTDPublicId
in interface DTDInfo
public String getDTDSystemId()
getDTDSystemId
in interface DTDInfo
public String getDTDInternalSubset()
getDTDInternalSubset
in interface DTDInfo
public DTDValidationSchema getProcessedDTDSchema()
getProcessedDTDSchema
in interface DTDInfo
public long getStartingByteOffset()
LocationInfo
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).
getStartingByteOffset
in interface LocationInfo
public long getStartingCharOffset()
LocationInfo
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).
getStartingCharOffset
in interface LocationInfo
public long getEndingByteOffset() throws XMLStreamException
LocationInfo
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.
getEndingByteOffset
in interface LocationInfo
XMLStreamException
public long getEndingCharOffset() throws XMLStreamException
LocationInfo
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.
getEndingCharOffset
in interface LocationInfo
XMLStreamException
public final Location getLocation()
StreamScanner
getLocation
in interface InputProblemReporter
getLocation
in interface XMLStreamReader
getLocation
in interface LocationInfo
getLocation
in class StreamScanner
public final XMLStreamLocation2 getEndLocation() throws XMLStreamException
LocationInfo
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.
getEndLocation
in interface LocationInfo
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 thrownpublic XMLValidator validateAgainst(XMLValidationSchema schema) throws XMLStreamException
Validatable
XMLValidator
instance 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 to
Validatable.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.
validateAgainst
in interface Validatable
XMLStreamException
public XMLValidator stopValidatingAgainst(XMLValidationSchema schema) throws XMLStreamException
Validatable
Validatable.validateAgainst(org.codehaus.stax2.validation.XMLValidationSchema)
was called earlier.
stopValidatingAgainst
in interface Validatable
XMLStreamException
public XMLValidator stopValidatingAgainst(XMLValidator validator) throws XMLStreamException
Validatable
Validatable.validateAgainst(org.codehaus.stax2.validation.XMLValidationSchema)
.
Note: the specified validator is compared for identity with validators in use, not for equality.
stopValidatingAgainst
in interface Validatable
validator
)
if it was being used for validating current document; null if not.
XMLStreamException
public ValidationProblemHandler setValidationProblemHandler(ValidationProblemHandler h)
Validatable
setValidationProblemHandler
in interface Validatable
h
- Handler to install, if non null; if null, indicates that
the default (implementation-specific) handling should be used
public EntityDecl getCurrentEntityDecl()
getCurrentEntityDecl
in interface StreamReaderImpl
public Object withStartElement(ElemCallback cb, Location loc)
DefaultEventAllocator
to get double-indirection necessary for constructing start element
events.
withStartElement
in interface StreamReaderImpl
public boolean isNamespaceAware()
isNamespaceAware
in interface StreamReaderImpl
public InputElementStack getInputElementStack()
getInputElementStack
in interface StreamReaderImpl
public AttributeCollector getAttributeCollector()
getAttributeCollector
in interface StreamReaderImpl
public void fireSaxStartElement(ContentHandler h, Attributes attrs) throws SAXException
SAXException
public void fireSaxEndElement(ContentHandler h) throws SAXException
SAXException
public void fireSaxCharacterEvents(ContentHandler h) throws XMLStreamException, SAXException
XMLStreamException
SAXException
public void fireSaxSpaceEvents(ContentHandler h) throws XMLStreamException, SAXException
XMLStreamException
SAXException
public void fireSaxCommentEvent(LexicalHandler h) throws XMLStreamException, SAXException
XMLStreamException
SAXException
public void fireSaxPIEvent(ContentHandler h) throws XMLStreamException, SAXException
XMLStreamException
SAXException
protected final boolean hasConfigFlags(int flags)
protected String checkKeyword(char c, String expected) throws XMLStreamException
XMLStreamException
protected void checkCData() throws XMLStreamException
XMLStreamException
protected void handleRootElem(char c) throws XMLStreamException
XMLStreamException
protected void initValidation() throws XMLStreamException
XMLStreamException
protected int handleEOF(boolean isProlog) throws XMLStreamException
XMLStreamException
protected int handleMultiDocStart(int nextEvent)
protected void handleMultiDocXmlDecl() throws XMLStreamException
XMLStreamException
protected final char skipEquals(String name, String eofMsg) throws XMLStreamException
XMLStreamException
protected final void parseQuoted(String name, char quoteChar, TextBuffer tbuf) throws XMLStreamException
Note: since it'll be called at most 3 times per document, this method is not optimized too much.
XMLStreamException
protected void finishDTD(boolean copyContents) throws XMLStreamException
NOTE: Since this default implementation will be overridden by some sub-classes, make sure you do NOT change the method signature.
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).
XMLStreamException
protected final void readEndElem() throws XMLStreamException
XMLStreamException
protected void ensureFinishToken() throws XMLStreamException
XMLStreamException
protected void safeEnsureFinishToken()
protected void safeFinishToken()
protected void finishToken(boolean deferErrors) throws XMLStreamException
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.
XMLStreamException
protected void readCoalescedText(int currType, boolean deferErrors) throws XMLStreamException
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.
XMLStreamException
protected boolean readCDataSecondary(int shortestSegment) throws XMLStreamException
XMLStreamException
protected final boolean readTextSecondary(int shortestSegment, boolean deferErrors) throws XMLStreamException
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.
XMLStreamException
protected final boolean skipWS(char c) throws XMLStreamException
XMLStreamException
protected EntityDecl findEntity(String id, Object arg) throws XMLStreamException
StreamScanner
findEntity
in class StreamScanner
id
- Identifier of the entity to findarg
- Optional argument passed from caller; needed by DTD
reader.
XMLStreamException
protected void handleUndeclaredEntity(String id) throws XMLStreamException
StreamScanner
handleUndeclaredEntity
in class StreamScanner
XMLStreamException
protected void handleIncompleteEntityProblem(WstxInputSource closing) throws XMLStreamException
handleIncompleteEntityProblem
in class StreamScanner
XMLStreamException
protected void handleGreedyEntityProblem(WstxInputSource input) throws XMLStreamException
XMLStreamException
protected void throwNotTextualOrElem(int type)
protected void throwUnexpectedEOF() throws WstxException
WstxException
protected XMLStreamException _constructUnexpectedInTyped(int nextToken)
protected TypedXMLStreamException _constructTypeException(String msg, String lexicalValue)
protected void reportInvalidContent(int evtType) throws XMLStreamException
XMLStreamException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |