@Override public Iterable<Triple> unmarshallContent(Context context, String content, MediaType type) throws ContentTransformationException { try { RDFContext rdfContext = RDFContext.createContext(context.getBase()); rdfContext.setOption(UnmarshallOptions.TRIPLE_ORDERING, UnmarshallOptions.Ordering.KEEP_TRIPLE_ORDER); return rdfContext.deserialize(content, Format.TURTLE); } catch (IOException e) { throw new ContentTransformationException("Could not unmarshall contents",e); } }
@Override public Iterable<Triple> unmarshallContent(Context context, String content, MediaType type) throws ContentTransformationException { try { RDFContext rdfContext = RDFContext.createContext(context.getBase()); rdfContext.setOption(UnmarshallOptions.TRIPLE_ORDERING, UnmarshallOptions.Ordering.KEEP_TRIPLE_ORDER); return rdfContext.deserialize(content, Format.JSON_LD); } catch (IOException e) { throw new ContentTransformationException("Could not unmarshall contents",e); } }
@Override public Iterable<Triple> unmarshallContent(Context context, String content, MediaType type) throws ContentTransformationException { try { RDFContext rdfContext = RDFContext.createContext(context.getBase()); rdfContext.setOption(UnmarshallOptions.TRIPLE_ORDERING, UnmarshallOptions.Ordering.KEEP_TRIPLE_ORDER); return rdfContext.deserialize(content, Format.RDF_XML); } catch (IOException e) { throw new ContentTransformationException("Could not unmarshall contents",e); } }
private InmutableTripleSet deserialize(String serialization, URI baseURI, Format format) throws IOException { System.out.println( String.format( "Deserializing {\n%s,\n%s,\n%s,\n}", indent("Serialization...: {"+LINE_SEPARATOR+indent(serialization)+LINE_SEPARATOR+"}"), indent("BaseURI...: "+baseURI), indent("Format....: "+format) ) ); InmutableTripleSet result = new InmutableTripleSet(RDFContext.createContext(baseURI).deserialize(serialization, format)); return result; }