Class RDFDataset

All Implemented Interfaces:
Serializable, Cloneable, Map<String,Object>, SequencedMap<String,Object>

public class RDFDataset extends LinkedHashMap<String,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:
  • Field Details

  • Constructor Details

    • RDFDataset

      public RDFDataset()
    • RDFDataset

      public RDFDataset(JsonLdApi jsonLdApi)
  • Method Details

    • setNamespace

      public void setNamespace(String ns, String prefix)
    • getNamespace

      public String getNamespace(String ns)
    • clearNamespaces

      public void clearNamespaces()
      clears all the namespaces in this dataset
    • getNamespaces

      public Map<String,String> getNamespaces()
    • getContext

      public Map<String,Object> getContext()
      Returns a valid context containing any namespaces set
      Returns:
      The context map
    • parseContext

      public void parseContext(Object contextLike) throws JsonLdError
      parses 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(String subject, String predicate, String value, String datatype, String language)
      Adds a triple to the @default graph of this dataset
      Parameters:
      subject - the subject for the triple
      predicate - the predicate for the triple
      value - the value of the literal object for the triple
      datatype - 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(String s, String p, String value, String datatype, String language, String graph)
      Adds a triple to the specified graph of this dataset
      Parameters:
      s - the subject for the triple
      p - the predicate for the triple
      value - the value of the literal object for the triple
      datatype - 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)
      graph - the graph to add this triple to
    • addTriple

      public void addTriple(String subject, String predicate, String object)
      Adds a triple to the default graph of this dataset
      Parameters:
      subject - the subject for the triple
      predicate - the predicate for the triple
      object - the object for the triple
    • addQuad

      public void addQuad(String subject, String predicate, String object, String graph)
      Adds a triple to the specified graph of this dataset
      Parameters:
      subject - the subject for the triple
      predicate - the predicate for the triple
      object - the object for the triple
      graph - the graph to add this triple to
    • graphToRDF

      void graphToRDF(String graphName, Map<String,Object> graph)
      Creates an array of RDF triples for the given graph.
      Parameters:
      graphName - The graph URI
      graph - the graph to create RDF triples for.
    • objectToRDF

      private RDFDataset.Node objectToRDF(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 Set<String> graphNames()
    • getQuads

      public List<RDFDataset.Quad> getQuads(String graphName)