Search in sources :

Example 1 with FormattingXmlStreamWriter

use of org.jboss.galleon.xml.util.FormattingXmlStreamWriter in project galleon by wildfly.

the class BaseXmlWriter method write.

public void write(T t, Writer stream) throws XMLStreamException, IOException {
    final ElementNode root = toElement(t);
    try (FormattingXmlStreamWriter writer = new FormattingXmlStreamWriter(XMLOutputFactory.newInstance().createXMLStreamWriter(stream))) {
        writer.writeStartDocument();
        root.marshall(writer);
        writer.writeEndDocument();
    }
}
Also used : FormattingXmlStreamWriter(org.jboss.galleon.xml.util.FormattingXmlStreamWriter) ElementNode(org.jboss.galleon.xml.util.ElementNode)

Example 2 with FormattingXmlStreamWriter

use of org.jboss.galleon.xml.util.FormattingXmlStreamWriter in project galleon by wildfly.

the class Configuration method needRewrite.

public void needRewrite() throws XMLStreamException, IOException {
    Path configFile = getConfigFile();
    Files.deleteIfExists(configFile);
    try (BufferedWriter bw = Files.newBufferedWriter(configFile, StandardOpenOption.CREATE, StandardOpenOption.WRITE)) {
        try (FormattingXmlStreamWriter writer = new FormattingXmlStreamWriter(XMLOutputFactory.newInstance().createXMLStreamWriter(bw))) {
            writer.writeStartDocument();
            writer.writeStartElement(ConfigXmlParser10.ROOT_1_0.getLocalPart());
            writer.writeDefaultNamespace(ConfigXmlParser10.NAMESPACE_1_0);
            maven.write(writer);
            writer.writeEndElement();
            writer.writeEndDocument();
        }
    }
}
Also used : Path(java.nio.file.Path) FormattingXmlStreamWriter(org.jboss.galleon.xml.util.FormattingXmlStreamWriter) BufferedWriter(java.io.BufferedWriter)

Aggregations

FormattingXmlStreamWriter (org.jboss.galleon.xml.util.FormattingXmlStreamWriter)2 BufferedWriter (java.io.BufferedWriter)1 Path (java.nio.file.Path)1 ElementNode (org.jboss.galleon.xml.util.ElementNode)1