Search in sources :

Example 1 with PrettyPrintHandler

use of it.uniroma1.dis.wsngroup.gexf4j.core.utils.PrettyPrintHandler in project gexf4j by francesco-ficarola.

the class StaxGraphWriter method writeToStream.

@Override
public void writeToStream(Gexf gexf, Writer out, String encoding) throws IOException {
    try {
        XMLOutputFactory xmlOutputFactory = WstxOutputFactory.newInstance();
        XMLStreamWriter streamWriter = xmlOutputFactory.createXMLStreamWriter(out);
        PrettyPrintHandler handler = new PrettyPrintHandler(streamWriter);
        streamWriter = (XMLStreamWriter) Proxy.newProxyInstance(XMLStreamWriter.class.getClassLoader(), new Class[] { XMLStreamWriter.class }, handler);
        streamWriter.writeStartDocument(encoding, "1.0");
        new GexfEntityWriter(streamWriter, gexf);
        streamWriter.writeEndDocument();
        streamWriter.flush();
        streamWriter.close();
    } catch (XMLStreamException e) {
        throw new IOException("XML Exception: " + e.getMessage(), e);
    }
}
Also used : XMLOutputFactory(javax.xml.stream.XMLOutputFactory) PrettyPrintHandler(it.uniroma1.dis.wsngroup.gexf4j.core.utils.PrettyPrintHandler) XMLStreamException(javax.xml.stream.XMLStreamException) GexfEntityWriter(it.uniroma1.dis.wsngroup.gexf4j.core.impl.writer.GexfEntityWriter) XMLStreamWriter(javax.xml.stream.XMLStreamWriter) IOException(java.io.IOException)

Aggregations

GexfEntityWriter (it.uniroma1.dis.wsngroup.gexf4j.core.impl.writer.GexfEntityWriter)1 PrettyPrintHandler (it.uniroma1.dis.wsngroup.gexf4j.core.utils.PrettyPrintHandler)1 IOException (java.io.IOException)1 XMLOutputFactory (javax.xml.stream.XMLOutputFactory)1 XMLStreamException (javax.xml.stream.XMLStreamException)1 XMLStreamWriter (javax.xml.stream.XMLStreamWriter)1