• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java IndentingXMLStreamWriter类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中javanet.staxutils.IndentingXMLStreamWriter的典型用法代码示例。如果您正苦于以下问题:Java IndentingXMLStreamWriter类的具体用法?Java IndentingXMLStreamWriter怎么用?Java IndentingXMLStreamWriter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IndentingXMLStreamWriter类属于javanet.staxutils包,在下文中一共展示了IndentingXMLStreamWriter类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: writeToXMLFile

import javanet.staxutils.IndentingXMLStreamWriter; //导入依赖的package包/类
/**
 * Writes the complete database to a file, by using the given XML out put
 * factory 'factory' to create an XMLStreamWriter. The root element of this
 * XML document is given by 'rootElement'
 * 
 * @param file
 * @param rootElement
 * @throws XMLStreamException
 * @throws IOException
 */
public void writeToXMLFile(File file, XMLOutputFactory factory,
		String rootElement) throws XMLStreamException, IOException {
	checkReleased();
	FileWriter fwr = new FileWriter(file);
	XMLStreamWriter writer = factory.createXMLStreamWriter(fwr);

	IndentingXMLStreamWriter indwr = new IndentingXMLStreamWriter(writer); // Ensures
																			// indentation
																			// of
																			// the
																			// XML
																			// document

	indwr.setIndent(" ");
	writer = indwr;

	writer.writeStartDocument("1.0");
	writer.writeStartElement(rootElement);
	writeToXML(writer);
	writer.writeEndElement();
	writer.writeEndDocument();

	fwr.flush();
	fwr.close();
}
 
开发者ID:flyroom,项目名称:PeerfactSimKOM_Clone,代码行数:36,代码来源:RelationalDB.java


示例2: createXmlStreamWriter

import javanet.staxutils.IndentingXMLStreamWriter; //导入依赖的package包/类
private static XMLStreamWriter createXmlStreamWriter(XMLExportOptions options, OutputStream os) throws XMLStreamException {
    XMLStreamWriter writer = XML_OUTPUT_FACTORY_SUPPLIER.get().createXMLStreamWriter(os, StandardCharsets.UTF_8.toString());
    if (options.isIndent()) {
        IndentingXMLStreamWriter indentingWriter = new IndentingXMLStreamWriter(writer);
        indentingWriter.setIndent(INDENT);
        writer = indentingWriter;
    }
    return writer;
}
 
开发者ID:powsybl,项目名称:powsybl-core,代码行数:10,代码来源:NetworkXml.java


示例3: toStream

import javanet.staxutils.IndentingXMLStreamWriter; //导入依赖的package包/类
public static void toStream(OutputStream outStream, NormalizedNode<?, ?> node)
        throws XMLStreamException, IOException {
    XMLStreamWriter xmlWriter = XOF.createXMLStreamWriter(outStream);

    IndentingXMLStreamWriter indenting = new IndentingXMLStreamWriter(xmlWriter);
    try (NormalizedNodeStreamWriter streamWriter = XMLStreamNormalizedNodeStreamWriter.createSchemaless(
            indenting)) {
        NormalizedNodeWriter nodeWriter = NormalizedNodeWriter.forStreamWriter(streamWriter);
        nodeWriter.write(node);
        nodeWriter.flush();
    }
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:13,代码来源:NormalizedNodeXMLOutput.java


示例4: encode

import javanet.staxutils.IndentingXMLStreamWriter; //导入依赖的package包/类
/**
 * Write the encoded {@code t} to the output stream.
 *
 * @param t   the object to encode
 * @param out the output stream (will not be closed)
 *
 * @throws XMLStreamException if the encoding fails
 */
default void encode(T t, OutputStream out)
        throws XMLStreamException {
    XMLOutputFactory factory = XMLOutputFactory.newFactory();
    XMLStreamWriter writer = new IndentingXMLStreamWriter(
            factory.createXMLStreamWriter(out));
    encode(writer, t);
    writer.flush();
}
 
开发者ID:52North,项目名称:imis-iot-eventing-process,代码行数:17,代码来源:StreamEncoder.java


示例5: encodeDocument

import javanet.staxutils.IndentingXMLStreamWriter; //导入依赖的package包/类
/**
 * Write the encoded {@code t} as a document to the output stream.
 *
 * @param t   the object to encode
 * @param out the output stream (will not be closed)
 *
 * @throws XMLStreamException if the encoding fails
 */
default void encodeDocument(T t, OutputStream out)
        throws XMLStreamException {
    XMLOutputFactory factory = XMLOutputFactory.newFactory();
    XMLStreamWriter writer = new IndentingXMLStreamWriter(
            factory.createXMLStreamWriter(out));
    encodeDocument(writer, t);
    writer.flush();
}
 
开发者ID:52North,项目名称:imis-iot-eventing-process,代码行数:17,代码来源:StreamEncoder.java


示例6: getWriter

import javanet.staxutils.IndentingXMLStreamWriter; //导入依赖的package包/类
public static XMLStreamWriter getWriter(OutputStream out, boolean indentWsdl) throws XMLStreamException {
    XMLStreamWriter w = XmlUtils.REPAIR_NAMESPACES_OUTPUT_FACTORY
            .createXMLStreamWriter(out, XmlUtils.STREAM_FACTORY_ENCODING);
    if (indentWsdl) {
        IndentingXMLStreamWriter iw = new IndentingXMLStreamWriter(w);
        iw.setIndent("\t");
        w = iw;
    }
    return w;
}
 
开发者ID:ibissource,项目名称:iaf,代码行数:11,代码来源:WsdlUtils.java


示例7: output

import javanet.staxutils.IndentingXMLStreamWriter; //导入依赖的package包/类
@Override
public void output(final BugList bugList, final Writer writer, final CFLintStats stats) throws MarshallerException {

    try {
        final XMLOutputFactory xmlOutputFactory = XMLOutputFactory.newInstance();
        XMLStreamWriter xtw = new IndentingXMLStreamWriter(xmlOutputFactory.createXMLStreamWriter(writer));

        writeIssues(bugList, xtw, stats);

        xtw.flush();

    } catch (XMLStreamException e) {
        throw new MarshallerException(e);
    }
}
 
开发者ID:cflint,项目名称:CFLint,代码行数:16,代码来源:DefaultCFlintResultMarshaller.java


示例8: process

import javanet.staxutils.IndentingXMLStreamWriter; //导入依赖的package包/类
public void process(Writer writer, List<Class<?>> annotatedList) throws Exception {
    Set<String> puNames = new HashSet<String>();
    XMLOutputFactory xof = XMLOutputFactory.newInstance();
    XMLStreamWriter w = new IndentingXMLStreamWriter(xof.createXMLStreamWriter(writer));
    w.setDefaultNamespace("http://java.sun.com/xml/ns/persistence");
    w.writeStartDocument();
    w.writeStartElement("persistence");
    w.writeAttribute("verson", "2.0");

    // w.println("<persistence version=\"2.0\" xmlns=\"http://java.sun.com/xml/ns/persistence\"
    // xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
    // xsi:schemaLocation=\"http://java.sun.com/xml/ns/persistence
    // http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd\">");
    for (Class<?> annotated : annotatedList) {
        PersistentUnit pu = annotated.getAnnotation(PersistentUnit.class);
        if (pu.name() == null || pu.name().isEmpty()) {
            throw new IOException("Missing persistent unit name");
        }
        if (!puNames.add(pu.name())) {
            throw new IOException("Duplicate persistent unit name: " + pu.name());
        }
        w.writeStartElement("persistence-unit");
        w.writeAttribute("name", pu.name());
        w.writeAttribute("transaction-type", pu.transactionType().toString());
        writeElement(w, "description", pu.description());
        String providerName = getProvider(pu);
        writeElement(w, "provider", providerName);
        writeElement(w, "jta-data-source", pu.jtaDataSource());
        writeElement(w, "non-jta-data-source", pu.nonJtaDataSource());
        Map<String, String> props = new HashMap<>();
        addProperties(pu, props);
        addAnnProperties(annotated, props);
        if (props.size() > 0) {
            w.writeStartElement("properties");
            for (String key : props.keySet()) {
                w.writeEmptyElement("property");
                w.writeAttribute("name", key);
                w.writeAttribute("value", props.get(key));
            }
            w.writeEndElement();
        }
        w.writeEndElement();
    }
    w.writeEndElement();
    w.writeEndDocument();
    w.flush();
    w.close();
}
 
开发者ID:apache,项目名称:karaf-boot,代码行数:49,代码来源:JpaProcessor.java



注:本文中的javanet.staxutils.IndentingXMLStreamWriter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Streams类代码示例发布时间:2022-05-22
下一篇:
Java Encodings类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap