Package org.codehaus.stax2.ri.evt
Class Stax2EventReaderAdapter
java.lang.Object
org.codehaus.stax2.ri.evt.Stax2EventReaderAdapter
- All Implemented Interfaces:
Iterator
,XMLEventReader
,XMLEventReader2
This adapter implements parts of
XMLEventReader2
, the
extended stream reader defined by Stax2 extension, by wrapping
a vanilla Stax 1.0 XMLEventReader
implementation.
Note: the implementation may be incomplete as-is, since not all features needed are necessarily accessible via basic Stax 1.0 interface. As such, two main use cases for this wrapper are:
- Serve as convenient base class for a complete implementation, which can use native accessors provided by the wrapped Stax implementation
- To be used for tasks that make limited use of Stax2 API, such that missing parts are not needed
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
getProperty
(String name) boolean
hasNext()
boolean
Method that is similar toXMLEventReader.hasNext()
, except that it can throw aXMLStreamException
.boolean
isPropertySupported
(String name) Method similar toXMLInputFactory.isPropertySupported(java.lang.String)
, used to determine whether a property is supported by the Reader instance.next()
nextTag()
peek()
void
remove()
Note: only here because we implement Iterator interface.boolean
setProperty
(String name, Object value) Method that can be used to set per-reader properties; a subset of properties one can set via matchingXMLInputFactory2
instance.static XMLEventReader2
Method that should be used to add dynamic support forXMLEventReader2
.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Iterator
forEachRemaining
-
Field Details
-
mReader
-
-
Constructor Details
-
Stax2EventReaderAdapter
-
-
Method Details
-
wrapIfNecessary
Method that should be used to add dynamic support forXMLEventReader2
. Method will check whether the stream reader passed happens to be aXMLEventReader2
; and if it is, return it properly cast. If not, it will create necessary wrapper. -
close
- Specified by:
close
in interfaceXMLEventReader
- Throws:
XMLStreamException
-
getElementText
- Specified by:
getElementText
in interfaceXMLEventReader
- Throws:
XMLStreamException
-
getProperty
- Specified by:
getProperty
in interfaceXMLEventReader
-
hasNext
public boolean hasNext()- Specified by:
hasNext
in interfaceIterator
- Specified by:
hasNext
in interfaceXMLEventReader
-
nextEvent
- Specified by:
nextEvent
in interfaceXMLEventReader
- Throws:
XMLStreamException
-
next
-
nextTag
- Specified by:
nextTag
in interfaceXMLEventReader
- Throws:
XMLStreamException
-
peek
- Specified by:
peek
in interfaceXMLEventReader
- Throws:
XMLStreamException
-
remove
public void remove()Note: only here because we implement Iterator interface. -
hasNextEvent
Description copied from interface:XMLEventReader2
Method that is similar toXMLEventReader.hasNext()
, except that it can throw aXMLStreamException
. This is important distinction, since the underlying stream reader is NOT allowed to throw such an exception when itshasNext()
gets called; but the underlying parser may well need to advance the input stream and in doing so may encounter an exception. This exception should be propagated to the caller, as it may signal a problem with the input stream or xml content.- Specified by:
hasNextEvent
in interfaceXMLEventReader2
- Throws:
XMLStreamException
-
isPropertySupported
Description copied from interface:XMLEventReader2
Method 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:
isPropertySupported
in interfaceXMLEventReader2
-
setProperty
Description copied from interface:XMLEventReader2
Method that can be used to set per-reader properties; a subset of properties one can set via matchingXMLInputFactory2
instance. Exactly which methods are mutable is implementation specific.- Specified by:
setProperty
in interfaceXMLEventReader2
- 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
-