Package org.trellisldp.api
Interface Resource
-
- All Known Implementing Classes:
DBResource
,FileResource
,Resource.SpecialResources
,TriplestoreResource
public interface Resource
The central resource abstraction for a Trellis-based linked data server.- See Also:
- Linked Data Platform Specification
- API Note:
- A common implementation pattern for this interface is to initialize the
Resource
object with metadata such asgetModified()
,getInteractionModel()
and other data fetched by the accessors. The resource content, on the other hand, is often loaded on-demand via thestream()
method. This pattern tends to reduce the number of requests to the persistence layer while also limiting the data held in memory for a givenResource
object.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
Resource.SpecialResources
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default Dataset
dataset()
Retrieve the RDF Quads for a resource.default Optional<BinaryMetadata>
getBinaryMetadata()
Retrieve a BinaryMetadata for this resouce, if it is a LDP-NR.Optional<IRI>
getContainer()
Get the container for this resource.default Stream<Map.Entry<String,String>>
getExtraLinkRelations()
Get any extra implementation-defined link relations for this resource.IRI
getIdentifier()
Get an identifier for this resource.default Optional<IRI>
getInsertedContentRelation()
Retrieve the inserted content relation if this is an LDP Indirect container.IRI
getInteractionModel()
Get the LDP interaction model for this resource.default Optional<IRI>
getMemberOfRelation()
Retrieve the member of relation IRI.default Optional<IRI>
getMemberRelation()
Retrieve the member relation if this is an LDP Direct or Indirect container.default Optional<IRI>
getMembershipResource()
Retrieve the membership resource if this is an LDP Direct or Indirect container.default Set<IRI>
getMetadataGraphNames()
Retrieve a collection of attached metadata graph names.Instant
getModified()
Get the last modified date.default String
getRevision()
Get the revision or state tag of the resource.default boolean
hasMetadata(IRI graphName)
Test whether this resource has an attached metadata resource.Stream<Quad>
stream()
Retrieve the RDF Quads for a resource.default Stream<Quad>
stream(Collection<IRI> graphNames)
Retrieve the RDF Quads for a set of named graphs.default Stream<Quad>
stream(IRI graphName)
Retrieve the RDF Quads for a given named graph.
-
-
-
Method Detail
-
getIdentifier
IRI getIdentifier()
Get an identifier for this resource.- Returns:
- the identifier
-
getInteractionModel
IRI getInteractionModel()
Get the LDP interaction model for this resource.- Returns:
- the interaction model
-
getModified
Instant getModified()
Get the last modified date.- Returns:
- the last-modified date
-
getRevision
default String getRevision()
Get the revision or state tag of the resource.- Returns:
- the revision tag of the resource
- API Note:
- the return value of this method should be unique to the state of the resource.
That is, it should be unique across all resources on the server, and whenever
a given resource changes, this revision tag should also change. This value will
be used as the raw material for generating an ETag in the HTTP layer, and it
should not return
null
. - Implementation Requirements:
- the default implementation returns a concatenation of the resource identifier and the modification date.
-
getContainer
Optional<IRI> getContainer()
Get the container for this resource.- Returns:
- the identifier for a container, if one exists.
- API Note:
- returning an empty Optional should indicate here that the resource is not contained by any parent resource. This may be because it is a root resource and therefore not contained by any other resource. Alternatively, it could mean that a PUT operation was used to create the resource.
-
getMembershipResource
default Optional<IRI> getMembershipResource()
Retrieve the membership resource if this is an LDP Direct or Indirect container.- Returns:
- the membership resource
- Implementation Requirements:
- Other LDP resource types will always return an empty
Optional
value
-
getMemberRelation
default Optional<IRI> getMemberRelation()
Retrieve the member relation if this is an LDP Direct or Indirect container.- Returns:
- the ldp:hasMemberRelation IRI
- Implementation Requirements:
- Other LDP resource types will always return an empty
Optional
value
-
getMemberOfRelation
default Optional<IRI> getMemberOfRelation()
Retrieve the member of relation IRI.- Returns:
- the ldp:isMemberOfRelation IRI
- Implementation Requirements:
- Other LDP resource types will always return an empty
Optional
value
-
getInsertedContentRelation
default Optional<IRI> getInsertedContentRelation()
Retrieve the inserted content relation if this is an LDP Indirect container.- Returns:
- the inserted content relation
- Implementation Requirements:
- Other LDP resource types will always return an empty
Optional
value
-
dataset
default Dataset dataset()
Retrieve the RDF Quads for a resource.- Returns:
- the RDF quads
-
stream
default Stream<Quad> stream(IRI graphName)
Retrieve the RDF Quads for a given named graph.- Parameters:
graphName
- the named graph- Returns:
- the RDF quads
-
stream
default Stream<Quad> stream(Collection<IRI> graphNames)
Retrieve the RDF Quads for a set of named graphs.- Parameters:
graphNames
- the named graphs- Returns:
- the RDF quads
-
getBinaryMetadata
default Optional<BinaryMetadata> getBinaryMetadata()
Retrieve a BinaryMetadata for this resouce, if it is a LDP-NR.- Returns:
- the binary metadata
- Implementation Requirements:
- Other LDP resource types will always return an empty
Optional
value
-
hasMetadata
default boolean hasMetadata(IRI graphName)
Test whether this resource has an attached metadata resource.- Parameters:
graphName
- the name of the metadata graph- Returns:
- true if this resource has an attached metadata resource; false otherwise
-
getMetadataGraphNames
default Set<IRI> getMetadataGraphNames()
Retrieve a collection of attached metadata graph names.- Returns:
- a set of metadata resource graph names
-
getExtraLinkRelations
default Stream<Map.Entry<String,String>> getExtraLinkRelations()
Get any extra implementation-defined link relations for this resource.- Returns:
- a stream of relation types
- API Note:
- Each entry will be used to create a link header, such that the key refers
to the URI and the value is the "rel" portion. For example, an item with
key="http://example.com/author001"
andvalue="author"
will result in the headerLink: <http://example.com/author001>; rel="author"
.
-
-