|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
@ComponentSpecification public interface StaxUtil
This is the interface for a collection of utility functions that help to deal with the StAX API (JSR 173).
StaxUtilImpl| Method Summary | ||
|---|---|---|
javax.xml.stream.XMLEventReader |
createXmlEventReader(InputStream inputStream)
This method creates an XMLEventReader. |
|
javax.xml.stream.XMLStreamReader |
createXmlStreamReader(InputStream inputStream)
This method creates an XMLStreamReader. |
|
javax.xml.stream.XMLStreamWriter |
createXmlStreamWriter(OutputStream out)
This method creates a XMLStreamWriter. |
|
javax.xml.stream.XMLStreamWriter |
createXmlStreamWriter(Writer writer)
This method creates a XMLStreamWriter. |
|
String |
getEventTypeName(int eventType)
This method gets the name for the given eventType. |
|
javax.xml.stream.events.XMLEvent |
nextElement(javax.xml.stream.XMLEventReader xmlReader)
This method skips all events until a StartElement,
EndElement or
EndDocument is
encountered. |
|
|
parseAttribute(javax.xml.stream.XMLStreamReader xmlReader,
String namespaceUri,
String localAttributeName,
Class<V> type)
This method parses the attribute with the given localAttributeName from the given xmlReader as
given by type. |
|
|
parseAttribute(javax.xml.stream.XMLStreamReader xmlReader,
String namespaceUri,
String localAttributeName,
Class<V> type,
V defaultValue)
This method parses the attribute with the given localAttributeName from the given xmlReader as
given by type. |
|
String |
readText(javax.xml.stream.XMLStreamReader xmlReader)
This method reads the text at the current
position of the given xmlReader. |
|
void |
skipOpenElement(javax.xml.stream.XMLEventReader xmlReader)
This method skips all events until the current element (tag) is closed. |
|
void |
skipOpenElement(javax.xml.stream.XMLStreamReader xmlReader)
This method skips all events until the current element (tag) is closed. |
|
| Method Detail |
|---|
javax.xml.stream.XMLStreamReader createXmlStreamReader(InputStream inputStream)
throws XmlGenericException
XMLStreamReader.
inputStream - is the InputStream to read from.
XMLStreamReader.
XmlGenericException - if the creation of the stream-reader failed
(StAX not available or misconfigured).XMLInputFactory.createXMLStreamReader(InputStream)
javax.xml.stream.XMLEventReader createXmlEventReader(InputStream inputStream)
throws XmlGenericException
XMLEventReader.
inputStream - is the InputStream to read from.
XMLEventReader.
XmlGenericException - if the creation of the event-reader failed
(StAX not available or misconfigured).XMLInputFactory.createXMLEventReader(InputStream)
javax.xml.stream.XMLStreamWriter createXmlStreamWriter(OutputStream out)
throws XmlGenericException
XMLStreamWriter.
out - is the output stream where the XML will be written to.
XmlGenericException - if the creation of the stream-writer failed
(StAX not available or misconfigured).XMLOutputFactory.createXMLStreamWriter(OutputStream)
javax.xml.stream.XMLStreamWriter createXmlStreamWriter(Writer writer)
throws XmlGenericException
XMLStreamWriter.
writer - is the writer where the XML will be written to.
XmlGenericException - if the creation of the stream-writer failed
(StAX not available or misconfigured).XMLOutputFactory.createXMLStreamWriter(Writer)
<V> V parseAttribute(javax.xml.stream.XMLStreamReader xmlReader,
String namespaceUri,
String localAttributeName,
Class<V> type)
throws ValueException
localAttributeName from the given xmlReader as
given by type.
V - is the generic for the type.xmlReader - is where to read the XML from.namespaceUri - is the URI representing the namespace of the requested
attribute or null to ignore the namespace.localAttributeName - is the local name of the requested attribute.type - is the type the requested attribute should be converted to.
type.
ValueException - if the attribute is NOT defined or its value can NOT
be converted to type.
<V> V parseAttribute(javax.xml.stream.XMLStreamReader xmlReader,
String namespaceUri,
String localAttributeName,
Class<V> type,
V defaultValue)
throws ValueException
localAttributeName from the given xmlReader as
given by type.
V - is the generic for the type.xmlReader - is where to read the XML from.namespaceUri - is the URI representing the namespace of the requested
attribute or null to ignore the namespace.localAttributeName - is the local name of the requested attribute.type - is the type the requested attribute should be converted to.defaultValue - is the default value returned if the requested
attribute is NOT defined. It may be null.
type.
ValueException - if the attribute value can NOT be converted to
type.
String readText(javax.xml.stream.XMLStreamReader xmlReader)
throws XmlGenericException
text at the current
position of the given xmlReader.xmlReader is pointing to XMLStreamConstants.START_ELEMENT or
XMLStreamConstants.ATTRIBUTE all
attributes are
skipped before.
For XMLEventReader use XMLEventReader.getElementText().
xmlReader - is the XMLStreamReader to read the XML from.
text at the current position
or null if there is no text to read (e.g.
XMLStreamConstants.END_ELEMENT was hit).
XmlGenericException - if an
XMLStreamException was caused by the given
xmlReader.
void skipOpenElement(javax.xml.stream.XMLStreamReader xmlReader)
throws XmlGenericException
... while (xmlReader.nextTag() ==XMLStreamConstants.START_ELEMENT) { String tagname = xmlReader.getLocalName(); if (XML_TAG_FOO.equals(tagname)) { handleFoo(xmlReader); } else { // ignore all other tags staxUtil.skipOpenElement(xmlReader); } }
xmlReader - is the STaX reader currently pointing at or inside the
element to skip. After the call of this method it will point to the
end-element event of the element to skip. Calling
XMLStreamReader.nextTag() will then point to start-element
of the next sibling or to end-element of the parent.
XmlGenericException - if an
XMLStreamException was caused by the given
xmlReader.
void skipOpenElement(javax.xml.stream.XMLEventReader xmlReader)
throws XmlGenericException
xmlReader - is the STaX reader currently pointing at or inside the
element to skip. After the call of this method it will point to the
end-element event of the element to skip. Calling
XMLEventReader.nextEvent() will then return the event after
the EndElement-Event of the skipped
element.
XmlGenericException - if an
XMLStreamException was caused by the given
xmlReader.skipOpenElement(XMLStreamReader)
javax.xml.stream.events.XMLEvent nextElement(javax.xml.stream.XMLEventReader xmlReader)
throws XmlGenericException
StartElement,
EndElement or
EndDocument is
encountered. Unlike
XMLEventReader.nextTag() no exception is thrown according to
unexpected events except if
has no next event.
xmlReader - is the XMLEventReader to read the XML from.
XmlGenericException - if an
XMLStreamException was caused by the given
xmlReader.String getEventTypeName(int eventType)
eventType.
eventType - is an event type constant declared in
XMLStreamConstants.
XMLStreamConstants
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||