org.restlet.ext.rdf
Class Link

java.lang.Object
  extended by org.restlet.util.Triple<Object,Reference,Object>
      extended by org.restlet.ext.rdf.Link

public class Link
extends Triple<Object,Reference,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).

Author:
Jerome Louvel
See Also:
RDF concepts

Constructor Summary
Link(Graph sourceGraph, Reference typeRef, Literal targetLit)
          Constructor.
Link(Graph sourceGraph, Reference typeRef, Object target)
          Constructor.
Link(Graph sourceGraph, Reference typeRef, Reference targetRef)
          Constructor.
Link(Graph sourceGraph, String typeRef, Literal targetLit)
          Constructor.
Link(Graph sourceGraph, String typeRef, Object target)
          Constructor.
Link(Graph sourceGraph, String typeRef, Reference targetRef)
          Constructor.
Link(Link from)
          Constructor by copy.
Link(Reference sourceRef, Reference typeRef, Literal targetLit)
          Constructor.
Link(Reference sourceRef, Reference typeRef, Reference targetRef)
          Constructor.
Link(Reference sourceRef, String typeRef, Literal targetLit)
          Constructor.
Link(Reference sourceRef, String typeRef, Reference targetRef)
          Constructor.
 
Method Summary
static Reference createBlankRef(String identifier)
          Creates a reference to a blank node.
 Object getSource()
          Returns the source which can be either a reference or a link or a graph or null.
 Graph getSourceAsGraph()
          Returns the source graph.
 Link getSourceAsLink()
          Returns the source link.
 Reference getSourceAsReference()
          Returns the source resource reference.
 Object getTarget()
          Returns the target which can be either a literal or a reference or is null.
 Graph getTargetAsGraph()
          Returns the target graph.
 Link getTargetAsLink()
          Returns the target link.
 Literal getTargetAsLiteral()
          Returns the target literal.
 Reference getTargetAsReference()
          Returns the target resource reference.
 Reference getTypeRef()
          Returns the type reference.
 boolean hasGraphSource()
          Indicates if the source is a graph.
 boolean hasGraphTarget()
          Indicates if the target is a graph.
 boolean hasLinkSource()
          Indicates if the source is a link.
 boolean hasLinkTarget()
          Indicates if the target is a link.
 boolean hasLiteralTarget()
          Indicates if the target is a literal.
 boolean hasReferenceSource()
          Indicates if the source is a reference.
 boolean hasReferenceTarget()
          Indicates if the target is a reference.
static boolean isBlankRef(Reference reference)
          Indicates if a reference is identifying a blank node.
 void setSource(Graph sourceGraph)
          Sets the source as a graph.
 void setSource(Link sourceLink)
          Sets the source as a link.
 void setSource(Reference sourceRef)
          Sets the source resource reference.
 void setTarget(Graph targetGraph)
          Sets the target as a graph.
 void setTarget(Link targetLink)
          Sets the target as a link.
 void setTarget(Literal targetLit)
          Sets the target literal.
 void setTarget(Reference targetRef)
          Sets the target as a resource reference.
 void setTypeRef(Reference typeRef)
          Sets the type reference.
 
Methods inherited from class org.restlet.util.Triple
equals, getFirst, getSecond, getThird, hashCode, setFirst, setSecond, setThird, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

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,
            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,
            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,
            String typeRef,
            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,
            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

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,
            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,
            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(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 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 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.


Copyright © 2005-2013 Restlet.