Java 8 XMLEvent - 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 XMLEvent class.

This code example shows how to use the following methods:asEndElement, isEndElement, isStartElement
	} 
 
 
	@Override 
	public QName getName() {
		if (this.event.isStartElement()) {
			return this.event.asStartElement().getName();
		} 
		else if (this.event.isEndElement()) {
			return this.event.asEndElement().getName();
		} 
		else { 
			throw new IllegalStateException();
		} 
	} 
 
	@Override 
	public Location getLocation() {
		return this.event.getLocation();
	} 
7
CodeRank
This code example shows how to use the following methods:isEndDocument, isStartDocument
		super(wrappedEventWriter);
	} 
 
    @Override 
	public void add(XMLEvent event) throws XMLStreamException {
		if ((!event.isStartDocument()) && (!event.isEndDocument())) {
			wrappedEventWriter.add(event);
		} 
	} 
     
    // prevents OXM Marshallers from closing the XMLEventWriter 
    @Override 
    public void close() throws XMLStreamException {
    	flush(); 
    } 
} 
7
CodeRank
This code example shows how to use the following methods:isStartDocument, isStartElement
	 */ 
	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 
	protected void parseInternal() throws SAXException, XMLStreamException {
		boolean documentStarted = false;
		boolean documentEnded = false;
7
CodeRank
This code example shows how to use the following methods:isEndDocument, isEndElement, isStartDocument, isStartElement
        Assert.notNull(events, "'events' must not be null");
        this.events = events;
    } 
 
    public void add(XMLEvent event) throws XMLStreamException {
        if (event.isStartElement()) {
            startElementSeen = true;
            elementDepth++;
        } 
        else if (event.isEndElement()) {
            elementDepth--;
        } 
        else if (event.isStartDocument() || event.isEndDocument()) {
            return; 
        } 
        if (elementDepth >= 0 && startElementSeen) {
            events.add(event);
        } 
    } 
} 

7
CodeRank
This code example shows how to use the following methods:isEndElement, isStartElement
	/* (non-Javadoc) 
	 * @see org.springframework.batch.item.xml.stax.AbstractEventWriterWrapper#add(javax.xml.stream.events.XMLEvent) 
	 */ 
	@Override 
	public void add(XMLEvent event) throws XMLStreamException {
		if (event.isStartElement()) {
			unclosedElements.addLast(event.asStartElement().getName());
		} else if (event.isEndElement()) {
			unclosedElements.removeLast();
		} 
		super.add(event);
	} 
 
	public List<QName> getUnclosedElements() {
		return unclosedElements;
	} 
} 
6
CodeRank
This code example shows how to use the following methods:asEndElement, isEndElement, isStartElement
This code example shows how to use the following methods:asEndElement, asStartElement, isEndElement, isStartDocument, isStartElement
        } 
 
        @Override 
        public void staxSource(XMLEventReader eventReader) throws Exception {
            XMLEvent event = eventReader.peek();
            if (event != null && event.isStartDocument()) {
                event = eventReader.nextTag();
            } 
            if (event != null) {
                if (event.isStartElement()) {
                    result = event.asStartElement().getName();
                } 
                else if (event.isEndElement()) {
                    result = event.asEndElement().getName();
                } 
            } 
        } 
 
        @Override 
        public void staxSource(XMLStreamReader streamReader) throws Exception {
6
CodeRank
This code example shows how to use the following methods:getEventType, getLocation, getSchemaType, writeAsEncodedUnicode
This code example shows how to use the following methods:asEndElement, isEndElement
	} 
 
	private boolean isUnopenedElementCloseEvent(XMLEvent event) {
		if (unopenedElements.isEmpty()) {
			return false; 
		} else if (!event.isEndElement()) {
			return false; 
		} else { 
			return unopenedElements.getLast().equals(event.asEndElement().getName());
		} 
	} 
 
} 
6
CodeRank
This code example shows how to use the following methods:isEndElement, isStartElement
	 * Sets the endFragmentFollows flag to true if next event is the last event 
	 * of the fragment. 
	 * @param event peek() from wrapped event reader 
	 */ 
	private void checkFragmentEnd(XMLEvent event) {
		if (event.isStartElement() && ((StartElement) event).getName().equals(fragmentRootName)) {
			matchCounter++;
		} 
		else if (event.isEndElement() && ((EndElement) event).getName().equals(fragmentRootName)) {
			matchCounter--;
			if (matchCounter == 0) {
				endFragmentFollows = true;
			} 
		} 
	} 
 
	/** 
	 * @param event peek() from wrapped event reader 
	 * @param peek if true do not change the internal state 
	 * @return StartDocument event if peek() points to beginning of fragment 
6
CodeRank
See Code Examples for Java 8 XMLEvent Methods: