use of javanet.staxutils.IndentingXMLStreamWriter in project gephi by gephi.
the class ExporterGEXF method execute.
@Override
public boolean execute() {
GraphController graphController = Lookup.getDefault().lookup(GraphController.class);
GraphModel graphModel = graphController.getGraphModel(workspace);
Graph graph = exportVisible ? graphModel.getGraphVisible() : graphModel.getGraph();
Progress.start(progress);
graph.readLock();
//Is it a dynamic graph?
exportDynamic = exportDynamic && graphModel.isDynamic();
//Calculate min & max
calculateMinMax(graph);
Progress.switchToDeterminate(progress, graph.getNodeCount() + graph.getEdgeCount());
try {
XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
outputFactory.setProperty("javax.xml.stream.isRepairingNamespaces", Boolean.FALSE);
XMLStreamWriter xmlWriter = outputFactory.createXMLStreamWriter(writer);
xmlWriter = new IndentingXMLStreamWriter(xmlWriter);
xmlWriter.writeStartDocument("UTF-8", "1.0");
xmlWriter.setPrefix("", GEXF_NAMESPACE);
xmlWriter.writeStartElement(GEXF_NAMESPACE, GEXF);
xmlWriter.writeNamespace("", GEXF_NAMESPACE);
xmlWriter.writeAttribute(GEXF_VERSION, "1.3");
if (exportColors || exportPosition || exportSize) {
xmlWriter.writeNamespace(VIZ, VIZ_NAMESPACE);
}
xmlWriter.writeAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
xmlWriter.writeAttribute("xsi:schemaLocation", GEXF_NAMESPACE_LOCATION);
writeMeta(xmlWriter);
writeGraph(xmlWriter, graph);
xmlWriter.writeEndElement();
xmlWriter.writeEndDocument();
xmlWriter.close();
} catch (Exception e) {
Logger.getLogger(ExporterGEXF.class.getName()).log(Level.SEVERE, null, e);
} finally {
graph.readUnlock();
Progress.finish(progress);
}
return !cancel;
}
use of javanet.staxutils.IndentingXMLStreamWriter in project CFLint by cflint.
the class DefaultCFlintResultMarshaller method output.
@Override
public void output(BugList bugList, Writer writer, boolean showStats) throws MarshallerException {
try {
final XMLOutputFactory xmlOutputFactory = XMLOutputFactory.newInstance();
XMLStreamWriter xtw = new IndentingXMLStreamWriter(xmlOutputFactory.createXMLStreamWriter(writer));
writeIssues(bugList, xtw, showStats);
xtw.flush();
} catch (XMLStreamException e) {
throw new MarshallerException(e);
}
}
Aggregations