Java Code Examples for javax.xml.stream.XMLEventFactory#newInstance()

The following examples show how to use javax.xml.stream.XMLEventFactory#newInstance() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AnimalRepository.java    From JavaMainRepo with Apache License 2.0 6 votes vote down vote up
public static void createNode(XMLEventWriter eventWriter, String name, String value) throws XMLStreamException {
	XMLEventFactory eventFactory = XMLEventFactory.newInstance();
	XMLEvent end = eventFactory.createDTD("\n");
	XMLEvent tab = eventFactory.createDTD("\t");
	// Create Start node
	StartElement sElement = eventFactory.createStartElement("", "", name);
	eventWriter.add(tab);
	eventWriter.add(sElement);
	// Create Content
	Characters characters = eventFactory.createCharacters(value);
	eventWriter.add(characters);
	// Create End node
	EndElement eElement = eventFactory.createEndElement("", "", name);
	eventWriter.add(eElement);
	eventWriter.add(end);
}
 
Example 2
Source File: EmployeeRepository.java    From JavaMainRepo with Apache License 2.0 6 votes vote down vote up
public static void createNode(XMLEventWriter eventWriter, String name, String value) throws XMLStreamException {
	XMLEventFactory eventFactory = XMLEventFactory.newInstance();
	XMLEvent end = eventFactory.createDTD("\n");
	XMLEvent tab = eventFactory.createDTD("\t");
	// Create start node
	StartElement sElement = eventFactory.createStartElement("", "", name);
	eventWriter.add(tab);
	eventWriter.add(sElement);
	// Create Content
	Characters characters = eventFactory.createCharacters(value);
	eventWriter.add(characters);
	// Create End node
	EndElement eElement = eventFactory.createEndElement("", "", name);
	eventWriter.add(eElement);
	eventWriter.add(end);
}
 
Example 3
Source File: EntityRepository.java    From JavaMainRepo with Apache License 2.0 6 votes vote down vote up
public static void createNode(XMLEventWriter eventWriter, String name, String value) throws XMLStreamException {

		XMLEventFactory eventFactory = XMLEventFactory.newInstance();
		XMLEvent end = eventFactory.createDTD("\n");
		XMLEvent tab = eventFactory.createDTD("\t");

		// Create start node
		StartElement sElement = eventFactory.createStartElement("", "", name);
		eventWriter.add(tab);
		eventWriter.add(sElement);

		// Create content

		Characters characters = eventFactory.createCharacters(value);
		eventWriter.add(characters);

		// Create end node

		EndElement eElement = eventFactory.createEndElement("", "", name);
		eventWriter.add(eElement);
		eventWriter.add(end);
	}
 
Example 4
Source File: EntityRepository.java    From JavaMainRepo with Apache License 2.0 6 votes vote down vote up
public static void createNode(XMLEventWriter eventWriter, String name, String value) throws XMLStreamException {
	XMLEventFactory eventFactory = XMLEventFactory.newInstance();
	XMLEvent end = eventFactory.createDTD("\n");
	XMLEvent tab = eventFactory.createDTD("\t");
	// Create Start node
	StartElement sElement = eventFactory.createStartElement("", "", name);
	eventWriter.add(tab);
	eventWriter.add(sElement);
	// Create Content
	Characters characters = eventFactory.createCharacters(value);
	eventWriter.add(characters);
	// Create End node
	EndElement eElement = eventFactory.createEndElement("", "", name);
	eventWriter.add(eElement);
	eventWriter.add(end);
}
 
Example 5
Source File: EntityRepository.java    From JavaMainRepo with Apache License 2.0 6 votes vote down vote up
public static void createNode(XMLEventWriter eventWriter, String name, String value) throws XMLStreamException {
	XMLEventFactory eventFactory = XMLEventFactory.newInstance();
	XMLEvent end = eventFactory.createDTD("\n");
	XMLEvent tab = eventFactory.createDTD("\t");

	// Create Start node
	StartElement sElement = eventFactory.createStartElement("", "", name);
	eventWriter.add(tab);
	eventWriter.add(sElement);

	// Create Content
	Characters characters = eventFactory.createCharacters(value);
	eventWriter.add(characters);

	// Create End node
	EndElement eElement = eventFactory.createEndElement("", "", name);
	eventWriter.add(eElement);
	eventWriter.add(end);

}
 
Example 6
Source File: EntityRepository.java    From JavaMainRepo with Apache License 2.0 5 votes vote down vote up
public void save(ArrayList<T> entities) throws FileNotFoundException, XMLStreamException {
	XMLOutputFactory outputFactory = XMLOutputFactory.newFactory();
	// Create XMLEventWriter
	XMLEventWriter eventWriter = outputFactory.createXMLEventWriter(new FileOutputStream(this.xmlFilename));
	// Create an EventFactory
	XMLEventFactory eventFactory = XMLEventFactory.newInstance();
	XMLEvent end = eventFactory.createDTD("\n");
	// Create and write Start Tag
	StartDocument startDocument = eventFactory.createStartDocument();
	eventWriter.add(startDocument);
	// Create content open tag
	StartElement configStartElement = eventFactory.createStartElement("", "", "content");
	eventWriter.add(configStartElement);
	eventWriter.add(end);

	for (XML_Parsable entity : entities) {
		StartElement sElement = eventFactory.createStartElement("", "", this.entityTag);
		eventWriter.add(sElement);
		eventWriter.add(end);

		entity.encodeToXml(eventWriter);

		EndElement eElement = eventFactory.createEndElement("", "", this.entityTag);
		eventWriter.add(eElement);
		eventWriter.add(end);

	}
	eventWriter.add(eventFactory.createEndElement("", "", "content"));
	eventWriter.add(eventFactory.createEndDocument());
	eventWriter.close();
}
 
Example 7
Source File: EntityRepository.java    From JavaMainRepo with Apache License 2.0 5 votes vote down vote up
public void save(ArrayList<T> entities) throws FileNotFoundException, XMLStreamException {

		XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
		// Create XMLEventWriter
		XMLEventWriter eventWriter = outputFactory.createXMLEventWriter(new FileOutputStream(this.xmlFilename));
		// Create a EventFactory
		XMLEventFactory eventFactory = XMLEventFactory.newInstance();
		XMLEvent end = eventFactory.createDTD("\n");
		// Create and write Start Tag
		StartDocument startDocument = eventFactory.createStartDocument();
		eventWriter.add(startDocument);
		// Create content open tag
		StartElement configStartElement = eventFactory.createStartElement("", "", "content");
		eventWriter.add(configStartElement);
		eventWriter.add(end);

		for (XML_Parsable entity : entities) {
			StartElement sElement = eventFactory.createStartElement("", "", this.entityTag);
			eventWriter.add(sElement);
			eventWriter.add(end);

			entity.encodeToXml(eventWriter);

			EndElement eElement = eventFactory.createEndElement("", "", this.entityTag);
			eventWriter.add(eElement);
			eventWriter.add(end);

		}
		eventWriter.add(eventFactory.createEndElement("", "", "content"));
		eventWriter.add(eventFactory.createEndDocument());
		eventWriter.close();
	}
 
Example 8
Source File: EmployeeRepository.java    From JavaMainRepo with Apache License 2.0 5 votes vote down vote up
public void save(ArrayList<Employee> employees) throws FileNotFoundException, XMLStreamException {
	XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
	// Create XMLEventWriter
	XMLEventWriter eventWriter = outputFactory.createXMLEventWriter(new FileOutputStream(XML_FILENAME));
	// Create a EventFactory
	XMLEventFactory eventFactory = XMLEventFactory.newInstance();
	XMLEvent end = eventFactory.createDTD("\n");
	// Create and write Start Tag
	StartDocument startDocument = eventFactory.createStartDocument();
	eventWriter.add(startDocument);
	// Create content open tag
	StartElement configStartElement = eventFactory.createStartElement("", "", "content");
	eventWriter.add(configStartElement);
	eventWriter.add(end);
	for (XML_Parsable employee : employees) {
		StartElement sElement = eventFactory.createStartElement("", "", Constants.XML_TAGS.EMPLOYEE);
		eventWriter.add(sElement);
		eventWriter.add(end);
		employee.encodeToXml(eventWriter);
		EndElement eElement = eventFactory.createEndElement("", "", Constants.XML_TAGS.EMPLOYEE);
		eventWriter.add(eElement);
		eventWriter.add(end);
	}
	eventWriter.add(eventFactory.createEndElement("", "", "content"));
	eventWriter.add(eventFactory.createEndDocument());
	eventWriter.close();
}
 
