Java Code Examples for javax.xml.stream.XMLEventFactory#newFactory()
The following examples show how to use
javax.xml.stream.XMLEventFactory#newFactory() .
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: XMLEventFactoryNewInstanceTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Test if newDefaultFactory() method returns an instance * of the expected factory. * @throws Exception If any errors occur. */ @Test public void testDefaultInstance() throws Exception { XMLEventFactory ef1 = XMLEventFactory.newDefaultFactory(); XMLEventFactory ef2 = XMLEventFactory.newFactory(); assertNotSame(ef1, ef2, "same instance returned:"); assertSame(ef1.getClass(), ef2.getClass(), "unexpected class mismatch for newDefaultFactory():"); assertEquals(ef1.getClass().getName(), DEFAULT_IMPL_CLASS); }
Example 2
Source File: XMLEventFactoryNewInstanceTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider = "parameters") public void testNewFactory(String factoryId, ClassLoader classLoader) { setSystemProperty(XMLEVENT_FACTORY_ID, XMLEVENT_FACTORY_CLASSNAME); try { XMLEventFactory xef = XMLEventFactory.newFactory(factoryId, classLoader); assertNotNull(xef); } finally { clearSystemProperty(XMLEVENT_FACTORY_ID); } }
Example 3
Source File: StaxItemWriter.java From incubator-batchee with Apache License 2.0 | 5 votes |
@Override public void open(final Serializable checkpoint) throws Exception { if (output == null) { throw new BatchRuntimeException("output should be set"); } if (marshallingPackage == null && marshallingClasses == null) { throw new BatchRuntimeException("marshallingPackage should be set"); } if (encoding == null) { encoding = "UTF-8"; } if (rootTag == null) { rootTag = "root"; } if (version == null) { version = "1.0"; } marshaller = JAXBContextFactory.getJaxbContext(marshallingPackage, marshallingClasses).createMarshaller(); final File file = new File(output); if (!file.getParentFile().exists() && !file.getParentFile().mkdirs()) { throw new BatchRuntimeException("Output parent file can't be created"); } final XMLOutputFactory xmlOutputFactory = XMLOutputFactory.newInstance(); woodStoxConfig(xmlOutputFactory); xmlEventFactory = XMLEventFactory.newFactory(); txWriter = new TransactionalWriter(file, encoding, checkpoint); writer = xmlOutputFactory.createXMLEventWriter(txWriter); if (txWriter.position() == 0) { writer.add(xmlEventFactory.createStartDocument(encoding, version)); writer.add(xmlEventFactory.createStartElement("", "", rootTag)); writer.flush(); } }
Example 4
Source File: StaxHelper.java From lams with GNU General Public License v2.0 | 4 votes |
/** * Creates a new StAX XMLEventFactory, with sensible defaults */ public static XMLEventFactory newXMLEventFactory() { return XMLEventFactory.newFactory(); }
Example 5
Source File: XmlFactories.java From arctic-sea with Apache License 2.0 | 4 votes |
private XMLEventFactory createEventFactory() { XMLEventFactory factory = XMLEventFactory.newFactory(); return factory; }
Example 6
Source File: XMLEventFactoryNewInstanceTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
@Test(expectedExceptions = NullPointerException.class, dataProvider = "new-instance-neg", dataProviderClass = JAXPDataProvider.class) public void testNewFactoryNeg(String factoryId, ClassLoader classLoader) { XMLEventFactory.newFactory(null, null); }
Example 7
Source File: XMLEventFactoryProvider.java From vespa with Apache License 2.0 | 4 votes |
@Override public XMLEventFactory get() { System.setProperty("javax.xml.stream.XMLEventFactory", FACTORY_CLASS); // NOTE: In case the newFactory(String, ClassLoader) is used, XMLEventFactory treats the string as classname. return XMLEventFactory.newFactory(); }
Example 8
Source File: StaxUtils.java From spring-analysis-note with MIT License | 2 votes |
/** * Return a {@link XMLStreamWriter} that writes to a {@link XMLEventWriter}. * @return a stream writer that writes to an event writer * @since 3.2 */ public static XMLStreamWriter createEventStreamWriter(XMLEventWriter eventWriter) { return new XMLEventStreamWriter(eventWriter, XMLEventFactory.newFactory()); }
Example 9
Source File: StaxUtils.java From java-technology-stack with MIT License | 2 votes |
/** * Return a {@link XMLStreamWriter} that writes to a {@link XMLEventWriter}. * @return a stream writer that writes to an event writer * @since 3.2 */ public static XMLStreamWriter createEventStreamWriter(XMLEventWriter eventWriter) { return new XMLEventStreamWriter(eventWriter, XMLEventFactory.newFactory()); }
Example 10
Source File: StaxUtils.java From lams with GNU General Public License v2.0 | 2 votes |
/** * Return a {@link XMLStreamWriter} that writes to a {@link XMLEventWriter}. * @return a stream writer that writes to an event writer * @since 3.2 */ public static XMLStreamWriter createEventStreamWriter(XMLEventWriter eventWriter) { return new XMLEventStreamWriter(eventWriter, XMLEventFactory.newFactory()); }
Example 11
Source File: StaxUtils.java From spring4-understanding with Apache License 2.0 | 2 votes |
/** * Return a {@link XMLStreamWriter} that writes to a {@link XMLEventWriter}. * @return a stream writer that writes to an event writer * @since 3.2 */ public static XMLStreamWriter createEventStreamWriter(XMLEventWriter eventWriter) { return new XMLEventStreamWriter(eventWriter, XMLEventFactory.newFactory()); }