本文整理汇总了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;未经允许,请勿转载。 |
请发表评论