Java 8 XMLEventReader - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 XMLEventReader class.

This code example shows how to use the following methods:nextTag
	} 
 
	public void testPartial() throws Exception {
		XMLInputFactory inputFactory = XMLInputFactory.newInstance();
		XMLEventReader eventReader = inputFactory.createXMLEventReader(new StringReader(CONTENT));
		eventReader.nextTag(); // skip to root
		StaxEventXMLReader xmlReader = new StaxEventXMLReader(eventReader);
		ContentHandler contentHandler = mock(ContentHandler.class);
		xmlReader.setContentHandler(contentHandler);
		xmlReader.parse(new InputSource());
		verify(contentHandler).startDocument();
		verify(contentHandler).startElement("http://springframework.org/spring-ws", "child", "child", new AttributesImpl());
		verify(contentHandler).endElement("http://springframework.org/spring-ws", "child", "child");
		verify(contentHandler).endDocument();
	} 
} 
 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:peek
		this.eventReader = eventReader; 
	} 
 
 
	/** 
	 * Return the {@code XMLEventReader} used by this {@code StaxSource}. If this {@code StaxSource} 
	 * was created with an {@code XMLStreamReader}, the result will be {@code null}. 
	 * @return the StAX event reader used by this source 
	 * @see StaxSource#StaxSource(javax.xml.stream.XMLEventReader) 
	 */ 
	XMLEventReader getXMLEventReader() { 
		return this.eventReader; 
	} 
 
	/** 
	 * Return the {@code XMLStreamReader} used by this {@code StaxSource}. If this {@code StaxSource} 
	 * was created with an {@code XMLEventReader}, the result will be {@code null}. 
	 * @return the StAX event reader used by this source 
	 * @see StaxSource#StaxSource(javax.xml.stream.XMLEventReader) 
	 */ 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:peek
	 * Create a custom, non-JAXP 1.4 StAX {@link Source} for the given {@link XMLEventReader}. 
	 * @param eventReader the StAX event reader 
	 * @return a source wrapping the {@code eventReader} 
	 */ 
	public static Source createCustomStaxSource(XMLEventReader eventReader) {
		return new StaxSource(eventReader);
	} 
 
	/** 
	 * Indicate whether the given {@link Source} is a JAXP 1.4 StAX Source or 
	 * custom StAX Source. 
	 * @return {@code true} if {@code source} is a JAXP 1.4 {@link StAXSource} or 
	 * custom StAX Source; {@code false} otherwise 
	 */ 
	public static boolean isStaxSource(Source source) {
		return (source instanceof StAXSource || source instanceof StaxSource);
	} 
 
	/** 
	 * Return the {@link XMLStreamReader} for the given StAX Source. 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:peek
	 * {@code XMLStreamConstants.START_ELEMENT} state. 
	 * @param reader the {@code XMLEventReader} to read from 
	 * @throws IllegalStateException if the reader is not at the start of a document or element 
	 */ 
	StaxEventXMLReader(XMLEventReader reader) {
		Assert.notNull(reader, "'reader' must not be null");
		try { 
			XMLEvent event = reader.peek();
			if (event != null && !(event.isStartDocument() || event.isStartElement())) {
				throw new IllegalStateException("XMLEventReader not at start of document or element");
			} 
		} 
		catch (XMLStreamException ex) {
			throw new IllegalStateException("Could not read first element: " + ex.getMessage());
		} 
		this.reader = reader;
	} 
 
 
	@Override 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:close
		return this.event.getEventType();
	} 
 
	@Override 
	public void close() throws XMLStreamException {
		this.eventReader.close();
	} 
 
 
	@SuppressWarnings("rawtypes") 
	private static int countIterator(Iterator iterator) {
		int count = 0;
		while (iterator.hasNext()) {
			iterator.next();
			count++;
		} 
		return count;
	} 
 
} 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:nextEvent
import org.jibx.runtime.IBindingFactory; 
import org.jibx.runtime.IMarshallingContext; 
import org.jibx.runtime.IUnmarshallingContext; 
import org.jibx.runtime.IXMLReader; 
import org.jibx.runtime.IXMLWriter; 
import org.jibx.runtime.JiBXException; 
import org.jibx.runtime.ValidationException; 
import org.jibx.runtime.impl.MarshallingContext; 
import org.jibx.runtime.impl.StAXReaderWrapper; 
import org.jibx.runtime.impl.StAXWriter; 
import org.jibx.runtime.impl.UnmarshallingContext; 
import org.w3c.dom.Node;
import org.xml.sax.ContentHandler;
import org.xml.sax.InputSource;
import org.xml.sax.XMLReader;
import org.xml.sax.ext.LexicalHandler;
 
import org.springframework.beans.factory.InitializingBean; 
import org.springframework.oxm.MarshallingFailureException;
import org.springframework.oxm.UnmarshallingFailureException;
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:hasNext, nextEvent, nextTag
 
    @Override 
    protected Object readPlainValue( XMLEventReader input )
        throws Exception
    { 
        if( !input.hasNext() )
        { 
            return null; 
        } 
        XMLEvent nextEvent = input.nextEvent();
        if( nextEvent.getEventType() == XMLEvent.START_ELEMENT
            && "null".equals( nextEvent.asStartElement().getName().getLocalPart() ) )
        { 
            input.nextTag();
            return null; 
        } 
        if( nextEvent.getEventType() != XMLEvent.CHARACTERS )
        { 
            throw new ValueSerializationException( "Expected characters but got: " + nextEvent );
        } 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:nextTag
 */ 
abstract class StroapBody extends StroapElement implements SoapBody { 
 
    private StroapPayload payload;
 
    protected StroapBody(StroapMessageFactory messageFactory) {
        super(messageFactory.getSoapVersion().getBodyName(), messageFactory);
        this.payload = new CachingStroapPayload();
    } 
 
    protected StroapBody(StartElement startElement, StroapPayload payload, StroapMessageFactory messageFactory) {
        super(startElement, messageFactory);
        this.payload = payload;
    } 
 
    static StroapBody build(XMLEventReader eventReader, StroapMessageFactory messageFactory) throws XMLStreamException {
        XMLEvent event = eventReader.nextTag();
        if (!event.isStartElement()) {
            throw new StroapMessageCreationException("Unexpected event: " + event + ", expected StartElement");
        } 

5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:peek
     * @return true if this unmarshaller context is at the very beginning of a 
     *         source document (i.e. no data has been parsed from the document 
     *         yet). 
     */ 
    public boolean isStartOfDocument() throws XMLStreamException {
        return eventReader.peek().isStartDocument();
    } 
 
    /** 
     * Returns the next XML event for the document being parsed. 
     * 
     * @return The next XML event for the document being parsed. 
     * 
     * @throws XMLStreamException 
     */ 
    public XMLEvent nextEvent() throws XMLStreamException {
        if (attributeIterator != null && attributeIterator.hasNext()) {
            currentEvent = (XMLEvent)attributeIterator.next();
        } else { 
            currentEvent = eventReader.nextEvent();
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:peek
		return wrappedEventReader.nextTag();
	} 
 
    @Override 
	public XMLEvent peek() throws XMLStreamException {
		return wrappedEventReader.peek();
	} 
 
    @Override 
	public Object next() { 
		return wrappedEventReader.next();
	} 
 
    @Override 
	public void remove() { 
		wrappedEventReader.remove();
	} 
 
} 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
See Code Examples for Java 8 XMLEventReader Methods: