Package org.jboss.staxmapper
Interface XMLExtendedStreamReader
-
- All Superinterfaces:
javax.xml.stream.XMLStreamConstants
,javax.xml.stream.XMLStreamReader
- All Known Implementing Classes:
XMLExtendedStreamReaderImpl
public interface XMLExtendedStreamReader extends javax.xml.stream.XMLStreamReader
An XML stream reader that can read nested<xs:any>
content using a registered set of root elements.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
discardRemainder()
Discard the remaining content of an element.<T> T
getAttributeValue(int index, java.lang.Class<T> kind)
Get the attribute value using intelligent type conversion.java.lang.String
getId()
Get the XML ID attribute, if any.int
getIntAttributeValue(int index)
Get the value of an attribute as an integer.int[]
getIntListAttributeValue(int index)
Get the value of an attribute as an integer list.java.util.List<java.lang.String>
getListAttributeValue(int index)
Get the value of an attribute as a space-delimited string list.<T> java.util.List<? extends T>
getListAttributeValue(int index, java.lang.Class<T> kind)
Get the attribute value as a list using intelligent type conversion.long
getLongAttributeValue(int index)
Get the value of an attribute as a long.long[]
getLongListAttributeValue(int index)
Get the value of an attribute as a long integer list.XMLMapper
getXMLMapper()
void
handleAny(java.lang.Object value)
Handle an<xs:any>
-type nested element, passing in the given value, returning after the end of the element.void
handleAttribute(java.lang.Object value, int index)
Handle an extended attribute, passing in the given value.void
setTrimElementText(boolean trim)
Whether or notXMLStreamReader.getElementText()
should trim content.-
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, next, nextTag, require, standaloneSet
-
-
-
-
Method Detail
-
handleAny
void handleAny(java.lang.Object value) throws javax.xml.stream.XMLStreamException
Handle an<xs:any>
-type nested element, passing in the given value, returning after the end of the element. Must be positioned on aSTART_ELEMENT
or an exception will occur. On return the cursor will be positioned on the correspondingEND_ELEMENT
.- Parameters:
value
- the value to pass in- Throws:
javax.xml.stream.XMLStreamException
- if an error occurs (e.g. the given value does not match the type of the handler for the element, or the element is unknown)
-
handleAttribute
void handleAttribute(java.lang.Object value, int index) throws javax.xml.stream.XMLStreamException
Handle an extended attribute, passing in the given value. Must be positioned on aSTART_ELEMENT
or an exception will occur. On return the cursor will be pointing at the sameSTART_ELEMENT
.- Parameters:
value
- the value to pass inindex
- the index of the attribute to process- Throws:
javax.xml.stream.XMLStreamException
- if an error occurs
-
discardRemainder
void discardRemainder() throws javax.xml.stream.XMLStreamException
Discard the remaining content of an element. Runs until aEND_ELEMENT
is encountered. If aSTART_ELEMENT
is encountered, then recursively consume and ignore its content as well.- Throws:
javax.xml.stream.XMLStreamException
- if an error occurs.
-
getIntAttributeValue
int getIntAttributeValue(int index) throws javax.xml.stream.XMLStreamException
Get the value of an attribute as an integer.- Parameters:
index
- the index of the attribute- Returns:
- the integer value
- Throws:
javax.xml.stream.XMLStreamException
- if an error occurs
-
getIntListAttributeValue
int[] getIntListAttributeValue(int index) throws javax.xml.stream.XMLStreamException
Get the value of an attribute as an integer list.- Parameters:
index
- the index of the attribute- Returns:
- the integer values
- Throws:
javax.xml.stream.XMLStreamException
- if an error occurs
-
getListAttributeValue
java.util.List<java.lang.String> getListAttributeValue(int index) throws javax.xml.stream.XMLStreamException
Get the value of an attribute as a space-delimited string list.- Parameters:
index
- the index of the attribute- Returns:
- the values
- Throws:
javax.xml.stream.XMLStreamException
- if an error occurs
-
getLongAttributeValue
long getLongAttributeValue(int index) throws javax.xml.stream.XMLStreamException
Get the value of an attribute as a long.- Parameters:
index
- the index of the attribute- Returns:
- the long value
- Throws:
javax.xml.stream.XMLStreamException
- if an error occurs
-
getLongListAttributeValue
long[] getLongListAttributeValue(int index) throws javax.xml.stream.XMLStreamException
Get the value of an attribute as a long integer list.- Parameters:
index
- the index of the attribute- Returns:
- the long values
- Throws:
javax.xml.stream.XMLStreamException
- if an error occurs
-
getAttributeValue
<T> T getAttributeValue(int index, java.lang.Class<T> kind) throws javax.xml.stream.XMLStreamException
Get the attribute value using intelligent type conversion. Numeric types will be parsed; enum types will be mapped.- Type Parameters:
T
- the type of the expected object- Parameters:
index
- the index of the attributekind
- the class of the expected object- Returns:
- the object equivalent
- Throws:
javax.xml.stream.XMLStreamException
- if an error occurs
-
getListAttributeValue
<T> java.util.List<? extends T> getListAttributeValue(int index, java.lang.Class<T> kind) throws javax.xml.stream.XMLStreamException
Get the attribute value as a list using intelligent type conversion. Numeric types will be parsed; enum types will be mapped.- Parameters:
index
- the index of the attributekind
- the class of the expected object- Returns:
- the list of object equivalents
- Throws:
javax.xml.stream.XMLStreamException
- if an error occurs
-
getId
java.lang.String getId() throws javax.xml.stream.XMLStreamException
Get the XML ID attribute, if any.- Returns:
- the attribute value
- Throws:
javax.xml.stream.XMLStreamException
- if an error occurs
-
getXMLMapper
XMLMapper getXMLMapper()
- Returns:
- the XMLMapper. Will not return
null
-
setTrimElementText
void setTrimElementText(boolean trim)
Whether or notXMLStreamReader.getElementText()
should trim content. The default is true.- Parameters:
trim
- trim if true, don't if false
-
-