Search in sources :

Example 1 with IndentingXMLStreamWriter

use of com.sun.xml.txw2.output.IndentingXMLStreamWriter in project jqa-core-framework by buschmais.

the class RuleSetWriterImpl method marshal.

private void marshal(Writer writer, JqassistantRules rules) {
    XMLOutputFactory xof = XMLOutputFactory.newInstance();
    XMLStreamWriter streamWriter = null;
    try {
        streamWriter = xof.createXMLStreamWriter(writer);
    } catch (XMLStreamException e) {
        e.printStackTrace();
    }
    XMLStreamWriter indentingStreamWriter = new IndentingXMLStreamWriter(new CDataXMLStreamWriter(streamWriter));
    try {
        Marshaller marshaller = jaxbContext.createMarshaller();
        marshaller.setProperty(Marshaller.JAXB_ENCODING, "UTF-8");
        marshaller.marshal(rules, indentingStreamWriter);
    } catch (JAXBException e) {
        throw new IllegalArgumentException("Cannot write rules to " + writer, e);
    }
}
Also used : IndentingXMLStreamWriter(com.sun.xml.txw2.output.IndentingXMLStreamWriter) XMLOutputFactory(javax.xml.stream.XMLOutputFactory) Marshaller(javax.xml.bind.Marshaller) CDataXMLStreamWriter(com.buschmais.jqassistant.core.rule.impl.reader.CDataXMLStreamWriter) XMLStreamException(javax.xml.stream.XMLStreamException) IndentingXMLStreamWriter(com.sun.xml.txw2.output.IndentingXMLStreamWriter) CDataXMLStreamWriter(com.buschmais.jqassistant.core.rule.impl.reader.CDataXMLStreamWriter) XMLStreamWriter(javax.xml.stream.XMLStreamWriter) JAXBException(javax.xml.bind.JAXBException)

Aggregations

CDataXMLStreamWriter (com.buschmais.jqassistant.core.rule.impl.reader.CDataXMLStreamWriter)1 IndentingXMLStreamWriter (com.sun.xml.txw2.output.IndentingXMLStreamWriter)1 JAXBException (javax.xml.bind.JAXBException)1 Marshaller (javax.xml.bind.Marshaller)1 XMLOutputFactory (javax.xml.stream.XMLOutputFactory)1 XMLStreamException (javax.xml.stream.XMLStreamException)1 XMLStreamWriter (javax.xml.stream.XMLStreamWriter)1