Class Graph

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Iterable<Link>, java.util.Collection<Link>, java.util.Set<Link>

    public class Graph
    extends java.util.concurrent.CopyOnWriteArraySet<Link>
    Graph composed of links. This also called a set of RDF statements or a RDF model.
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private Link defaultLink
      The default link that is used to complete new links.
      private static long serialVersionUID
      The serialization unique identifier.
    • Constructor Summary

      Constructors 
      Constructor Description
      Graph()
      Default constructor.
      Graph​(Link defaultLink)
      Constructor with a default link.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Link add​(java.lang.String sourceRef, java.lang.String typeRef, Reference targetRef)
      Creates then adds a link.
      Link add​(java.lang.String sourceRef, java.lang.String typeRef, Literal targetLit)
      Creates then adds a link.
      Link add​(java.lang.String sourceRef, Reference typeRef, Reference targetRef)
      Creates then adds a link.
      Link add​(java.lang.String sourceRef, Reference typeRef, Literal targetLit)
      Creates then adds a link.
      Link add​(Reference sourceRef, java.lang.String typeRef, Reference targetRef)
      Creates then adds a link.
      Link add​(Reference sourceRef, java.lang.String typeRef, Literal targetLit)
      Creates then adds a link.
      Link add​(Reference sourceRef, Reference typeRef, Reference targetRef)
      Creates then adds a link.
      Link add​(Reference sourceRef, Reference typeRef, Literal targetLit)
      Creates then adds a link.
      Link add​(Graph sourceGraph, Reference typeRef, Reference targetRef)
      Creates then adds a link.
      Link add​(Graph sourceGraph, Reference typeRef, Literal targetLit)
      Creates then adds a link.
      Link addLiteral​(java.lang.String sourceRef, java.lang.String typeRef, java.lang.String targetLit)
      Creates then adds a link.
      Link addLiteral​(Graph sourceGraph, java.lang.String typeRef, java.lang.String targetLit)
      Creates then adds a link.
      Link addReference​(java.lang.String sourceRef, java.lang.String typeRef, java.lang.String targetRef)
      Creates then adds a link.
      Link addReference​(Graph sourceGraph, java.lang.String typeRef, java.lang.String targetRef)
      Creates then adds a link.
      Link getDefaultLink()
      Returns the default link that is used to complete new links.
      Representation getRdfN3Representation()
      Returns a representation in the RDF/n3 format.
      Representation getRdfNTriplesRepresentation()
      Returns a representation in the RDF/N-Triples format.
      Representation getRdfTurtleRepresentation()
      Returns a representation in the RDF/Turtle format.
      Representation getRdfXmlRepresentation()
      Returns a representation in the RDF/XML format.
      private Graph getSourceAsGraph​(Graph sourceGraph)
      Returns the source reference, either the one given in the sourceRef parameter or if it is null, the source reference of the default link.
      private Reference getSourceAsReference​(Reference sourceRef)
      Returns the source reference, either the one given in the sourceRef parameter or if it is null, the source reference of the default link.
      private Literal getTargetAsLiteral​(Literal targetLit)
      Returns the target literal, either the one given in the targetLit parameter or if it is null, the target literal of the default link.
      private Reference getTargetAsReference​(Reference targetRef)
      Returns the target reference, either the one given in the targetRef parameter or if it is null, the target reference of the default link.
      private Reference getTypeRef​(Reference typeRef)
      Returns the type reference, either the one given in the typeRef parameter or if it is null, the type reference of the default link.
      void setDefaultLink​(Link defaultLink)
      Sets the default link that is used to complete new links.
      • Methods inherited from class java.util.concurrent.CopyOnWriteArraySet

        add, addAll, clear, contains, containsAll, equals, forEach, isEmpty, iterator, remove, removeAll, removeIf, retainAll, size, spliterator, toArray, toArray
      • Methods inherited from class java.util.AbstractSet

        hashCode
      • Methods inherited from class java.util.AbstractCollection

        toString
      • Methods inherited from class java.lang.Object

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

        parallelStream, stream, toArray
    • Field Detail

      • serialVersionUID

        private static final long serialVersionUID
        The serialization unique identifier.
        See Also:
        Constant Field Values
      • defaultLink

        private Link defaultLink
        The default link that is used to complete new links.
    • Constructor Detail

      • Graph

        public Graph()
        Default constructor.
      • Graph

        public Graph​(Link defaultLink)
        Constructor with a default link.
        Parameters:
        defaultLink - The link to use when adding links with missing properties.
    • Method Detail

      • add

        public Link add​(Graph sourceGraph,
                        Reference typeRef,
                        Literal targetLit)
        Creates then adds a link. If one of the parameter is null, the value from getDefaultLink() is used instead if possible.
        Parameters:
        sourceGraph - The source graph.
        typeRef - The type reference.
        targetLit - The target literal.
        Returns:
        The created link.
      • add

        public Link add​(Graph sourceGraph,
                        Reference typeRef,
                        Reference targetRef)
        Creates then adds a link. If one of the parameter is null, the value from getDefaultLink() is used instead if possible.
        Parameters:
        sourceGraph - The source graph.
        typeRef - The type reference.
        targetRef - The target reference.
        Returns:
        The created link.
      • add

        public Link add​(Reference sourceRef,
                        Reference typeRef,
                        Literal targetLit)
        Creates then adds a link. If one of the parameter is null, the value from getDefaultLink() is used instead if possible.
        Parameters:
        sourceRef - The source resource reference.
        typeRef - The type reference.
        targetLit - The target literal.
        Returns:
        The created link.
      • add

        public Link add​(Reference sourceRef,
                        Reference typeRef,
                        Reference targetRef)
        Creates then adds a link. If one of the parameter is null, the value from getDefaultLink() is used instead if possible.
        Parameters:
        sourceRef - The source resource reference.
        typeRef - The type reference.
        targetRef - The target resource reference.
        Returns:
        The created link.
      • add

        public Link add​(Reference sourceRef,
                        java.lang.String typeRef,
                        Literal targetLit)
        Creates then adds a link. If one of the parameter is null, the value from getDefaultLink() is used instead if possible.
        Parameters:
        sourceRef - The source resource reference.
        typeRef - The type reference.
        targetLit - The target literal.
        Returns:
        The created link.
      • add

        public Link add​(Reference sourceRef,
                        java.lang.String typeRef,
                        Reference targetRef)
        Creates then adds a link. If one of the parameter is null, the value from getDefaultLink() is used instead if possible.
        Parameters:
        sourceRef - The source resource reference.
        typeRef - The type reference.
        targetRef - The target resource reference.
        Returns:
        The created link.
      • add

        public Link add​(java.lang.String sourceRef,
                        Reference typeRef,
                        Literal targetLit)
        Creates then adds a link. If one of the parameter is null, the value from getDefaultLink() is used instead if possible.
        Parameters:
        sourceRef - The source resource reference.
        typeRef - The type reference.
        targetLit - The target literal.
        Returns:
        The created link.
      • add

        public Link add​(java.lang.String sourceRef,
                        Reference typeRef,
                        Reference targetRef)
        Creates then adds a link. If one of the parameter is null, the value from getDefaultLink() is used instead if possible.
        Parameters:
        sourceRef - The source resource reference.
        typeRef - The type reference.
        targetRef - The target resource reference.
        Returns:
        The created link.
      • add

        public Link add​(java.lang.String sourceRef,
                        java.lang.String typeRef,
                        Literal targetLit)
        Creates then adds a link. If one of the parameter is null, the value from getDefaultLink() is used instead if possible.
        Parameters:
        sourceRef - The source resource reference.
        typeRef - The type reference.
        targetLit - The target literal.
        Returns:
        The created link.
      • add

        public Link add​(java.lang.String sourceRef,
                        java.lang.String typeRef,
                        Reference targetRef)
        Creates then adds a link. If one of the parameter is null, the value from getDefaultLink() is used instead if possible.
        Parameters:
        sourceRef - The source resource reference.
        typeRef - The type reference.
        targetRef - The target resource reference.
        Returns:
        The created link.
      • addLiteral

        public Link addLiteral​(Graph sourceGraph,
                               java.lang.String typeRef,
                               java.lang.String targetLit)
        Creates then adds a link. If one of the parameter is null, the value from getDefaultLink() is used instead if possible.
        Parameters:
        sourceGraph - The source graph.
        typeRef - The type reference.
        targetLit - The target literal.
        Returns:
        The created link.
      • addLiteral

        public Link addLiteral​(java.lang.String sourceRef,
                               java.lang.String typeRef,
                               java.lang.String targetLit)
        Creates then adds a link. If one of the parameter is null, the value from getDefaultLink() is used instead if possible.
        Parameters:
        sourceRef - The source resource reference.
        typeRef - The type reference.
        targetLit - The target literal.
        Returns:
        The created link.
      • addReference

        public Link addReference​(Graph sourceGraph,
                                 java.lang.String typeRef,
                                 java.lang.String targetRef)
        Creates then adds a link. If one of the parameter is null, the value from getDefaultLink() is used instead if possible.
        Parameters:
        sourceGraph - The source graph.
        typeRef - The type reference.
        targetRef - The target reference.
        Returns:
        The created link.
      • addReference

        public Link addReference​(java.lang.String sourceRef,
                                 java.lang.String typeRef,
                                 java.lang.String targetRef)
        Creates then adds a link. If one of the parameter is null, the value from getDefaultLink() is used instead if possible.
        Parameters:
        sourceRef - The source resource reference.
        typeRef - The type reference.
        targetRef - The target resource reference.
        Returns:
        The created link.
      • getDefaultLink

        public Link getDefaultLink()
        Returns the default link that is used to complete new links.
        Returns:
        The default link that is used to complete new links.
      • getRdfN3Representation

        public Representation getRdfN3Representation()
        Returns a representation in the RDF/n3 format.
        Returns:
        A representation in the RDF/n3 format.
      • getRdfNTriplesRepresentation

        public Representation getRdfNTriplesRepresentation()
        Returns a representation in the RDF/N-Triples format.
        Returns:
        A representation in the RDF/N-Triples format.
      • getRdfTurtleRepresentation

        public Representation getRdfTurtleRepresentation()
        Returns a representation in the RDF/Turtle format.
        Returns:
        A representation in the RDF/Turtle format.
      • getRdfXmlRepresentation

        public Representation getRdfXmlRepresentation()
        Returns a representation in the RDF/XML format.
        Returns:
        A representation in the RDF/XML format.
      • getSourceAsGraph

        private Graph getSourceAsGraph​(Graph sourceGraph)
        Returns the source reference, either the one given in the sourceRef parameter or if it is null, the source reference of the default link.
        Parameters:
        sourceRef - The source reference to check.
        Returns:
        The source reference.
      • getSourceAsReference

        private Reference getSourceAsReference​(Reference sourceRef)
        Returns the source reference, either the one given in the sourceRef parameter or if it is null, the source reference of the default link.
        Parameters:
        sourceRef - The source reference to check.
        Returns:
        The source reference.
      • getTargetAsLiteral

        private Literal getTargetAsLiteral​(Literal targetLit)
        Returns the target literal, either the one given in the targetLit parameter or if it is null, the target literal of the default link.
        Parameters:
        targetLit - The target literal to check.
        Returns:
        The target literal.
      • getTargetAsReference

        private Reference getTargetAsReference​(Reference targetRef)
        Returns the target reference, either the one given in the targetRef parameter or if it is null, the target reference of the default link.
        Parameters:
        targetRef - The target reference to check.
        Returns:
        The target reference.
      • getTypeRef

        private Reference getTypeRef​(Reference typeRef)
        Returns the type reference, either the one given in the typeRef parameter or if it is null, the type reference of the default link.
        Parameters:
        typeRef - The type reference to check.
        Returns:
        The type reference.
      • setDefaultLink

        public void setDefaultLink​(Link defaultLink)
        Sets the default link that is used to complete new links.
        Parameters:
        defaultLink - The default link that is used to complete new links.