Package com.github.jsonldjava.core
Class RDFDataset
- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- java.util.HashMap<K,V>
-
- java.util.LinkedHashMap<java.lang.String,java.lang.Object>
-
- com.github.jsonldjava.core.RDFDataset
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,java.util.Map<java.lang.String,java.lang.Object>
public class RDFDataset extends java.util.LinkedHashMap<java.lang.String,java.lang.Object>Starting to migrate away from using plain java Maps as the internal RDF dataset store. Currently each item just wraps a Map based on the old format so everything doesn't break. Will phase this out once everything is using the new format.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classRDFDataset.BlankNodestatic classRDFDataset.IRIstatic classRDFDataset.Literalstatic classRDFDataset.Nodestatic classRDFDataset.Quad
-
Field Summary
Fields Modifier and Type Field Description private JsonLdApiapiprivate java.util.Map<java.lang.String,java.lang.String>contextprivate static RDFDataset.Nodefirstprivate static RDFDataset.Nodenilprivate static java.util.regex.PatternPATTERN_DOUBLEprivate static java.util.regex.PatternPATTERN_INTEGERprivate static RDFDataset.Noderestprivate static longserialVersionUID
-
Constructor Summary
Constructors Constructor Description RDFDataset()RDFDataset(JsonLdApi jsonLdApi)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddQuad(java.lang.String subject, java.lang.String predicate, java.lang.String object, java.lang.String graph)Adds a triple to the specified graph of this datasetvoidaddQuad(java.lang.String s, java.lang.String p, java.lang.String value, java.lang.String datatype, java.lang.String language, java.lang.String graph)Adds a triple to the specified graph of this datasetvoidaddTriple(java.lang.String subject, java.lang.String predicate, java.lang.String object)Adds a triple to the default graph of this datasetvoidaddTriple(java.lang.String subject, java.lang.String predicate, java.lang.String value, java.lang.String datatype, java.lang.String language)Adds a triple to the @default graph of this datasetvoidclearNamespaces()clears all the namespaces in this datasetjava.util.Map<java.lang.String,java.lang.Object>getContext()Returns a valid context containing any namespaces setjava.lang.StringgetNamespace(java.lang.String ns)java.util.Map<java.lang.String,java.lang.String>getNamespaces()java.util.List<RDFDataset.Quad>getQuads(java.lang.String graphName)java.util.Set<java.lang.String>graphNames()(package private) voidgraphToRDF(java.lang.String graphName, java.util.Map<java.lang.String,java.lang.Object> graph)Creates an array of RDF triples for the given graph.private RDFDataset.NodeobjectToRDF(java.lang.Object item)Converts a JSON-LD value object to an RDF literal or a JSON-LD string or node object to an RDF resource.voidparseContext(java.lang.Object contextLike)parses a context object and sets any namespaces found within itvoidsetNamespace(java.lang.String ns, java.lang.String prefix)-
Methods inherited from class java.util.LinkedHashMap
clear, containsValue, entrySet, forEach, get, getOrDefault, keySet, removeEldestEntry, replaceAll, values
-
Methods inherited from class java.util.HashMap
clone, compute, computeIfAbsent, computeIfPresent, containsKey, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, size
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
PATTERN_INTEGER
private static final java.util.regex.Pattern PATTERN_INTEGER
-
PATTERN_DOUBLE
private static final java.util.regex.Pattern PATTERN_DOUBLE
-
first
private static final RDFDataset.Node first
-
rest
private static final RDFDataset.Node rest
-
nil
private static final RDFDataset.Node nil
-
context
private final java.util.Map<java.lang.String,java.lang.String> context
-
api
private JsonLdApi api
-
-
Constructor Detail
-
RDFDataset
public RDFDataset()
-
RDFDataset
public RDFDataset(JsonLdApi jsonLdApi)
-
-
Method Detail
-
setNamespace
public void setNamespace(java.lang.String ns, java.lang.String prefix)
-
getNamespace
public java.lang.String getNamespace(java.lang.String ns)
-
clearNamespaces
public void clearNamespaces()
clears all the namespaces in this dataset
-
getNamespaces
public java.util.Map<java.lang.String,java.lang.String> getNamespaces()
-
getContext
public java.util.Map<java.lang.String,java.lang.Object> getContext()
Returns a valid context containing any namespaces set- Returns:
- The context map
-
parseContext
public void parseContext(java.lang.Object contextLike) throws JsonLdErrorparses a context object and sets any namespaces found within it- Parameters:
contextLike- The context to parse- Throws:
JsonLdError- If the context can't be parsed
-
addTriple
public void addTriple(java.lang.String subject, java.lang.String predicate, java.lang.String value, java.lang.String datatype, java.lang.String language)Adds a triple to the @default graph of this dataset- Parameters:
subject- the subject for the triplepredicate- the predicate for the triplevalue- the value of the literal object for the tripledatatype- the datatype of the literal object for the triple (null values will default to xsd:string)language- the language of the literal object for the triple (or null)
-
addQuad
public void addQuad(java.lang.String s, java.lang.String p, java.lang.String value, java.lang.String datatype, java.lang.String language, java.lang.String graph)Adds a triple to the specified graph of this dataset- Parameters:
s- the subject for the triplep- the predicate for the triplevalue- the value of the literal object for the tripledatatype- the datatype of the literal object for the triple (null values will default to xsd:string)graph- the graph to add this triple tolanguage- the language of the literal object for the triple (or null)
-
addTriple
public void addTriple(java.lang.String subject, java.lang.String predicate, java.lang.String object)Adds a triple to the default graph of this dataset- Parameters:
subject- the subject for the triplepredicate- the predicate for the tripleobject- the object for the triple
-
addQuad
public void addQuad(java.lang.String subject, java.lang.String predicate, java.lang.String object, java.lang.String graph)Adds a triple to the specified graph of this dataset- Parameters:
subject- the subject for the triplepredicate- the predicate for the tripleobject- the object for the triplegraph- the graph to add this triple to
-
graphToRDF
void graphToRDF(java.lang.String graphName, java.util.Map<java.lang.String,java.lang.Object> graph)Creates an array of RDF triples for the given graph.- Parameters:
graphName- The graph URIgraph- the graph to create RDF triples for.
-
objectToRDF
private RDFDataset.Node objectToRDF(java.lang.Object item)
Converts a JSON-LD value object to an RDF literal or a JSON-LD string or node object to an RDF resource.- Parameters:
item- the JSON-LD value or node object.- Returns:
- the RDF literal or RDF resource.
-
graphNames
public java.util.Set<java.lang.String> graphNames()
-
getQuads
public java.util.List<RDFDataset.Quad> getQuads(java.lang.String graphName)
-
-