Skip to content
Snippets Groups Projects
Commit 1f23824a authored by Sören Henning's avatar Sören Henning
Browse files

added simple JAXB marshaling test

parent 942249fe
No related branches found
No related tags found
1 merge request!17Get impletemented stages and Java 8
package kieker.analysis.graph;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import org.graphdrawing.graphml.EdgeType;
import org.graphdrawing.graphml.GraphType;
import org.graphdrawing.graphml.GraphmlType;
import org.graphdrawing.graphml.KeyType;
import org.graphdrawing.graphml.NodeType;
import org.graphdrawing.graphml.ObjectFactory;
import kieker.analysis.graph.impl.GraphImpl;
public class GraphTester {
......@@ -73,23 +85,27 @@ public class GraphTester {
System.out.println(edge.getId());
}
// GraphmlType graphmlType = new GraphmlType();
// graphmlType.getKey().add(new KeyType());
// graphmlType.getGraphOrData().add(new GraphType());
// ERROR als Element ist nicht möglich, weil eine @XmlRootElement-Annotation fehlt
/*
* try {
* JAXBContext context = JAXBContext.newInstance(GraphmlType.class);
* Marshaller m = context.createMarshaller();
* m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
* m.marshal(graphmlType, System.out);
* } catch (JAXBException e) {
* // TODO Auto-generated catch block
* e.printStackTrace();
* }
*/
GraphmlType graphmlType = new GraphmlType();
graphmlType.getKey().add(new KeyType());
GraphType graphType = new GraphType();
graphType.getDataOrNodeOrEdge().add(new NodeType());
graphType.getDataOrNodeOrEdge().add(new NodeType());
graphType.getDataOrNodeOrEdge().add(new EdgeType());
graphmlType.getGraphOrData().add(graphType);
try {
JAXBContext context = JAXBContext.newInstance(GraphmlType.class);
Marshaller m = context.createMarshaller();
m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
ObjectFactory objectFactory = new ObjectFactory();
JAXBElement<GraphmlType> element = objectFactory.createGraphml(graphmlType);
m.marshal(element, System.out);
} catch (JAXBException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// Use object factory
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment