Package org.restlet.ext.rdf
Class Graph
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractSet<E>
-
- java.util.concurrent.CopyOnWriteArraySet<Link>
-
- org.restlet.ext.rdf.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 LinkdefaultLinkThe default link that is used to complete new links.private static longserialVersionUIDThe serialization unique identifier.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Linkadd(java.lang.String sourceRef, java.lang.String typeRef, Reference targetRef)Creates then adds a link.Linkadd(java.lang.String sourceRef, java.lang.String typeRef, Literal targetLit)Creates then adds a link.Linkadd(java.lang.String sourceRef, Reference typeRef, Reference targetRef)Creates then adds a link.Linkadd(java.lang.String sourceRef, Reference typeRef, Literal targetLit)Creates then adds a link.Linkadd(Reference sourceRef, java.lang.String typeRef, Reference targetRef)Creates then adds a link.Linkadd(Reference sourceRef, java.lang.String typeRef, Literal targetLit)Creates then adds a link.Linkadd(Reference sourceRef, Reference typeRef, Reference targetRef)Creates then adds a link.Linkadd(Reference sourceRef, Reference typeRef, Literal targetLit)Creates then adds a link.Linkadd(Graph sourceGraph, Reference typeRef, Reference targetRef)Creates then adds a link.Linkadd(Graph sourceGraph, Reference typeRef, Literal targetLit)Creates then adds a link.LinkaddLiteral(java.lang.String sourceRef, java.lang.String typeRef, java.lang.String targetLit)Creates then adds a link.LinkaddLiteral(Graph sourceGraph, java.lang.String typeRef, java.lang.String targetLit)Creates then adds a link.LinkaddReference(java.lang.String sourceRef, java.lang.String typeRef, java.lang.String targetRef)Creates then adds a link.LinkaddReference(Graph sourceGraph, java.lang.String typeRef, java.lang.String targetRef)Creates then adds a link.LinkgetDefaultLink()Returns the default link that is used to complete new links.RepresentationgetRdfN3Representation()Returns a representation in the RDF/n3 format.RepresentationgetRdfNTriplesRepresentation()Returns a representation in the RDF/N-Triples format.RepresentationgetRdfTurtleRepresentation()Returns a representation in the RDF/Turtle format.RepresentationgetRdfXmlRepresentation()Returns a representation in the RDF/XML format.private GraphgetSourceAsGraph(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 ReferencegetSourceAsReference(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 LiteralgetTargetAsLiteral(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 ReferencegetTargetAsReference(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 ReferencegetTypeRef(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.voidsetDefaultLink(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
-
-
-
-
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 fromgetDefaultLink()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 fromgetDefaultLink()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 fromgetDefaultLink()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 fromgetDefaultLink()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 fromgetDefaultLink()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 fromgetDefaultLink()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 fromgetDefaultLink()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 fromgetDefaultLink()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 fromgetDefaultLink()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 fromgetDefaultLink()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 fromgetDefaultLink()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 fromgetDefaultLink()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 fromgetDefaultLink()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 fromgetDefaultLink()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.
-
-