Package org.codehaus.stax2.ri.evt
Class Stax2FilteredEventReader
- java.lang.Object
-
- org.codehaus.stax2.ri.evt.Stax2FilteredEventReader
-
- All Implemented Interfaces:
java.util.Iterator<java.lang.Object>
,javax.xml.stream.XMLEventReader
,javax.xml.stream.XMLStreamConstants
,XMLEventReader2
public class Stax2FilteredEventReader extends java.lang.Object implements XMLEventReader2, javax.xml.stream.XMLStreamConstants
Some notes about implemention:
- There is no way to filter out values of peek(), so we'll just straight dispatch the call to underlying reader
-
-
Constructor Summary
Constructors Constructor Description Stax2FilteredEventReader(XMLEventReader2 r, javax.xml.stream.EventFilter f)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
java.lang.String
getElementText()
java.lang.Object
getProperty(java.lang.String name)
boolean
hasNext()
boolean
hasNextEvent()
Method that is similar toXMLEventReader.hasNext()
, except that it can throw aXMLStreamException
.boolean
isPropertySupported(java.lang.String name)
Method similar toXMLInputFactory.isPropertySupported(java.lang.String)
, used to determine whether a property is supported by the Reader instance.java.lang.Object
next()
javax.xml.stream.events.XMLEvent
nextEvent()
javax.xml.stream.events.XMLEvent
nextTag()
javax.xml.stream.events.XMLEvent
peek()
This is bit tricky to implement, but it should filter out events just as nextEvent() would.void
remove()
Note: only here because we implement Iterator interfaceboolean
setProperty(java.lang.String name, java.lang.Object value)
Method that can be used to set per-reader properties; a subset of properties one can set via matchingXMLInputFactory2
instance.
-
-
-
Constructor Detail
-
Stax2FilteredEventReader
public Stax2FilteredEventReader(XMLEventReader2 r, javax.xml.stream.EventFilter f)
-
-
Method Detail
-
close
public void close() throws javax.xml.stream.XMLStreamException
- Specified by:
close
in interfacejavax.xml.stream.XMLEventReader
- Throws:
javax.xml.stream.XMLStreamException
-
getElementText
public java.lang.String getElementText() throws javax.xml.stream.XMLStreamException
- Specified by:
getElementText
in interfacejavax.xml.stream.XMLEventReader
- Throws:
javax.xml.stream.XMLStreamException
-
getProperty
public java.lang.Object getProperty(java.lang.String name)
- Specified by:
getProperty
in interfacejavax.xml.stream.XMLEventReader
-
hasNext
public boolean hasNext()
- Specified by:
hasNext
in interfacejava.util.Iterator<java.lang.Object>
- Specified by:
hasNext
in interfacejavax.xml.stream.XMLEventReader
-
nextEvent
public javax.xml.stream.events.XMLEvent nextEvent() throws javax.xml.stream.XMLStreamException
- Specified by:
nextEvent
in interfacejavax.xml.stream.XMLEventReader
- Throws:
javax.xml.stream.XMLStreamException
-
next
public java.lang.Object next()
- Specified by:
next
in interfacejava.util.Iterator<java.lang.Object>
-
nextTag
public javax.xml.stream.events.XMLEvent nextTag() throws javax.xml.stream.XMLStreamException
- Specified by:
nextTag
in interfacejavax.xml.stream.XMLEventReader
- Throws:
javax.xml.stream.XMLStreamException
-
peek
public javax.xml.stream.events.XMLEvent peek() throws javax.xml.stream.XMLStreamException
This is bit tricky to implement, but it should filter out events just as nextEvent() would.- Specified by:
peek
in interfacejavax.xml.stream.XMLEventReader
- Throws:
javax.xml.stream.XMLStreamException
-
remove
public void remove()
Note: only here because we implement Iterator interface- Specified by:
remove
in interfacejava.util.Iterator<java.lang.Object>
-
hasNextEvent
public boolean hasNextEvent() throws javax.xml.stream.XMLStreamException
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:
javax.xml.stream.XMLStreamException
-
isPropertySupported
public boolean isPropertySupported(java.lang.String name)
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
public boolean setProperty(java.lang.String name, java.lang.Object value)
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
-
-