Example usage for javax.xml.stream.util StreamReaderDelegate StreamReaderDelegate

List of usage examples for javax.xml.stream.util StreamReaderDelegate StreamReaderDelegate

Introduction

In this page you can find the example usage for javax.xml.stream.util StreamReaderDelegate StreamReaderDelegate.

Prototype

public StreamReaderDelegate(XMLStreamReader reader) 

Source Link

Document

Construct an filter with the specified parent.

Usage

From source file:Main.java

public static XMLStreamReader getXMLStreamReader(InputStream is)
        throws XMLStreamException, FactoryConfigurationError {
    //return XMLInputFactory.newInstance().createXMLStreamReader(is);
    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;
                default:
                    return event;
                }//  ww w.j a va 2s. c  o m
            }
        }
    };
}