Package org.restlet.ext.rdf
Class Link
- java.lang.Object
-
- org.restlet.ext.rdf.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).- Author:
- Jerome Louvel
- See Also:
- RDF concepts
-
-
Constructor Summary
Constructors Constructor Description Link(org.restlet.data.Reference sourceRef, java.lang.String typeRef, org.restlet.data.Reference targetRef)
Constructor.Link(org.restlet.data.Reference sourceRef, java.lang.String typeRef, Literal targetLit)
Constructor.Link(org.restlet.data.Reference sourceRef, org.restlet.data.Reference typeRef, org.restlet.data.Reference targetRef)
Constructor.Link(org.restlet.data.Reference sourceRef, org.restlet.data.Reference typeRef, Literal targetLit)
Constructor.Link(Graph sourceGraph, java.lang.String typeRef, java.lang.Object target)
Constructor.Link(Graph sourceGraph, java.lang.String typeRef, org.restlet.data.Reference targetRef)
Constructor.Link(Graph sourceGraph, java.lang.String typeRef, Literal targetLit)
Constructor.Link(Graph sourceGraph, org.restlet.data.Reference typeRef, java.lang.Object target)
Constructor.Link(Graph sourceGraph, org.restlet.data.Reference typeRef, org.restlet.data.Reference targetRef)
Constructor.Link(Graph sourceGraph, org.restlet.data.Reference typeRef, Literal targetLit)
Constructor.Link(Link from)
Constructor by copy.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static org.restlet.data.Reference
createBlankRef(java.lang.String identifier)
Creates a reference to a blank node.java.lang.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.org.restlet.data.Reference
getSourceAsReference()
Returns the source resource reference.java.lang.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.org.restlet.data.Reference
getTargetAsReference()
Returns the target resource reference.org.restlet.data.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(org.restlet.data.Reference reference)
Indicates if a reference is identifying a blank node.void
setSource(org.restlet.data.Reference sourceRef)
Sets the source resource reference.void
setSource(Graph sourceGraph)
Sets the source as a graph.void
setSource(Link sourceLink)
Sets the source as a link.void
setTarget(org.restlet.data.Reference targetRef)
Sets the target as a 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
setTypeRef(org.restlet.data.Reference typeRef)
Sets the type reference.
-
-
-
Constructor Detail
-
Link
public Link(Graph sourceGraph, org.restlet.data.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, org.restlet.data.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, org.restlet.data.Reference typeRef, org.restlet.data.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, org.restlet.data.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(org.restlet.data.Reference sourceRef, org.restlet.data.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(org.restlet.data.Reference sourceRef, org.restlet.data.Reference typeRef, org.restlet.data.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(org.restlet.data.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(org.restlet.data.Reference sourceRef, java.lang.String typeRef, org.restlet.data.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 org.restlet.data.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(org.restlet.data.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 org.restlet.data.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 org.restlet.data.Reference getTargetAsReference()
Returns the target resource reference.- Returns:
- The target resource reference.
- See Also:
getTarget()
-
getTypeRef
public org.restlet.data.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(org.restlet.data.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(org.restlet.data.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(org.restlet.data.Reference typeRef)
Sets the type reference. This maps with the concept of predicate in RDF terminology.- Parameters:
typeRef
- The type reference.
-
-