Class FastInfosetReader
- All Implemented Interfaces:
com.sun.xml.fastinfoset.OctetBufferListener,XMLReader,XMLStreamConstants,XMLStreamReader,org.jvnet.fastinfoset.FastInfosetParser,org.jvnet.fastinfoset.stax.FastInfosetStreamReader
XMLReader provides a high-level streaming parser interface for reading XML documents.
The next() method is used to read events from the XML document.
Each time it is called, next() returns the new state of the reader.
Possible states are: BOF, the initial state, START, denoting the start tag of an element, END, denoting the end tag of an element, CHARS, denoting the character content of an element, PI, denoting a processing instruction, EOF, denoting the end of the document.
Depending on the state the reader is in, one or more of the following
query methods will be meaningful: StAXDocumentParser.getName(), getURI(),
StAXDocumentParser.getLocalName(), getAttributes(), getValue().
Elements visited by a XMLReader are tagged with unique IDs. The ID of the
current element can be found by calling getElementId().
A XMLReader is always namespace-aware, and keeps track of the namespace
declarations which are in scope at any time during streaming. The
StAXDocumentParser.getURI(java.lang.String) method can be used to find the URI
associated to a given prefix in the current scope.
XMLReaders can be created using a XMLReaderFactory.
Some utility methods, nextContent() and nextElementContent()
make it possible to ignore whitespace and processing instructions with
minimum impact on the client code.
Similarly, the skipElement() and skipElement(int elementId)
methods allow to skip to the end tag of an element ignoring all its content.
Finally, the recordElement() method can be invoked when the XMLReader
is positioned on the start tag of an element to record the element's contents
so that they can be played back later.
- Author:
- JAX-RPC Development Team
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.sun.xml.fastinfoset.stax.StAXDocumentParser
com.sun.xml.fastinfoset.stax.StAXDocumentParser.NamespaceContextImplNested classes/interfaces inherited from class com.sun.xml.fastinfoset.Decoder
com.sun.xml.fastinfoset.Decoder.EncodingAlgorithmInputStream -
Field Summary
Fields inherited from class com.sun.xml.fastinfoset.stax.StAXDocumentParser
_algorithmData, _algorithmDataLength, _algorithmDataOffset, _algorithmId, _algorithmURI, _attributes, _characterEncodingScheme, _characters, _charactersOffset, _clearAttributes, _currentNamespaceAIIsEnd, _currentNamespaceAIIsStart, _eventType, _internalState, _isAlgorithmDataCloned, _manager, _namespaceAIIsEndStack, _namespaceAIIsIndex, _namespaceAIIsNamespaceName, _namespaceAIIsPrefix, _namespaceAIIsPrefixIndex, _namespaceAIIsStartStack, _nsContext, _piData, _piTarget, _qNameStack, _qualifiedName, _stackCount, INTERNAL_STATE_DOUBLE_TERMINATE_ELEMENT, INTERNAL_STATE_END_DOCUMENT, INTERNAL_STATE_SINGLE_TERMINATE_ELEMENT_WITH_NAMESPACES, INTERNAL_STATE_START_DOCUMENT, INTERNAL_STATE_START_ELEMENT_TERMINATE, INTERNAL_STATE_VOIDFields inherited from class com.sun.xml.fastinfoset.Decoder
_addToTable, _attributeNameTable, _attributeValueTable, _b, _bufferSize, _characterContentChunkTable, _charBuffer, _charBufferLength, _doubleTerminate, _duplicateAttributeVerifier, _elementNameTable, _identifier, _integer, _namespaceNameIndex, _needForceStreamClose, _notations, _octetBuffer, _octetBufferEnd, _octetBufferLength, _octetBufferOffset, _octetBufferStart, _parseFragments, _prefixIndex, _prefixTable, _registeredEncodingAlgorithms, _terminate, _unparsedEntities, _v, BUFFER_SIZE_SYSTEM_PROPERTY, NISTRING_EMPTY_STRING, NISTRING_ENCODING_ALGORITHM, NISTRING_INDEX, NISTRING_STRING, STRING_INTERNING_SYSTEM_PROPERTYFields inherited from interface org.jvnet.fastinfoset.FastInfosetParser
BUFFER_SIZE_PROPERTY, EXTERNAL_VOCABULARIES_PROPERTY, FORCE_STREAM_CLOSE_PROPERTY, REGISTERED_ENCODING_ALGORITHMS_PROPERTY, STRING_INTERNING_PROPERTYFields 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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close the XMLReader.Return the current attribute list.intReturn the current element ID.intReturn the current line number.intgetState()Return the current state of the XMLReader.getURI()Return the current URI.getValue()Return the current value.intnext()Return the next state of the XMLReader.intintReturn the next state of the XMLReader.Records the current element and leaves the reader positioned on its end tag.voidreset()voidSkip all nodes up to the end tag of the element with the current element ID.voidskipElement(int elementId) Skip all nodes up to the end tag of the element with the given element ID.Methods inherited from class com.sun.xml.fastinfoset.stax.StAXDocumentParser
accessLocalName, accessNamespaceCount, accessNamespaceURI, accessPrefix, accessTextCharacters, accessTextLength, accessTextStart, checkTextState, convertBase64AlorithmDataToCharacters, convertEncodingAlgorithmDataToCharacters, getAttributeCount, getAttributeLocalName, getAttributeName, getAttributeNamespace, getAttributeNameString, getAttributePrefix, getAttributesHolder, getAttributeType, getAttributeValue, getAttributeValue, getCharacterEncodingScheme, getElementText, getElementText, getEncoding, getEventType, getLocalName, getLocation, getName, getNamespaceContext, getNamespaceCount, getNamespaceDecl, getNamespacePrefix, getNamespaceURI, getNamespaceURI, getNamespaceURI, getNameString, getPIData, getPITarget, getPrefix, getPrefixes, getProperty, getText, getTextAlgorithmBytes, getTextAlgorithmBytes, getTextAlgorithmBytesClone, getTextAlgorithmIndex, getTextAlgorithmLength, getTextAlgorithmStart, getTextAlgorithmURI, getTextCharacters, getTextCharacters, getTextLength, getTextStart, getURI, getVersion, hasName, hasNext, hasText, hasTextAlgorithmBytes, isAttributeSpecified, isBase64Follows, isCharacters, isEndElement, isStandalone, isStartElement, isWhiteSpace, nextTag, nextTag, onBeforeOctetBufferOverwrite, peekNext, processAIIEncodingAlgorithm, processAIIs, processCIIEncodingAlgorithm, processCommentII, processDII, processDIIOptionalProperties, processEII, processEIIIndexLarge, processEIIIndexMedium, processEIIWithNamespaces, processLiteralQualifiedName, processProcessingII, processUnexpandedEntityReference, require, resetOnError, resizeNamespaceAIIs, setInputStream, setManager, standaloneSetMethods inherited from class com.sun.xml.fastinfoset.Decoder
_isFastInfosetDocument, closeIfRequired, createQualifiedNameString, createQualifiedNameString, decodeAdditionalData, decodeAlphabetOctetsAsCharBuffer, decodeCharacterEncodingScheme, decodeDII, decodeEIIIndexLarge, decodeEIIIndexMedium, decodeFourBitAlphabetOctetsAsCharBuffer, decodeHeader, decodeIdentifyingNonEmptyStringIndexOnFirstBitAsNamespaceName, decodeIdentifyingNonEmptyStringIndexOnFirstBitAsPrefix, decodeIdentifyingNonEmptyStringOnFirstBit, decodeIdentifyingNonEmptyStringOnFirstBitAsNamespaceName, decodeIdentifyingNonEmptyStringOnFirstBitAsPrefix, decodeInitialVocabulary, decodeIntegerIndexOnSecondBit, decodeLiteralQualifiedName, decodeNonEmptyOctetStringLengthOnSecondBit, decodeNonEmptyOctetStringOnSecondBitAsUtf8CharArray, decodeNonEmptyOctetStringOnSecondBitAsUtf8String, decodeNonIdentifyingStringOnFirstBit, decodeNotations, decodeOctetsOnFifthBitOfNonIdentifyingStringOnFirstBit, decodeOctetsOnSeventhBitOfNonIdentifyingStringOnThirdBit, decodeRAOctetsAsString, decodeRestrictedAlphabetAsCharBuffer, decodeRestrictedAlphabetAsString, decodeUnparsedEntities, decodeUtf16StringAsCharBuffer, decodeUtf16StringAsString, decodeUtf8NCNameIntoCharBuffer, decodeUtf8StringAsCharBuffer, decodeUtf8StringAsCharBuffer, decodeUtf8StringAsString, decodeUtf8StringIntoCharBuffer, decodeUtf8StringIntoCharBuffer, decodeVersion, getBufferSize, getExternalVocabularies, getForceStreamClose, getParseFragments, getRegisteredEncodingAlgorithms, getStringInterning, isFastInfosetDocument, peek, peek, peek2, read, setBufferSize, setExternalVocabularies, setForceStreamClose, setParseFragments, setRegisteredEncodingAlgorithms, setStringInterning, setVocabularyMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.sun.xml.rpc.streaming.XMLReader
getLocalName, getName, getPrefixes, getURI
-
Constructor Details
-
FastInfosetReader
Initialize a FastInfosetReader instance. Note that reset() is called by constructor in base class.
-
-
Method Details
-
reset
public void reset()- Overrides:
resetin classcom.sun.xml.fastinfoset.stax.StAXDocumentParser
-
next
public int next()Return the next state of the XMLReader. The return value is one of: START, END, CHARS, PI, EOF.- Specified by:
nextin interfaceXMLReader- Specified by:
nextin interfaceXMLStreamReader- Overrides:
nextin classcom.sun.xml.fastinfoset.stax.StAXDocumentParser
-
nextElementContent
public int nextElementContent()Description copied from interface:XMLReaderReturn the next state of the XMLReader.Whitespace character content, processing instructions are ignored. Non-whitespace character content triggers an exception.
The return value is one of: START, END, EOF.
- Specified by:
nextElementContentin interfaceXMLReader
-
nextContent
public int nextContent()- Specified by:
nextContentin interfaceXMLReader
-
getState
public int getState()Return the current state of the XMLReader. -
getURI
Return the current URI.Meaningful only when the state is one of: START, END.
-
getAttributes
Return the current attribute list.Meaningful only when the state is one of: START.
The returned
Attributesobject belong to the XMLReader and is only guaranteed to be valid until thenext()method is called, directly or indirectly.- Specified by:
getAttributesin interfaceXMLReader
-
getValue
Return the current value.Meaningful only when the state is one of: CHARS, PI.
-
getElementId
public int getElementId()Return the current element ID.- Specified by:
getElementIdin interfaceXMLReader
-
getLineNumber
public int getLineNumber()Return the current line number.Due to aggressive parsing, this value may be off by a few lines.
- Specified by:
getLineNumberin interfaceXMLReader
-
recordElement
Records the current element and leaves the reader positioned on its end tag.The XMLReader must be positioned on the start tag of the element. The returned reader will play back all events starting with the start tag of the element and ending with its end tag.
- Specified by:
recordElementin interfaceXMLReader
-
skipElement
public void skipElement()Skip all nodes up to the end tag of the element with the current element ID.- Specified by:
skipElementin interfaceXMLReader
-
skipElement
public void skipElement(int elementId) Skip all nodes up to the end tag of the element with the given element ID.- Specified by:
skipElementin interfaceXMLReader
-
close
public void close()Close the XMLReader.All subsequent calls to
next()will return EOF.- Specified by:
closein interfaceXMLReader- Specified by:
closein interfaceXMLStreamReader- Overrides:
closein classcom.sun.xml.fastinfoset.stax.StAXDocumentParser
-