public abstract class AbstractXMLStreaming extends Object
Modifier | Constructor and Description |
---|---|
protected |
AbstractXMLStreaming() |
Modifier and Type | Method and Description |
---|---|
protected boolean |
expect(XMLStreamReader reader,
boolean closingOK,
QName... names)
Scan forward until we see an opening or closing tag.
|
protected void |
expectClose(XMLStreamReader reader)
Scan forward expecting to see a closing tag.
|
protected String |
getAttr(XMLStreamReader reader,
QName name)
Get a requried attribute from the current element.
|
protected String |
getAttr(XMLStreamReader reader,
QName name,
boolean required)
Get an attribute from the current element.
|
protected boolean |
getBooleanAttr(XMLStreamReader reader,
QName name)
Get a requried boolean attribute from the current element.
|
protected Boolean |
getBooleanAttr(XMLStreamReader reader,
QName name,
boolean required)
Get an attribute from the current element and parse as a boolean value.
|
protected int |
getIntAttr(XMLStreamReader reader,
QName name)
Get a requried integer attribute from the current element.
|
protected Integer |
getIntAttr(XMLStreamReader reader,
QName name,
boolean required)
Get an attribute from the current element and parse as a decimal integer value.
|
protected Long |
getLongAttr(XMLStreamReader reader,
QName name,
boolean required)
Get an attribute from the current element and parse as a decimal long value.
|
protected XMLStreamException |
newInvalidAttributeException(XMLStreamReader reader,
QName name,
String description,
Throwable... cause)
Build a
XMLStreamException caused by invalid content in an attribute. |
protected QName |
next(XMLStreamReader reader)
Skip forward until either the next opening tag is reached, or the currently open tag is closed.
|
protected void |
skip(XMLStreamReader reader)
Skip over the remainder of the current XML element, including any nested elements,
until the closing XML tag is seen and consumed.
|
protected void |
writeElement(XMLStreamWriter writer,
QName element,
String content)
Write out a simple XML element containing the given content.
|
protected boolean expect(XMLStreamReader reader, boolean closingOK, QName... names) throws XMLStreamException
names
and then we return true, if not or if names
is empty throw an exception; if a closing tag is seen, return false if closingOK
, else throw exception.reader
- XML inputclosingOK
- true if a closing tag is OK, otherwise falsenames
- expected opening tag, or null if we expected a closing tagXMLStreamException
- if something unexpected is encounteredprotected QName next(XMLStreamReader reader) throws XMLStreamException
reader
- XML inputXMLStreamException
- if no opening tag is found before the current tag closesXMLStreamException
- if something unexpected is encounteredprotected void skip(XMLStreamReader reader) throws XMLStreamException
reader
- XML inputXMLStreamException
- if something unexpected is encounteredprotected void expectClose(XMLStreamReader reader) throws XMLStreamException
Equivalant to: expect
(reader, true)
.
reader
- XML inputXMLStreamException
- if something other than a closing tag is encounteredprotected void writeElement(XMLStreamWriter writer, QName element, String content) throws XMLStreamException
writer
- XML outputelement
- element namecontent
- simple contentXMLStreamException
- if error occurs writing outputprotected String getAttr(XMLStreamReader reader, QName name, boolean required) throws XMLStreamException
reader
- XML inputname
- attribute namerequired
- whether attribute must be presentrequired
and no attribute is presentIllegalStateException
- if the current event is not a start element eventXMLStreamException
- if required
is true and no such attribute is foundprotected String getAttr(XMLStreamReader reader, QName name) throws XMLStreamException
getAttr(reader, name, true)
.reader
- XML inputname
- attribute nameIllegalStateException
- if the current event is not a start element eventXMLStreamException
- if no such attribute is foundprotected Integer getIntAttr(XMLStreamReader reader, QName name, boolean required) throws XMLStreamException
reader
- XML inputname
- attribute namerequired
- whether attribute must be presentrequired
and no attribute is presentIllegalStateException
- if the current event is not a start element eventXMLStreamException
- if required
is true and no such attribute is foundXMLStreamException
- if attribute is not an integer valueprotected Long getLongAttr(XMLStreamReader reader, QName name, boolean required) throws XMLStreamException
reader
- XML inputname
- attribute namerequired
- whether attribute must be presentrequired
and no attribute is presentIllegalStateException
- if the current event is not a start element eventXMLStreamException
- if required
is true and no such attribute is foundXMLStreamException
- if attribute is not an integer valueprotected int getIntAttr(XMLStreamReader reader, QName name) throws XMLStreamException
getIntAttr(reader, name, true)
.reader
- XML inputname
- attribute nameIllegalStateException
- if the current event is not a start element eventXMLStreamException
- if no such attribute is foundXMLStreamException
- if attribute is not an integer valueprotected Boolean getBooleanAttr(XMLStreamReader reader, QName name, boolean required) throws XMLStreamException
reader
- XML inputname
- attribute namerequired
- whether attribute must be presentrequired
and no attribute is presentIllegalStateException
- if the current event is not a start element eventXMLStreamException
- if required
is true and no such attribute is foundXMLStreamException
- if attribute is not "true"
or "false"
protected boolean getBooleanAttr(XMLStreamReader reader, QName name) throws XMLStreamException
getBooleanAttr(reader, name, true)
.reader
- XML inputname
- attribute nameIllegalStateException
- if the current event is not a start element eventXMLStreamException
- if no such attribute is foundXMLStreamException
- if attribute is not "true"
or "false"
protected XMLStreamException newInvalidAttributeException(XMLStreamReader reader, QName name, String description, Throwable... cause) throws XMLStreamException
XMLStreamException
caused by invalid content in an attribute.reader
- XML inputname
- attribute namedescription
- a description of the problemcause
- optional underlying exception for chainingIllegalArgumentException
- if more than one cause
is givenXMLStreamException
- if error occurs accessing the attribute valueCopyright © 2022. All rights reserved.