Java Utililty Methods XMLStreamReader

List of utility methods to do XMLStreamReader

Description

The list of methods to do XMLStreamReader are organized into topic(s).

Method

intgetNextEvent(XMLStreamReader reader)
Returns the next relevant reader event.
while (reader.hasNext()) {
    int e = reader.next();
    if (e == XMLStreamConstants.END_DOCUMENT) {
        return e;
    if (e == XMLStreamConstants.START_ELEMENT || e == XMLStreamConstants.END_ELEMENT) {
        return e;
    } else if (e == XMLStreamConstants.CHARACTERS) {
...
XMLStreamReadergetXMLStreamReader(File file)
get XML Stream Reader
InputStream inputStream = new BufferedInputStream(new FileInputStream(file));
return getStaxInputFactory().createXMLStreamReader(inputStream);
XMLStreamReadergetXMLStreamReader(InputStream is)
get XML Stream Reader
return new StreamReaderDelegate(XMLInputFactory.newInstance().createXMLStreamReader(is)) {
    public int next() throws XMLStreamException {
        while (true) {
            int event = super.next();
            switch (event) {
            case XMLStreamConstants.COMMENT:
            case XMLStreamConstants.PROCESSING_INSTRUCTION:
                continue;
...
QNamegetXSIType(XMLStreamReader reader)
Returns the value of xsi:type attribute
String qname = reader.getAttributeValue(XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI, "type");
return getValueAsQName(reader, qname);
booleanisContextual(XMLStreamReader input)
is Contextual
return input.getAttributeValue(LOCATION_NS, LOCATION_END_LINE_ATTR) != null ? true : false;
booleanisEndTag(XMLStreamReader reader, String tagLocalName)
Test if reader is on an end tag named tagLocalName.
return (reader.getEventType() == XMLStreamConstants.END_ELEMENT)
        && (reader.getLocalName().equals(tagLocalName));
booleanisStartTag(XMLStreamReader reader)
Test if reader is on a start tag.
return (reader.getEventType() == XMLStreamConstants.START_ELEMENT);
voidlogReader(Logger logger, String msg, XMLStreamReader reader)
log Reader
if (logger.isDebugEnabled()) {
    logger.debug(readerStatus(msg, reader));
booleanmove(XMLStreamReader reader)
move
if (reader.getEventType() == XMLStreamReader.START_ELEMENT
        || reader.getEventType() == XMLStreamReader.END_ELEMENT) {
    return false;
return true;
voidmoveReaderToEndCurrentTag(XMLStreamReader reader)
Moves the reader to the closing tag of current tag.
int level = 0;
QName tag = reader.getName();
for (int event = reader.getEventType(); reader.hasNext(); event = reader.next()) {
    if (XMLStreamReader.START_ELEMENT == event) {
        level += 1;
    } else if (XMLStreamReader.END_ELEMENT == event) {
        level -= 1;
        if (level == 0 && tag.equals(reader.getName())) {
...