Package com.epimorphics.json
Class RDFJSONModWriter
- java.lang.Object
-
- com.epimorphics.json.RDFJSONModWriter
-
public class RDFJSONModWriter extends Object
Support for serializing sets of RDF resources and whole models in JSON.
In lieu of the W3C standard we are mostly following the Talis format. Unfortunately that doesn't cater for lists in a usable fashion and our primary use case is outputting lists of results. So we extend the Talis format with a value type "list" which is rendered in JSON as an array.
- Author:
- Dave Reynolds
-
-
Constructor Summary
Constructors Constructor Description RDFJSONModWriter(OutputStream out)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidfinish()Finish the write.protected booleanisListNode(org.apache.jena.graph.Graph g, org.apache.jena.graph.Node n)protected StringnodeLabel(org.apache.jena.graph.Node node)protected voidstart()voidwrite(org.apache.jena.graph.Graph graph)Write the given graph, not including a resources that have already been visitedvoidwrite(org.apache.jena.rdf.model.Model model)Write the given model, not including a resources that have already been visitedvoidwrite(org.apache.jena.rdf.model.Resource root, org.apache.jena.rdf.model.Resource page, Iterable<org.apache.jena.rdf.model.Resource> items)Write the given ResultPage out with a wrapper object round the graph data showing the root, page and results list.protected voidwriteKeyValue(String key, long value)protected voidwriteKeyValue(String key, String value)protected voidwriteLiteral(org.apache.jena.graph.impl.LiteralLabel literal, boolean isFirst)protected voidwriteNodeValue(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node node, boolean isFirst)voidwriteResource(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node node, boolean recordVisit)Write a single graph nodevoidwriteResource(org.apache.jena.rdf.model.Resource resource)Write a single resource
-
-
-
Field Detail
-
visited
protected Set<org.apache.jena.graph.Node> visited
-
writer
protected org.apache.jena.atlas.json.io.JSWriter writer
-
-
Constructor Detail
-
RDFJSONModWriter
public RDFJSONModWriter(OutputStream out)
-
-
Method Detail
-
start
protected void start()
-
writeResource
public void writeResource(org.apache.jena.rdf.model.Resource resource)
Write a single resource
-
writeResource
public void writeResource(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node node, boolean recordVisit)Write a single graph node- Parameters:
graph- the graph from which to writenode- the specific node to write out properties forrecordVisit- if true then this visit will be record to be blocked from an subsequent full write
-
writeNodeValue
protected void writeNodeValue(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node node, boolean isFirst)
-
writeLiteral
protected void writeLiteral(org.apache.jena.graph.impl.LiteralLabel literal, boolean isFirst)
-
isListNode
protected boolean isListNode(org.apache.jena.graph.Graph g, org.apache.jena.graph.Node n)
-
writeKeyValue
protected void writeKeyValue(String key, long value)
-
nodeLabel
protected String nodeLabel(org.apache.jena.graph.Node node)
-
write
public void write(org.apache.jena.rdf.model.Model model)
Write the given model, not including a resources that have already been visited
-
write
public void write(org.apache.jena.graph.Graph graph)
Write the given graph, not including a resources that have already been visited
-
write
public void write(org.apache.jena.rdf.model.Resource root, org.apache.jena.rdf.model.Resource page, Iterable<org.apache.jena.rdf.model.Resource> items)Write the given ResultPage out with a wrapper object round the graph data showing the root, page and results list.
-
finish
public void finish()
Finish the write. Not called "close" because it doesn't not close the underlying output stream.
-
-