Commit 49780b49 authored by Alessio Carenini's avatar Alessio Carenini
Browse files

Added method to create a Choreography instance from an XML string

parent 36c16e6f
......@@ -3,6 +3,7 @@ package eu.chorevolution.datamodel;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.StringReader;
import java.io.StringWriter;
import java.io.Writer;
import java.util.ArrayList;
......@@ -12,6 +13,7 @@ import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.bind.SchemaOutputResolver;
import javax.xml.bind.Unmarshaller;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.transform.OutputKeys;
......@@ -87,6 +89,14 @@ public class Choreography {
return marshaller;
}
public static Choreography create_new(String xml) throws JAXBException{
JAXBContext context = JAXBContext.newInstance(Choreography.class);
Unmarshaller unmarshaller = context.createUnmarshaller();
Choreography c = (Choreography) unmarshaller.unmarshal(new StringReader(xml));
return c;
}
// based on
// http://arthur.gonigberg.com/2010/04/26/jaxb-generating-schema-from-object-model/
// and
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment