Java XMLStreamReader toReadableEvent(XMLStreamReader r)

Here you can find the source of toReadableEvent(XMLStreamReader r)

Description

Utility method that converts the current event on the XML stream to something human-readable for debug purposes.

License

Apache License

Parameter

Parameter Description
r The XML stream reader whose current event is to be converted to a readable string.

Return

The event in human-readable form.

Declaration

public static final String toReadableEvent(XMLStreamReader r) 

Method Source Code

//package com.java2s;
// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.  See the NOTICE file *

import javax.xml.stream.*;

public class Main {
    /**/*from  w  w  w . ja v  a  2 s .co  m*/
     * Utility method that converts the current event on the XML stream to something human-readable for debug purposes.
     *
     * @param r The XML stream reader whose current event is to be converted to a readable string.
     * @return The event in human-readable form.
     */
    public static final String toReadableEvent(XMLStreamReader r) {
        int t = r.getEventType();
        if (t == 1)
            return "<" + r.getLocalName() + ">";
        if (t == 2)
            return "</" + r.getLocalName() + ">";
        if (t == 3)
            return "PROCESSING_INSTRUCTION";
        if (t == 4)
            return "CHARACTERS=[" + r.getText() + "]";
        if (t == 5)
            return "COMMENTS=[" + r.getText() + "]";
        if (t == 6)
            return "SPACE=[" + r.getText() + "]";
        if (t == 7)
            return "START_DOCUMENT";
        if (t == 8)
            return "END_DOCUMENT";
        if (t == 9)
            return "ENTITY_REFERENCE";
        if (t == 10)
            return "ATTRIBUTE";
        if (t == 11)
            return "DTD";
        if (t == 12)
            return "CDATA=[" + r.getText() + "]";
        if (t == 13)
            return "NAMESPACE";
        if (t == 14)
            return "NOTATION_DECLARATION";
        if (t == 15)
            return "ENTITY_DECLARATION";
        return "UNKNOWN";
    }
}

Related

  1. readTextWithNodes(XMLStreamReader xsr, Map nodeIdToOffsetMap)
  2. skip(XMLStreamReader parser)
  3. skip(XMLStreamReader parser)
  4. skipEventsTo(int targetEvent, XMLStreamReader parser)
  5. skipNewLines(XMLStreamReader xmlStreamReader)
  6. write(XMLStreamReader xmlr, XMLStreamWriter writer)
  7. writeCharacters(XMLStreamReader reader, XMLStreamWriter writer)