org.codehaus.staxmate.util
Class Stax2ReaderAdapter
java.lang.Object
javax.xml.stream.util.StreamReaderDelegate
org.codehaus.staxmate.util.Stax2ReaderAdapter
- All Implemented Interfaces:
- javax.xml.stream.XMLStreamConstants, javax.xml.stream.XMLStreamReader, org.codehaus.stax2.AttributeInfo, org.codehaus.stax2.DTDInfo, org.codehaus.stax2.LocationInfo, org.codehaus.stax2.validation.Validatable, org.codehaus.stax2.XMLStreamReader2
public class Stax2ReaderAdapter
- extends javax.xml.stream.util.StreamReaderDelegate
- implements org.codehaus.stax2.XMLStreamReader2, org.codehaus.stax2.AttributeInfo, org.codehaus.stax2.DTDInfo, org.codehaus.stax2.LocationInfo
This adapter implements parts of XMLStreamReader2, the
extended stream reader defined by Stax2 extension, by wrapping
a vanilla Stax 1.0 XMLStreamReader implementation.
Note: the implementation is incomplete as-is, since not all
features needed are accessible via basic Stax 1.0 interface.
However, it should be enough to allow StaxMate to handle
underlying Stax implementations in generic way, independent
of whether they are truly Stax2 compatible or not.
|
Field Summary |
protected int |
mDepth
Number of open (start) elements currently. |
| 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 |
| Methods inherited from class javax.xml.stream.util.StreamReaderDelegate |
close, getAttributeCount, getAttributeLocalName, getAttributeName, getAttributeNamespace, getAttributePrefix, getAttributeType, getAttributeValue, getAttributeValue, getCharacterEncodingScheme, getElementText, getEncoding, getEventType, getLocalName, getLocation, getName, getNamespaceContext, getNamespaceCount, getNamespacePrefix, getNamespaceURI, getNamespaceURI, getNamespaceURI, getParent, getPIData, getPITarget, getPrefix, getProperty, getText, getTextCharacters, getTextCharacters, getTextLength, getTextStart, getVersion, hasName, hasNext, hasText, isAttributeSpecified, isCharacters, isEndElement, isStandalone, isStartElement, isWhiteSpace, nextTag, require, setParent, standaloneSet |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface javax.xml.stream.XMLStreamReader |
close, getAttributeCount, getAttributeLocalName, getAttributeName, getAttributeNamespace, getAttributePrefix, getAttributeType, getAttributeValue, getAttributeValue, getCharacterEncodingScheme, getElementText, getEncoding, getEventType, getLocalName, getLocation, getName, getNamespaceContext, getNamespaceCount, getNamespacePrefix, getNamespaceURI, getNamespaceURI, getNamespaceURI, getPIData, getPITarget, getPrefix, getProperty, getText, getTextCharacters, getTextCharacters, getTextLength, getTextStart, getVersion, hasName, hasNext, hasText, isAttributeSpecified, isCharacters, isEndElement, isStandalone, isStartElement, isWhiteSpace, nextTag, require, standaloneSet |
| Methods inherited from interface org.codehaus.stax2.AttributeInfo |
getAttributeCount |
| Methods inherited from interface org.codehaus.stax2.LocationInfo |
getLocation |
mDepth
protected int mDepth
- Number of open (start) elements currently.
Stax2ReaderAdapter
protected Stax2ReaderAdapter(javax.xml.stream.XMLStreamReader sr)
wrapIfNecessary
public static org.codehaus.stax2.XMLStreamReader2 wrapIfNecessary(javax.xml.stream.XMLStreamReader sr)
- Method that should be used to add dynamic support for
XMLStreamReader2. Method will check whether the
stream reader passed happens to be a XMLStreamReader2;
and if it is, return it properly cast. If not, it will create
necessary wrapper to support features needed by StaxMate,
using vanilla Stax 1.0 interface.
next
public int next()
throws javax.xml.stream.XMLStreamException
- Specified by:
next in interface javax.xml.stream.XMLStreamReader- Overrides:
next in class javax.xml.stream.util.StreamReaderDelegate
- Throws:
javax.xml.stream.XMLStreamException
getFeature
public java.lang.Object getFeature(java.lang.String name)
- Specified by:
getFeature in interface org.codehaus.stax2.XMLStreamReader2
setFeature
public void setFeature(java.lang.String name,
java.lang.Object value)
- Specified by:
setFeature in interface org.codehaus.stax2.XMLStreamReader2
isPropertySupported
public boolean isPropertySupported(java.lang.String name)
- Specified by:
isPropertySupported in interface org.codehaus.stax2.XMLStreamReader2
setProperty
public boolean setProperty(java.lang.String name,
java.lang.Object value)
- Specified by:
setProperty in interface org.codehaus.stax2.XMLStreamReader2
skipElement
public void skipElement()
throws javax.xml.stream.XMLStreamException
- Specified by:
skipElement in interface org.codehaus.stax2.XMLStreamReader2
- Throws:
javax.xml.stream.XMLStreamException
getAttributeInfo
public org.codehaus.stax2.AttributeInfo getAttributeInfo()
throws javax.xml.stream.XMLStreamException
- Specified by:
getAttributeInfo in interface org.codehaus.stax2.XMLStreamReader2
- Throws:
javax.xml.stream.XMLStreamException
getDTDInfo
public org.codehaus.stax2.DTDInfo getDTDInfo()
throws javax.xml.stream.XMLStreamException
- Specified by:
getDTDInfo in interface org.codehaus.stax2.XMLStreamReader2
- Throws:
javax.xml.stream.XMLStreamException
getLocationInfo
public final org.codehaus.stax2.LocationInfo getLocationInfo()
- Location information is always accessible, for this reader.
- Specified by:
getLocationInfo in interface org.codehaus.stax2.XMLStreamReader2
getText
public int getText(java.io.Writer w,
boolean preserveContents)
throws java.io.IOException,
javax.xml.stream.XMLStreamException
- Specified by:
getText in interface org.codehaus.stax2.XMLStreamReader2
- Throws:
java.io.IOException
javax.xml.stream.XMLStreamException
getDepth
public int getDepth()
- Specified by:
getDepth in interface org.codehaus.stax2.XMLStreamReader2
- Returns:
- Number of open elements in the stack; 0 when parser is in
prolog/epilog, 1 inside root element and so on.
isEmptyElement
public boolean isEmptyElement()
throws javax.xml.stream.XMLStreamException
- Alas, there is no way to find this out via Stax 1.0, so this
implementation always returns false.
- Specified by:
isEmptyElement in interface org.codehaus.stax2.XMLStreamReader2
- Throws:
javax.xml.stream.XMLStreamException
getNonTransientNamespaceContext
public javax.xml.namespace.NamespaceContext getNonTransientNamespaceContext()
- Specified by:
getNonTransientNamespaceContext in interface org.codehaus.stax2.XMLStreamReader2
getPrefixedName
public java.lang.String getPrefixedName()
- Specified by:
getPrefixedName in interface org.codehaus.stax2.XMLStreamReader2
closeCompletely
public void closeCompletely()
throws javax.xml.stream.XMLStreamException
- Specified by:
closeCompletely in interface org.codehaus.stax2.XMLStreamReader2
- Throws:
javax.xml.stream.XMLStreamException
findAttributeIndex
public int findAttributeIndex(java.lang.String nsURI,
java.lang.String localName)
- Specified by:
findAttributeIndex in interface org.codehaus.stax2.AttributeInfo
getIdAttributeIndex
public int getIdAttributeIndex()
- Specified by:
getIdAttributeIndex in interface org.codehaus.stax2.AttributeInfo
getNotationAttributeIndex
public int getNotationAttributeIndex()
- Specified by:
getNotationAttributeIndex in interface org.codehaus.stax2.AttributeInfo
getProcessedDTD
public java.lang.Object getProcessedDTD()
- Specified by:
getProcessedDTD in interface org.codehaus.stax2.DTDInfo
getDTDRootName
public java.lang.String getDTDRootName()
- Specified by:
getDTDRootName in interface org.codehaus.stax2.DTDInfo
getDTDPublicId
public java.lang.String getDTDPublicId()
- Specified by:
getDTDPublicId in interface org.codehaus.stax2.DTDInfo
getDTDSystemId
public java.lang.String getDTDSystemId()
- Specified by:
getDTDSystemId in interface org.codehaus.stax2.DTDInfo
getDTDInternalSubset
public java.lang.String getDTDInternalSubset()
- Specified by:
getDTDInternalSubset in interface org.codehaus.stax2.DTDInfo
- Returns:
- Internal subset portion of the DOCTYPE declaration, if any;
empty String if none
getProcessedDTDSchema
public org.codehaus.stax2.validation.DTDValidationSchema getProcessedDTDSchema()
- Specified by:
getProcessedDTDSchema in interface org.codehaus.stax2.DTDInfo
getStartingByteOffset
public long getStartingByteOffset()
- Specified by:
getStartingByteOffset in interface org.codehaus.stax2.LocationInfo
getStartingCharOffset
public long getStartingCharOffset()
- Specified by:
getStartingCharOffset in interface org.codehaus.stax2.LocationInfo
getEndingByteOffset
public long getEndingByteOffset()
throws javax.xml.stream.XMLStreamException
- Specified by:
getEndingByteOffset in interface org.codehaus.stax2.LocationInfo
- Throws:
javax.xml.stream.XMLStreamException
getEndingCharOffset
public long getEndingCharOffset()
throws javax.xml.stream.XMLStreamException
- Specified by:
getEndingCharOffset in interface org.codehaus.stax2.LocationInfo
- Throws:
javax.xml.stream.XMLStreamException
getStartLocation
public org.codehaus.stax2.XMLStreamLocation2 getStartLocation()
- Specified by:
getStartLocation in interface org.codehaus.stax2.LocationInfo
getCurrentLocation
public org.codehaus.stax2.XMLStreamLocation2 getCurrentLocation()
- Specified by:
getCurrentLocation in interface org.codehaus.stax2.LocationInfo
getEndLocation
public final org.codehaus.stax2.XMLStreamLocation2 getEndLocation()
throws javax.xml.stream.XMLStreamException
- Specified by:
getEndLocation in interface org.codehaus.stax2.LocationInfo
- Throws:
javax.xml.stream.XMLStreamException
validateAgainst
public org.codehaus.stax2.validation.XMLValidator validateAgainst(org.codehaus.stax2.validation.XMLValidationSchema schema)
throws javax.xml.stream.XMLStreamException
- Specified by:
validateAgainst in interface org.codehaus.stax2.validation.Validatable
- Throws:
javax.xml.stream.XMLStreamException
stopValidatingAgainst
public org.codehaus.stax2.validation.XMLValidator stopValidatingAgainst(org.codehaus.stax2.validation.XMLValidationSchema schema)
throws javax.xml.stream.XMLStreamException
- Specified by:
stopValidatingAgainst in interface org.codehaus.stax2.validation.Validatable
- Throws:
javax.xml.stream.XMLStreamException
stopValidatingAgainst
public org.codehaus.stax2.validation.XMLValidator stopValidatingAgainst(org.codehaus.stax2.validation.XMLValidator validator)
throws javax.xml.stream.XMLStreamException
- Specified by:
stopValidatingAgainst in interface org.codehaus.stax2.validation.Validatable
- Throws:
javax.xml.stream.XMLStreamException
setValidationProblemHandler
public org.codehaus.stax2.validation.ValidationProblemHandler setValidationProblemHandler(org.codehaus.stax2.validation.ValidationProblemHandler h)
- Specified by:
setValidationProblemHandler in interface org.codehaus.stax2.validation.Validatable
throwUnsupported
protected void throwUnsupported()
throws javax.xml.stream.XMLStreamException
- Throws:
javax.xml.stream.XMLStreamException
throwNotStartElem
protected void throwNotStartElem()