當前位置: 首頁>>代碼示例>>Java>>正文


Java XMLEventFactory.newFactory方法代碼示例

本文整理匯總了Java中javax.xml.stream.XMLEventFactory.newFactory方法的典型用法代碼示例。如果您正苦於以下問題:Java XMLEventFactory.newFactory方法的具體用法?Java XMLEventFactory.newFactory怎麽用?Java XMLEventFactory.newFactory使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.xml.stream.XMLEventFactory的用法示例。


在下文中一共展示了XMLEventFactory.newFactory方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: initialize

import javax.xml.stream.XMLEventFactory; //導入方法依賴的package包/類
@Override
public void initialize(ByteBuf buffer) throws Exception {
    XMLOutputFactory factory = XMLOutputFactory.newInstance();
    this.writer = factory.createXMLEventWriter(new ByteBufOutputStream(buffer));
    this.eventFactory = XMLEventFactory.newFactory();

    startTag("html");
    startTag("head");
    startTag("title");
    text("LiveOak");
    endTag("title");


    startTag("link");
    attribute("rel", "stylesheet");
    attribute("type", "text/css");
    attribute("href", "//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css");
    endTag("link");

    startTag("style");
    text(getCss());
    endTag("style");

    endTag("head");
    startTag("body");
}
 
開發者ID:liveoak-io,項目名稱:liveoak,代碼行數:27,代碼來源:HTMLEncoder.java

示例2: testDefaultInstance

import javax.xml.stream.XMLEventFactory; //導入方法依賴的package包/類
/**
 * 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);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:15,代碼來源:XMLEventFactoryNewInstanceTest.java

示例3: testNewFactory

import javax.xml.stream.XMLEventFactory; //導入方法依賴的package包/類
@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);
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:11,代碼來源:XMLEventFactoryNewInstanceTest.java

示例4: testNewFactory

import javax.xml.stream.XMLEventFactory; //導入方法依賴的package包/類
@Test(dataProvider = "parameters")
public void testNewFactory(String factoryId, ClassLoader classLoader) {
    setSystemProperty(XMLEVENT_FACRORY_ID, XMLEVENT_FACTORY_CLASSNAME);
    try {
        XMLEventFactory xef = XMLEventFactory.newFactory(factoryId, classLoader);
        assertNotNull(xef);
    } finally {
        setSystemProperty(XMLEVENT_FACRORY_ID, null);
    }
}
 
開發者ID:campolake,項目名稱:openjdk9,代碼行數:11,代碼來源:XMLEventFactoryNewInstanceTest.java

示例5: open

import javax.xml.stream.XMLEventFactory; //導入方法依賴的package包/類
@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();
    }
}
 
開發者ID:apache,項目名稱:incubator-batchee,代碼行數:38,代碼來源:StaxItemWriter.java

示例6: run

import javax.xml.stream.XMLEventFactory; //導入方法依賴的package包/類
private void run(
	final XMLEventReader r,
	final XMLEventWriter w
	)
	throws XMLStreamException,JAXBException
{
final XMLEventFactory eventFactory=XMLEventFactory.newFactory();

boolean prev_was_iteration=false;
while(r.hasNext())
	{
	final XMLEvent evt=r.peek();
	QName qname=null;
	if(evt.isStartElement() && (qname=evt.asStartElement().getName()).getLocalPart().equals("Iteration")) 
		{
		final Iteration iteration =  this.unmarshaller.unmarshal(r, Iteration.class).getValue();
		if(!iteration.getIterationHits().getHit().isEmpty()) {
			if(!this.keep_message) iteration.setIterationMessage(null);
			if(!this.keep_stats) iteration.setIterationStat(null);
			this.marshaller.marshal(
					new JAXBElement<Iteration>(qname,Iteration.class , iteration),
					w);
			w.add(eventFactory.createCharacters("\n"));
			}
		prev_was_iteration=true;
		continue;
		}
	else if(prev_was_iteration && evt.isCharacters() && is_empty(evt.asCharacters().getData())) {
		r.nextEvent();
		continue;
		}
		
	w.add(r.nextEvent());
	prev_was_iteration=false;
	}
}
 
開發者ID:lindenb,項目名稱:jvarkit,代碼行數:37,代碼來源:ReduceBlast.java

示例7: testNewFactoryNeg

import javax.xml.stream.XMLEventFactory; //導入方法依賴的package包/類
@Test(expectedExceptions = NullPointerException.class, dataProvider = "new-instance-neg", dataProviderClass = JAXPDataProvider.class)
public void testNewFactoryNeg(String factoryId, ClassLoader classLoader) {
    XMLEventFactory.newFactory(null, null);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:5,代碼來源:XMLEventFactoryNewInstanceTest.java

示例8: get

import javax.xml.stream.XMLEventFactory; //導入方法依賴的package包/類
@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();
}
 
開發者ID:vespa-engine,項目名稱:vespa,代碼行數:7,代碼來源:XMLEventFactoryProvider.java

示例9: initialValue

import javax.xml.stream.XMLEventFactory; //導入方法依賴的package包/類
protected XMLEventFactory initialValue() {
	return XMLEventFactory.newFactory();
}
 
開發者ID:kenweezy,項目名稱:teiid,代碼行數:4,代碼來源:XMLSystemFunctions.java

示例10: getXMLEventFactory

import javax.xml.stream.XMLEventFactory; //導入方法依賴的package包/類
public XMLEventFactory getXMLEventFactory()
{
 if (null == xmlEventFactory)
  xmlEventFactory = XMLEventFactory.newFactory();
 return xmlEventFactory;
}
 
開發者ID:StanLivitski,項目名稱:HTMLtoc,代碼行數:7,代碼來源:TocFormatter.java

示例11: parse

import javax.xml.stream.XMLEventFactory; //導入方法依賴的package包/類
public static ContentModel parse(XMLEventReader xml, String containerName) throws XMLStreamException, IllegalSchemaException {
    final StringWriter schema = new StringWriter();
    final XMLEventFactory xef = XMLEventFactory.newFactory();

    final XMLEventWriter grammar = XML.outputFactory().createXMLEventWriter(new StreamResult(schema));
    try {
        grammar.add(xef.createStartDocument());
        grammar.add(xef.createStartElement("", RELAX_NG, "grammar"));
        grammar.add(xef.createStartElement("", RELAX_NG, "define",
                Collections.singleton(xef.createAttribute("name", CONTENT_MODEL_DEF)).iterator(),
                Collections.emptySet().iterator()));

        while (xml.hasNext()) {
            final XMLEvent event = xml.nextEvent();
            if (event.isEndElement()) {
                if (XML.hasName(event.asEndElement(), Namespaceable.DEFAULT_NS_STR, containerName)) {
                    break;
                }
            }
            grammar.add(event);
        }

        grammar.add(xef.createEndElement("", RELAX_NG, "define"));

        grammar.add(xef.createStartElement("", RELAX_NG, "start"));
        grammar.add(xef.createStartElement("", RELAX_NG, "ref",
                Collections.singleton(xef.createAttribute("name", CONTENT_MODEL_DEF)).iterator(),
                Collections.emptySet().iterator()));
        grammar.add(xef.createEndElement("", RELAX_NG, "ref"));
        grammar.add(xef.createEndElement("", RELAX_NG, "start"));

        grammar.add(xef.createEndElement("", RELAX_NG, "grammar"));
        grammar.add(xef.createEndDocument());
    } finally {
        grammar.close();
    }

    final String grammarStr = schema.toString();
    try {
        final DPattern grammarPattern = (DPattern) new SAXParseable(
                new InputSource(new StringReader(grammarStr)),
                XML.STRICT_ERROR_HANDLER
        ).parse(new DSchemaBuilderImpl());

        final List<DPattern> root = new ArrayList<>();
        grammarPattern.accept(new DPatternWalker() {
            @Override
            public Void onRef(DRefPattern p) {
                final DDefine target = p.getTarget();
                if (target != null && CONTENT_MODEL_DEF.equals(p.getName())) {
                    root.add(target.getPattern());
                }
                return null;
            }
        });

        return new ContentModel(grammarPattern, root.stream().findFirst().orElse(null));
    } catch (BuildException e) {
        throw new UnsupportedOperationException(grammarStr, e);
    }
}
 
開發者ID:interedition,項目名稱:tei-schema,代碼行數:62,代碼來源:ContentModel.java

示例12: createEventStreamWriter

import javax.xml.stream.XMLEventFactory; //導入方法依賴的package包/類
/**
 * 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());
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:9,代碼來源:StaxUtils.java


注:本文中的javax.xml.stream.XMLEventFactory.newFactory方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。