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

This code example shows how to use the following methods:createComment, createEndDocument, createStartDocument
	/** 
	 * StartDocument and EndDocument events are not passed to the wrapped 
	 * writer. 
	 */ 
	public void testNoStartEnd() throws Exception {
		XMLEvent event = eventFactory.createComment("testEvent");
 
		// mock expects only a single event 
		wrappedWriter.add(event);
 
		writer.add(eventFactory.createStartDocument());
		writer.add(event);
		writer.add(eventFactory.createEndDocument());
 
	} 
	 
	/** 
	 * Close is not delegated to the wrapped writer. Instead, the wrapped writer is flushed. 
	 */ 
	public void testClose() throws Exception {
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:createEndElement, createStartElement
	} 
 
	@Override 
	public void writeStartElement(String localName) throws XMLStreamException {
		closeEmptyElementIfNecessary(); 
		doWriteStartElement(this.eventFactory.createStartElement(new QName(localName), null, null));
	} 
 
	@Override 
	public void writeStartElement(String namespaceURI, String localName) throws XMLStreamException {
		closeEmptyElementIfNecessary(); 
		doWriteStartElement(this.eventFactory.createStartElement(new QName(namespaceURI, localName), null, null));
	} 
 
	@Override 
	public void writeStartElement(String prefix, String localName, String namespaceURI) throws XMLStreamException {
		closeEmptyElementIfNecessary(); 
		doWriteStartElement(this.eventFactory.createStartElement(new QName(namespaceURI, localName, prefix), null, null));
	} 
 

6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:createAttribute, createCData, createCharacters, createEndElement, createStartDocument
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:createAttribute, createCharacters, createEndElement, createStartElement
This code example shows how to use the following methods:createEndDocument, createEndElement
		return result;
	} 
 
	private List<XMLEvent> getFooterElements() throws XMLStreamException {
		List<XMLEvent> result = new ArrayList<XMLEvent>();
		result.add(xmlEventFactory.createEndElement("", null, "body"));
		result.add(xmlEventFactory.createEndElement("", null, "html"));
		result.add(xmlEventFactory.createEndDocument());
		return result;
	} 
 
	private static boolean isBodyStartElement(XMLEvent xmlEvent) {
		return xmlEvent.isStartElement() && xmlEvent.asStartElement().getName().getLocalPart().equals("body");
	} 
 
	private static boolean isBodyEndElement(XMLEvent xmlEvent) {
		return xmlEvent.isEndElement() && xmlEvent.asEndElement().getName().getLocalPart().equals("body");
	} 
} 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:createCharacters
		this.eventWriter.add(this.eventFactory.createEndElement(name, namespaces.iterator()));
	} 
 
	@Override 
	protected void charactersInternal(String data) throws XMLStreamException {
		this.eventWriter.add(this.eventFactory.createCharacters(data));
	} 
 
	@Override 
	protected void cDataInternal(String data) throws XMLStreamException {
		this.eventWriter.add(this.eventFactory.createCData(data));
	} 
 
	@Override 
	protected void ignorableWhitespaceInternal(String data) throws XMLStreamException {
		this.eventWriter.add(this.eventFactory.createIgnorableSpace(data));
	} 
 
	@Override 
	protected void processingInstructionInternal(String target, String data) throws XMLStreamException {
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:createEndElement, createStartElement
		writer = new UnclosedElementCollectingEventWriter(wrappedWriter);
	} 
     
    @Test
    public void testNoUnclosedElements() throws Exception {
    	writer.add(eventFactory.createStartElement(elementA, null, null));
    	writer.add(eventFactory.createEndElement(elementA, null));
 
    	assertEquals(0, writer.getUnclosedElements().size());
		verify(wrappedWriter, Mockito.times(2)).add(Mockito.any(XMLEvent.class));
    } 
 
    @Test
    public void testSingleUnclosedElement() throws Exception {
    	writer.add(eventFactory.createStartElement(elementA, null, null));
    	writer.add(eventFactory.createEndElement(elementA, null));
    	writer.add(eventFactory.createStartElement(elementB, null, null));
 
    	assertEquals(1, writer.getUnclosedElements().size());
    	assertEquals(elementB, writer.getUnclosedElements().get(0));
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:createEndElement, createStartElement
    	verify(ioWriter, Mockito.times(2)).flush();
    } 
     
    @Test
    public void testEndUnopenedElementRemovesFromList() throws Exception {
    	EndElement endElement = eventFactory.createEndElement(unopenedB, null);
    	writer.add(endElement);
    	 
    	verify(wrappedWriter, Mockito.never()).add(endElement);
    	verify(wrappedWriter).flush();
    	verify(ioWriter).write("</unopened-b>");
    	verify(ioWriter).flush();
    	 
    	StartElement startElement = eventFactory.createStartElement(unopenedB, null, null);
    	writer.add(startElement);
    	endElement = eventFactory.createEndElement(unopenedB, null);
    	writer.add(endElement);
 
    	verify(wrappedWriter).add(startElement);
    	verify(wrappedWriter).add(endElement);
    	 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:createCharacters, createEndDocument, createNamespace, createStartDocument, XMLEventFactory.createAttribute
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:createCharacters, createEndElement, createStartElement
See Code Examples for Java 8 XMLEventFactory Methods: