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.
| Modifier and Type | Field and Description |
|---|---|
protected Set<org.apache.jena.graph.Node> |
visited |
protected org.apache.jena.atlas.json.io.JSWriter |
writer |
| Constructor and Description |
|---|
RDFJSONModWriter(OutputStream out) |
| Modifier and Type | Method and Description |
|---|---|
void |
finish()
Finish the write.
|
protected boolean |
isListNode(org.apache.jena.graph.Graph g,
org.apache.jena.graph.Node n) |
protected String |
nodeLabel(org.apache.jena.graph.Node node) |
protected void |
start() |
void |
write(org.apache.jena.graph.Graph graph)
Write the given graph, not including a resources that have already been visited
|
void |
write(org.apache.jena.rdf.model.Model model)
Write the given model, not including a resources that have already been visited
|
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.
|
protected void |
writeKeyValue(String key,
long value) |
protected void |
writeKeyValue(String key,
String value) |
protected void |
writeLiteral(org.apache.jena.graph.impl.LiteralLabel literal,
boolean isFirst) |
protected void |
writeNodeValue(org.apache.jena.graph.Graph graph,
org.apache.jena.graph.Node node,
boolean isFirst) |
void |
writeResource(org.apache.jena.graph.Graph graph,
org.apache.jena.graph.Node node,
boolean recordVisit)
Write a single graph node
|
void |
writeResource(org.apache.jena.rdf.model.Resource resource)
Write a single resource
|
protected Set<org.apache.jena.graph.Node> visited
protected org.apache.jena.atlas.json.io.JSWriter writer
public RDFJSONModWriter(OutputStream out)
protected void start()
public void writeResource(org.apache.jena.rdf.model.Resource resource)
public void writeResource(org.apache.jena.graph.Graph graph,
org.apache.jena.graph.Node node,
boolean recordVisit)
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 writeprotected void writeNodeValue(org.apache.jena.graph.Graph graph,
org.apache.jena.graph.Node node,
boolean isFirst)
protected void writeLiteral(org.apache.jena.graph.impl.LiteralLabel literal,
boolean isFirst)
protected boolean isListNode(org.apache.jena.graph.Graph g,
org.apache.jena.graph.Node n)
protected void writeKeyValue(String key, long value)
protected String nodeLabel(org.apache.jena.graph.Node node)
public void write(org.apache.jena.rdf.model.Model model)
public void write(org.apache.jena.graph.Graph graph)
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)
public void finish()
Copyright © 2019. All rights reserved.