Example 9
Source File: EntityRepository.java    From JavaMainRepo with Apache License 2.0 5 votes vote down vote up
public void save(ArrayList<T> entities) throws FileNotFoundException, XMLStreamException {

		XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
		XMLEventWriter eventWriter = outputFactory.createXMLEventWriter(new FileOutputStream(this.xmlFilename));
		XMLEventFactory eventFactory = XMLEventFactory.newInstance();
		XMLEvent end = eventFactory.createDTD("\n");
		StartDocument startDocument = eventFactory.createStartDocument();
		eventWriter.add(startDocument);
		StartElement configStartElement = eventFactory.createStartElement("", "", "content");
		eventWriter.add(configStartElement);
		eventWriter.add(end);

		for (XML_Parsable entity : entities) {
			StartElement sElement = eventFactory.createStartElement("", "", this.entityTag);
			eventWriter.add(sElement);
			eventWriter.add(end);

			entity.encodeToXml(eventWriter);

			EndElement eElement = eventFactory.createEndElement("", "", this.entityTag);
			eventWriter.add(eElement);
			eventWriter.add(end);
		}

		eventWriter.add(eventFactory.createEndElement("", "", "content"));
		eventWriter.add(eventFactory.createEndDocument());
		eventWriter.close();
	}
 
Example 10
Source File: EntityRepository.java    From JavaMainRepo with Apache License 2.0 5 votes vote down vote up
public void save(ArrayList<T> entities) throws FileNotFoundException, XMLStreamException {
XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
// Create XMLEventWriter
XMLEventWriter eventWriter = outputFactory.createXMLEventWriter(new FileOutputStream(this.xmlFilename));
// Create a EventFactory
XMLEventFactory eventFactory = XMLEventFactory.newInstance();
XMLEvent end = eventFactory.createDTD("\n");
// Create and write Start Tag
StartDocument startDocument = eventFactory.createStartDocument();
eventWriter.add(startDocument);
// Create content open tag
StartElement configStartElement = eventFactory.createStartElement("", "", "content");
eventWriter.add(configStartElement);
eventWriter.add(end);
for (XML_Parsable animal : entities) {
	StartElement sElement = eventFactory.createStartElement("", "", this.entityTag);
	eventWriter.add(sElement);
	eventWriter.add(end);
	animal.encodeToXml(eventWriter);
	EndElement eElement = eventFactory.createEndElement("", "", this.entityTag);
	eventWriter.add(eElement);
	eventWriter.add(end);
}
eventWriter.add(eventFactory.createEndElement("", "", "content"));
eventWriter.add(eventFactory.createEndDocument());
eventWriter.close();
}
 
Example 11
Source File: EntityRepository.java    From JavaMainRepo with Apache License 2.0 5 votes vote down vote up
public void save(ArrayList<T> entities) throws FileNotFoundException, XMLStreamException {
	XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();

	XMLEventWriter eventWriter = outputFactory.createXMLEventWriter(new FileOutputStream(this.xmlFilename));

	XMLEventFactory eventFactory = XMLEventFactory.newInstance();
	XMLEvent end = eventFactory.createDTD("\n");

	StartDocument startDocument = eventFactory.createStartDocument();
	eventWriter.add(startDocument);

	StartElement configStartElement = eventFactory.createStartElement("", "", "content");
	eventWriter.add(configStartElement);
	eventWriter.add(end);

	for (XML_Parsable entity : entities) {
		StartElement sElement = eventFactory.createStartElement("", "", this.entityTag);
		eventWriter.add(sElement);
		eventWriter.add(end);

		entity.encodeToXml(eventWriter);

		EndElement eElement = eventFactory.createEndElement("", "", this.entityTag);
		eventWriter.add(eElement);
		eventWriter.add(end);
	}

	eventWriter.add(eventFactory.createEndElement("", "", "content"));
	eventWriter.add(eventFactory.createEndDocument());
	eventWriter.close();
}
 
Example 12
Source File: EntityRepository.java    From JavaMainRepo with Apache License 2.0 5 votes vote down vote up
public void save(ArrayList<T> entities) throws FileNotFoundException, XMLStreamException {
	XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
	// Create XMLEventWriter
	XMLEventWriter eventWriter = outputFactory.createXMLEventWriter(new FileOutputStream(this.xmlFilename));
	// Create a EventFactory
	XMLEventFactory eventFactory = XMLEventFactory.newInstance();
	XMLEvent end = eventFactory.createDTD("\n");
	// Create and write Start Tag
	StartDocument startDocument = eventFactory.createStartDocument();
	eventWriter.add(startDocument);
	// Create content open tag
	StartElement configStartElement = eventFactory.createStartElement("", "", "content");
	eventWriter.add(configStartElement);
	eventWriter.add(end);
	for (XML_Parsable animal : entities) {
		StartElement sElement = eventFactory.createStartElement("", "", this.entityTag);
		eventWriter.add(sElement);
		eventWriter.add(end);
		animal.encodeToXml(eventWriter);
		EndElement eElement = eventFactory.createEndElement("", "", this.entityTag);
		eventWriter.add(eElement);
		eventWriter.add(end);
	}
	eventWriter.add(eventFactory.createEndElement("", "", "content"));
	eventWriter.add(eventFactory.createEndDocument());
	eventWriter.close();
}
 
Example 13
Source File: AdWordsModule.java    From googleads-java-lib with Apache License 2.0 4 votes vote down vote up
@Provides
XMLEventFactory provideXMLEventFactory() {
  return XMLEventFactory.newInstance();
}
 
Example 14
Source File: CachingXmlEventWriter.java    From cxf with Apache License 2.0 4 votes vote down vote up
public CachingXmlEventWriter() {
    factory = XMLEventFactory.newInstance();
}
 
Example 15
Source File: SAX2StAXEventWriter.java    From openjdk-8 with GNU General Public License v2.0 3 votes vote down vote up
public SAX2StAXEventWriter(XMLEventWriter writer,
        XMLEventFactory factory) {

    this.writer = writer;
    if (factory != null) {

        this.eventFactory = factory;

    } else {

        eventFactory = XMLEventFactory.newInstance();

    }

}
 
Example 16
Source File: SAX2StAXEventWriter.java    From openjdk-8-source with GNU General Public License v2.0 3 votes vote down vote up
public SAX2StAXEventWriter(XMLEventWriter writer,
        XMLEventFactory factory) {

    this.writer = writer;
    if (factory != null) {

        this.eventFactory = factory;

    } else {

        eventFactory = XMLEventFactory.newInstance();

    }

}
 
Example 17
Source File: SAX2StAXEventWriter.java    From hottub with GNU General Public License v2.0 3 votes vote down vote up
public SAX2StAXEventWriter(XMLEventWriter writer,
        XMLEventFactory factory) {

    this.writer = writer;
    if (factory != null) {

        this.eventFactory = factory;

    } else {

        eventFactory = XMLEventFactory.newInstance();

    }

}
 
Example 18
Source File: SAX2StAXEventWriter.java    From JDKSourceCode1.8 with MIT License 3 votes vote down vote up
public SAX2StAXEventWriter(XMLEventWriter writer,
        XMLEventFactory factory) {

    this.writer = writer;
    if (factory != null) {

        this.eventFactory = factory;

    } else {

        eventFactory = XMLEventFactory.newInstance();

    }

}
 
Example 19
Source File: SAX2StAXEventWriter.java    From openjdk-jdk8u with GNU General Public License v2.0 2 votes vote down vote up
public SAX2StAXEventWriter(XMLEventWriter writer) {

        this.writer = writer;
        eventFactory = XMLEventFactory.newInstance();

    }
 
Example 20
Source File: SAX2StAXEventWriter.java    From Bytecoder with Apache License 2.0 2 votes vote down vote up
public SAX2StAXEventWriter(XMLEventWriter writer) {

        this.writer = writer;
        eventFactory = XMLEventFactory.newInstance();

    }