se.kmr.scam.rest.util
Class RDFJSON

java.lang.Object
  extended by se.kmr.scam.rest.util.RDFJSON

public class RDFJSON
extends Object

A utility class to help converting Sesame Graphs from and to RDF/JSON.

Author:
Hannes Ebner , Joshua Shinavier, Peter Ansell

Constructor Summary
RDFJSON()
           
 
Method Summary
static String graphToRdfJsonPreordered(Set<org.openrdf.model.Statement> graph)
          Outputs an ordered set of Statements directly to JSON
static Writer graphToRdfJsonPreordered(Set<org.openrdf.model.Statement> graph, Writer writer)
          Outputs an ordered set of Statements directly to JSON NOTE: The statements must be ordered by a comparator that orders null before other values, or the contexts may not be written correctly
static Collection<org.openrdf.model.Statement> rdfJsonToGraph(String json)
          Implementation using the json.org API.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RDFJSON

public RDFJSON()
Method Detail

rdfJsonToGraph

public static Collection<org.openrdf.model.Statement> rdfJsonToGraph(String json)
Implementation using the json.org API.

Parameters:
json - The RDF/JSON string to be parsed and converted into a Collection.
Returns:
A Collection if successful, otherwise null.

graphToRdfJsonPreordered

public static String graphToRdfJsonPreordered(Set<org.openrdf.model.Statement> graph)
Outputs an ordered set of Statements directly to JSON

Parameters:
graph - A Set of Statements that are preordered in the order subject>predicate>object>context so that it can be output directly without any further checks
Returns:
An RDF/JSON string if successful, otherwise null.

graphToRdfJsonPreordered

public static Writer graphToRdfJsonPreordered(Set<org.openrdf.model.Statement> graph,
                                              Writer writer)
Outputs an ordered set of Statements directly to JSON NOTE: The statements must be ordered by a comparator that orders null before other values, or the contexts may not be written correctly

Parameters:
graph - A Set of Statements that are preordered in the order subject>predicate>object>context so that it can be output directly without any further checks
writer - The output writer to use
Returns:
An RDF/JSON string if successful, otherwise null.


Copyright © 2013. All Rights Reserved.