Class Link


  • public class Link
    extends java.lang.Object
    Link between a source resource and a target resource or literal. This exactly maps with the concepts of statement, triple or relationship defined by RDF, the core specification of the Semantic Web. A link is composed of a source node (or subject in RDF terminology), a type URI reference (or predicate in RDF terminology) and a target node (or object in RDF terminology). We use this class in Restlet to enhance resources and make them part of the Web of data (also know as Linked Data and Hyperdata).
    See Also:
    RDF concepts
    • Field Detail

      • source

        private volatile java.lang.Object source
        The source object.
      • target

        private volatile java.lang.Object target
        The target object.
      • typeRef

        private volatile Reference typeRef
        The type URI reference.
    • Constructor Detail

      • Link

        public Link​(Graph sourceGraph,
                    Reference typeRef,
                    Literal targetLit)
        Constructor. Leverages n3 reification feature where a graph itself can be the source node of a link.
        Parameters:
        sourceGraph - The source graph or subject in RDF terminology.
        typeRef - The type reference or predicate in RDF terminology.
        targetLit - The target literal or object in RDF terminology.
      • Link

        public Link​(Graph sourceGraph,
                    Reference typeRef,
                    java.lang.Object target)
        Constructor. Leverages n3 reification feature where a graph itself can be the source node of a link.
        Parameters:
        sourceGraph - The source graph or subject in RDF terminology.
        typeRef - The type reference or predicate in RDF terminology.
        target - The target node or object in RDF terminology.
      • Link

        public Link​(Graph sourceGraph,
                    Reference typeRef,
                    Reference targetRef)
        Constructor. Leverages n3 reification feature where a graph itself can be the source node of a link.
        Parameters:
        sourceGraph - The source graph or subject in RDF terminology.
        typeRef - The type reference or predicate in RDF terminology.
        targetRef - The target reference or object in RDF terminology.
      • Link

        public Link​(Graph sourceGraph,
                    java.lang.String typeRef,
                    Literal targetLit)
        Constructor. Leverages n3 reification feature where a graph itself can be the source node of a link.
        Parameters:
        sourceGraph - The source graph or subject in RDF terminology.
        typeRef - The type reference or predicate in RDF terminology.
        targetLit - The target literal or object in RDF terminology.
      • Link

        public Link​(Graph sourceGraph,
                    java.lang.String typeRef,
                    java.lang.Object target)
        Constructor. Leverages n3 reification feature where a graph itself can be the source node of a link.
        Parameters:
        sourceGraph - The source graph or subject in RDF terminology.
        typeRef - The type reference or predicate in RDF terminology.
        target - The target node or object in RDF terminology.
      • Link

        public Link​(Graph sourceGraph,
                    java.lang.String typeRef,
                    Reference targetRef)
        Constructor. Leverages n3 reification feature where a graph itself can be the source node of a link.
        Parameters:
        sourceGraph - The source graph or subject in RDF terminology.
        typeRef - The type reference or predicate in RDF terminology.
        targetRef - The target reference or object in RDF terminology.
      • Link

        public Link​(Link from)
        Constructor by copy.
        Parameters:
        from - The link to copy from.
      • Link

        private Link​(java.lang.Object source,
                     Reference typeRef,
                     java.lang.Object target)
        Constructor.
        Parameters:
        source - The source node or subject in RDF terminology.
        typeRef - The type reference or predicate in RDF terminology.
        target - The target node or object in RDF terminology.
      • Link

        public Link​(Reference sourceRef,
                    Reference typeRef,
                    Literal targetLit)
        Constructor.
        Parameters:
        sourceRef - The source resource reference or subject in RDF terminology.
        typeRef - The type reference or predicate in RDF terminology.
        targetLit - The target literal node or object in RDF terminology.
      • Link

        public Link​(Reference sourceRef,
                    Reference typeRef,
                    Reference targetRef)
        Constructor.
        Parameters:
        sourceRef - The source resource reference or subject in RDF terminology.
        typeRef - The type reference or predicate in RDF terminology.
        targetRef - The target resource reference or object in RDF terminology.
      • Link

        public Link​(Reference sourceRef,
                    java.lang.String typeRef,
                    Literal targetLit)
        Constructor.
        Parameters:
        sourceRef - The source resource reference or subject in RDF terminology.
        typeRef - The type reference or predicate in RDF terminology.
        targetLit - The target literal node or object in RDF terminology.
      • Link

        public Link​(Reference sourceRef,
                    java.lang.String typeRef,
                    Reference targetRef)
        Constructor.
        Parameters:
        sourceRef - The source resource reference or subject in RDF terminology.
        typeRef - The type reference or predicate in RDF terminology.
        targetRef - The target resource reference or object in RDF terminology.
    • Method Detail

      • createBlankRef

        public static Reference createBlankRef​(java.lang.String identifier)
        Creates a reference to a blank node. In this API, we support RDF blank nodes using the "_" namespace and local identifiers, in a way similar to the RDF n3 serialization format.
        Parameters:
        identifier - The blank node identifier.
        Returns:
        A reference to a blank node.
      • isBlankRef

        public static boolean isBlankRef​(Reference reference)
        Indicates if a reference is identifying a blank node.
        Parameters:
        reference - The reference to test.
        Returns:
        True if a reference is identifying a blank node.
        See Also:
        createBlankRef(String)
      • getSource

        public java.lang.Object getSource()
        Returns the source which can be either a reference or a link or a graph or null. This maps with the concept of subject in RDF terminology.
        Returns:
        The source.
      • getSourceAsGraph

        public Graph getSourceAsGraph()
        Returns the source graph. Supports RDF reification or N3 formulae.
        Returns:
        The source graph.
        See Also:
        getSource()
      • getSourceAsLink

        public Link getSourceAsLink()
        Returns the source link. Supports RDF reification.
        Returns:
        The source link.
        See Also:
        getSource()
      • getSourceAsReference

        public Reference getSourceAsReference()
        Returns the source resource reference.
        Returns:
        The source resource reference.
        See Also:
        getSource()
      • getTarget

        public java.lang.Object getTarget()
        Returns the target which can be either a literal or a reference or is null. This maps with the concept of object in RDF terminology.
        Returns:
        The target.
      • getTargetAsGraph

        public Graph getTargetAsGraph()
        Returns the target graph.
        Returns:
        The target graph.
        See Also:
        getTarget()
      • getTargetAsLink

        public Link getTargetAsLink()
        Returns the target link.
        Returns:
        The target link.
        See Also:
        getTarget()
      • getTargetAsLiteral

        public Literal getTargetAsLiteral()
        Returns the target literal.
        Returns:
        The target literal.
        See Also:
        getTarget()
      • getTargetAsReference

        public Reference getTargetAsReference()
        Returns the target resource reference.
        Returns:
        The target resource reference.
        See Also:
        getTarget()
      • getTypeRef

        public Reference getTypeRef()
        Returns the type reference. This maps with the concept of predicate in RDF terminology.
        Returns:
        The type reference.
      • hasGraphSource

        public boolean hasGraphSource()
        Indicates if the source is a graph.
        Returns:
        True if the source is a graph.
      • hasGraphTarget

        public boolean hasGraphTarget()
        Indicates if the target is a graph.
        Returns:
        True if the target is a graph.
      • hasLinkSource

        public boolean hasLinkSource()
        Indicates if the source is a link.
        Returns:
        True if the source is a link.
      • hasLinkTarget

        public boolean hasLinkTarget()
        Indicates if the target is a link.
        Returns:
        True if the target is a link.
      • hasLiteralTarget

        public boolean hasLiteralTarget()
        Indicates if the target is a literal.
        Returns:
        True if the target is a literal.
      • hasReferenceSource

        public boolean hasReferenceSource()
        Indicates if the source is a reference.
        Returns:
        True if the source is a reference.
      • hasReferenceTarget

        public boolean hasReferenceTarget()
        Indicates if the target is a reference.
        Returns:
        True if the target is a reference.
      • setSource

        public void setSource​(Graph sourceGraph)
        Sets the source as a graph. This maps with the concept of subject in RDF terminology.
        Parameters:
        sourceGraph - The source graph.
      • setSource

        public void setSource​(Link sourceLink)
        Sets the source as a link. This maps with the concept of subject in RDF terminology.
        Parameters:
        sourceLink - The source link.
      • setSource

        public void setSource​(Reference sourceRef)
        Sets the source resource reference. This maps with the concept of subject in RDF terminology.
        Parameters:
        sourceRef - The source resource reference.
      • setTarget

        public void setTarget​(Graph targetGraph)
        Sets the target as a graph. This maps with the concept of object in RDF terminology.
        Parameters:
        targetGraph - The target graph.
      • setTarget

        public void setTarget​(Link targetLink)
        Sets the target as a link. This maps with the concept of object in RDF terminology.
        Parameters:
        targetLink - The target link.
      • setTarget

        public void setTarget​(Literal targetLit)
        Sets the target literal. This maps with the concept of object in RDF terminology.
        Parameters:
        targetLit - The target literal.
      • setTarget

        public void setTarget​(Reference targetRef)
        Sets the target as a resource reference. This maps with the concept of object in RDF terminology.
        Parameters:
        targetRef - The target resource reference.
      • setTypeRef

        public void setTypeRef​(Reference typeRef)
        Sets the type reference. This maps with the concept of predicate in RDF terminology.
        Parameters:
        typeRef - The type reference.