Class 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 class  RDFDataset.BlankNode  
      static class  RDFDataset.IRI  
      static class  RDFDataset.Literal  
      static class  RDFDataset.Node  
      static class  RDFDataset.Quad  
      • Nested classes/interfaces inherited from class java.util.AbstractMap

        java.util.AbstractMap.SimpleEntry<K extends java.lang.Object,​V extends java.lang.Object>, java.util.AbstractMap.SimpleImmutableEntry<K extends java.lang.Object,​V extends java.lang.Object>
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      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
      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
      void addTriple​(java.lang.String subject, java.lang.String predicate, java.lang.String object)
      Adds a triple to the default graph of this dataset
      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
      void clearNamespaces()
      clears all the namespaces in this dataset
      java.util.Map<java.lang.String,​java.lang.Object> getContext()
      Returns a valid context containing any namespaces set
      java.lang.String getNamespace​(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) 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.
      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.
      void parseContext​(java.lang.Object contextLike)
      parses a context object and sets any namespaces found within it
      void setNamespace​(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
      • Methods inherited from class java.util.AbstractMap

        equals, hashCode, toString
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.Map

        compute, computeIfAbsent, computeIfPresent, containsKey, equals, hashCode, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, size
    • Field Detail

      • PATTERN_INTEGER

        private static final java.util.regex.Pattern PATTERN_INTEGER
      • PATTERN_DOUBLE

        private static final java.util.regex.Pattern PATTERN_DOUBLE
      • context

        private final java.util.Map<java.lang.String,​java.lang.String> context
    • 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 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​(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 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​(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 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)
        graph - the graph to add this triple to
        language - 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 triple
        predicate - the predicate for the triple
        object - 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 triple
        predicate - the predicate for the triple
        object - the object for the triple
        graph - 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 URI
        graph - 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)