Interface Resource
-
- All Superinterfaces:
FrontsNode
,RDFNode
- All Known Subinterfaces:
AllDifferent
,AllValuesFromRestriction
,Alt
,AnnotationProperty
,Bag
,BooleanClassDescription
,CardinalityQRestriction
,CardinalityRestriction
,ComplementClass
,Container
,DataRange
,DatatypeProperty
,EnumeratedClass
,FunctionalProperty
,HasValueRestriction
,Individual
,IntersectionClass
,InverseFunctionalProperty
,MaxCardinalityQRestriction
,MaxCardinalityRestriction
,MinCardinalityQRestriction
,MinCardinalityRestriction
,ObjectProperty
,OntClass
,Ontology
,OntProperty
,OntResource
,Property
,QualifiedRestriction
,RDFList
,ReifiedStatement
,Restriction
,Seq
,SomeValuesFromRestriction
,SymmetricProperty
,TransitiveProperty
,UnionClass
- All Known Implementing Classes:
AllDifferentImpl
,AllValuesFromRestrictionImpl
,AltImpl
,AnnotationPropertyImpl
,BagImpl
,BooleanClassDescriptionImpl
,CardinalityQRestrictionImpl
,CardinalityRestrictionImpl
,ComplementClassImpl
,ContainerImpl
,DataRangeImpl
,DatatypePropertyImpl
,EnumeratedClassImpl
,FunctionalPropertyImpl
,HasValueRestrictionImpl
,IndividualImpl
,IntersectionClassImpl
,InverseFunctionalPropertyImpl
,MaxCardinalityQRestrictionImpl
,MaxCardinalityRestrictionImpl
,MinCardinalityQRestrictionImpl
,MinCardinalityRestrictionImpl
,ObjectPropertyImpl
,OntClassImpl
,OntologyImpl
,OntPropertyImpl
,OntResourceImpl
,PropertyImpl
,QualifiedRestrictionImpl
,RDFListImpl
,ReifiedStatementImpl
,ResourceImpl
,RestrictionImpl
,SeqImpl
,SomeValuesFromRestrictionImpl
,SymmetricPropertyImpl
,TransitivePropertyImpl
,UnionClassImpl
public interface Resource extends RDFNode
An RDF Resource. Resource instances when created may be associated with a specific model. Resources created by a model will refer to that model, and support a range of methods, such asgetProperty()
andaddProperty()
which will access or modify that model. This enables the programmer to write code in a compact and easy style.Resources created by ResourceFactory will not refer to any model, and will not permit operations which require a model. Such resources are useful as general constants.
This interface provides methods supporting typed literals. This means that methods are provided which will translate a built in type, or an object to an RDF Literal. This translation is done by invoking the
toString()
method of the object, or its built in equivalent. The reverse translation is also supported. This is built in for built in types. Factory objects, provided by the application, are used for application objects.This interface provides methods for supporting enhanced resources. An enhanced resource is a resource to which the application has added behaviour. RDF containers are examples of enhanced resources built in to this package. Enhanced resources are supported by encapsulating a resource created by an implementation in another class which adds the extra behaviour. Factory objects are used to construct such enhanced resources.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Resource
abort()
Abort the transaction in the associated model.Resource
addLiteral(Property p, boolean o)
Add the propertyp
with the typed-literal valueo
to this resource, ie add (this, p, typed(o)) to this's model.Resource
addLiteral(Property p, char o)
Add the propertyp
with the typed-literal valueo
to this resource, ie add (this, p, typed(o)) to this's model.Resource
addLiteral(Property value, double d)
Add the propertyp
with the typed-literal valueo
to this resource, ie add (this, p, typed(o)) to this's model.Resource
addLiteral(Property value, float d)
Add the propertyp
with the typed-literal valueo
to this resource, ie add (this, p, typed(o)) to this's model.Resource
addLiteral(Property p, long o)
Add the propertyp
with the typed-literal valueo
to this resource, ie add (this, p, typed(o)) to this's model.Resource
addLiteral(Property p, java.lang.Object o)
Add the propertyp
with the typed-literal valueo
to this resource, ie add (this, p, typed(o)) to this's model.Resource
addLiteral(Property p, Literal o)
Add the propertyp
with the pre-constructed Literal valueo
to this resource, ie add (this, p, o) to this's model.Resource
addProperty(Property p, java.lang.String o)
Add a property to this resource.Resource
addProperty(Property p, java.lang.String o, java.lang.String l)
Add a property to this resource.Resource
addProperty(Property p, java.lang.String lexicalForm, RDFDatatype datatype)
Add a property to this resource.Resource
addProperty(Property p, RDFNode o)
Add a property to this resource.Resource
begin()
Begin a transaction in the associated model.Resource
commit()
Commit the transaction in the associated model.boolean
equals(java.lang.Object o)
Determine whether two objects represent the same resource.AnonId
getId()
Returns an a unique identifier for anonymous resources.java.lang.String
getLocalName()
Returns the localname of this resource within its namespace if it is a URI else null.java.lang.String
getNameSpace()
Returns the namespace associated with this resource if it is a URI, else return null.Statement
getProperty(Property p)
Answer some statement (this, p, O) in the associated model.Statement
getProperty(Property p, java.lang.String lang)
Answer some statement (this, p, O), in languagelang
, in the associated model.Resource
getPropertyResourceValue(Property p)
Answer some resource R for which this.hasProperty( p, R ), or null if no such R exists.Statement
getRequiredProperty(Property p)
Get a property value of this resource.Statement
getRequiredProperty(Property p, java.lang.String lang)
Get a property value of this resource in a specified language.Statement
getStmtTerm()
Return the statement of this resource, or null if it is not an RDF-star triple term.java.lang.String
getURI()
Return the URI of the resource, or null if it's a bnode or statement.boolean
hasLiteral(Property p, boolean o)
Answer true iff this resource has the valueo
for propertyp
.boolean
hasLiteral(Property p, char o)
Answer true iff this resource has the valueo
for propertyp
.boolean
hasLiteral(Property p, double o)
Answer true iff this resource has the valueo
for propertyp
.boolean
hasLiteral(Property p, float o)
Answer true iff this resource has the valueo
for propertyp
.boolean
hasLiteral(Property p, long o)
Answer true iff this resource has the valueo
for propertyp
.boolean
hasLiteral(Property p, java.lang.Object o)
Answer true iff this resource has the valueo
for propertyp
.boolean
hasProperty(Property p)
Determine whether this resource has any values for a given property.boolean
hasProperty(Property p, java.lang.String o)
Test if this resource has a given property with a given value.boolean
hasProperty(Property p, java.lang.String o, java.lang.String l)
Test if this resource has a given property with a given value.boolean
hasProperty(Property p, RDFNode o)
Test if this resource has a given property with a given value.boolean
hasURI(java.lang.String uri)
Answer true iff this Resource is a URI resource with the given URI.Resource
inModel(Model m)
Override RDFNode.inModel() to produce a statically-typed Resource in the given Model.StmtIterator
listProperties()
Return an iterator over all the properties of this resource.StmtIterator
listProperties(Property p)
List all the values of the property p.StmtIterator
listProperties(Property p, java.lang.String lang)
Return an iterator over all the properties of this resource with a specific language.Resource
removeAll(Property p)
Delete all the statements with predicatep
for this resource from its associated model.Resource
removeProperties()
Delete all the properties for this resource from the associated model.java.lang.String
toString()
Return a string representation of the resource.-
Methods inherited from interface org.apache.jena.graph.FrontsNode
asNode
-
Methods inherited from interface org.apache.jena.rdf.model.RDFNode
as, asLiteral, asResource, canAs, getModel, isAnon, isLiteral, isResource, isStmtResource, isURIResource, visitWith
-
-
-
-
Method Detail
-
getId
AnonId getId()
Returns an a unique identifier for anonymous resources.The id is unique within the scope of a particular implementation. All models within an implementation will use the same id for the same anonymous resource.
This method is undefined if called on resources which are not anonymous and may raise an exception.
- Returns:
- A unique id for an anonymous resource.
-
inModel
Resource inModel(Model m)
Override RDFNode.inModel() to produce a statically-typed Resource in the given Model.
-
hasURI
boolean hasURI(java.lang.String uri)
Answer true iff this Resource is a URI resource with the given URI. Using this is preferred to using getURI() and .equals().
-
getURI
java.lang.String getURI()
Return the URI of the resource, or null if it's a bnode or statement.- Returns:
- The URI of the resource, or null if it's a bnode or statement.
-
getStmtTerm
Statement getStmtTerm()
Return the statement of this resource, or null if it is not an RDF-star triple term. This is not a resource for a reified statement.- Returns:
- The statement of this resource,or null if it is not an RDF-star triple term.
-
getNameSpace
java.lang.String getNameSpace()
Returns the namespace associated with this resource if it is a URI, else return null.The namespace is suitable for use with localname in in RDF/XML. XML does not allow QNames to start with a digit and this method reflects that restriction in the values for namespace and localname.
See functions in
SplitIRI
for other split algorithms.- Returns:
- The namespace for this resource or null.
-
getLocalName
java.lang.String getLocalName()
Returns the localname of this resource within its namespace if it is a URI else null.Note: XML requires QNames to start with a letter, not a digit, and this method reflects that restriction.
See functions in
SplitIRI
for other split algorithms.- Returns:
- The localname of this property within its namespace.
-
toString
java.lang.String toString()
Return a string representation of the resource. Returns the URI of the resource unless the resource is anonymous in which case it returns the id of the resource enclosed in square brackets.
-
equals
boolean equals(java.lang.Object o)
Determine whether two objects represent the same resource.A resource can only be equal to another resource. If both resources are not anonymous, then they are equal if the URI's are equal. If both resources are anonymous, they are equal only if their Id's are the same. If one resource is anonymous and the other is not, then they are not equal.
- Overrides:
equals
in classjava.lang.Object
- Parameters:
o
- The object to be compared.- Returns:
- true if and only if both objects are equal
-
getRequiredProperty
Statement getRequiredProperty(Property p)
Get a property value of this resource.The model associated with the resource instance is searched for statements whose subject is this resource and whose predicate is p. If such a statement is found, it is returned. If several such statements are found, any one may be returned. If no such statements are found, an exception is thrown.
- Parameters:
p
- The property sought.- Returns:
- some (this, p, ?O) statement if one exists
- Throws:
PropertyNotFoundException
- if no such statement found
-
getRequiredProperty
Statement getRequiredProperty(Property p, java.lang.String lang)
Get a property value of this resource in a specified language.The model associated with the resource instance is searched for statements whose subject is this resource and whose predicate is p. If such a statement is found, it is returned. If several such statements are found, any one may be returned. If no such statements are found, an exception is thrown.
- Parameters:
p
- The property sought.lang
- The language of the statement with the property sought.- Returns:
- some (this, p, ?O@lang) statement if one exists
- Throws:
PropertyNotFoundException
- if no such statement found
-
getProperty
Statement getProperty(Property p)
Answer some statement (this, p, O) in the associated model. If there are several such statements, any one of them may be returned. If no such statements exist, null is returned - in this is differs from getRequiredProperty.- Parameters:
p
- the property sought- Returns:
- a statement (this, p, O), or null if no such statements exist here
-
getProperty
Statement getProperty(Property p, java.lang.String lang)
Answer some statement (this, p, O), in languagelang
, in the associated model. If there are several such statements, any one of them may be returned. If no such statements exist, null is returned - in this it differs from getRequiredProperty.- Parameters:
p
- The property sought.lang
- The language of the property sought.- Returns:
- some (this, p, ?O@lang) statement if one exists
-
listProperties
StmtIterator listProperties(Property p)
List all the values of the property p.Returns an iterator over all the statements in the associated model whose subject is this resource and whose predicate is p.
- Parameters:
p
- The predicate sought.- Returns:
- An iterator over the statements.
-
listProperties
StmtIterator listProperties(Property p, java.lang.String lang)
Return an iterator over all the properties of this resource with a specific language.The model associated with this resource is searched and an iterator is returned which iterates over all the statements which have this resource as a subject.
- Returns:
- An iterator over all the statements about this object.
-
listProperties
StmtIterator listProperties()
Return an iterator over all the properties of this resource.The model associated with this resource is search and an iterator is returned which iterates over all the statements which have this resource as a subject.
- Returns:
- An iterator over all the statements about this object.
-
addLiteral
Resource addLiteral(Property p, boolean o)
Add the propertyp
with the typed-literal valueo
to this resource, ie add (this, p, typed(o)) to this's model. Answer this resource. The typed literal is equal to one constructed by usingthis.getModel().createTypedLiteral(o)
.
-
addLiteral
Resource addLiteral(Property p, long o)
Add the propertyp
with the typed-literal valueo
to this resource, ie add (this, p, typed(o)) to this's model. Answer this resource. The typed literal is equal to one constructed by usingthis.getModel().createTypedLiteral(o)
.
-
addLiteral
Resource addLiteral(Property p, char o)
Add the propertyp
with the typed-literal valueo
to this resource, ie add (this, p, typed(o)) to this's model. Answer this resource. The typed literal is equal to one constructed by usingthis.getModel().createTypedLiteral(o)
.
-
addLiteral
Resource addLiteral(Property value, double d)
Add the propertyp
with the typed-literal valueo
to this resource, ie add (this, p, typed(o)) to this's model. Answer this resource. The typed literal is equal to one constructed by usingthis.getModel().createTypedLiteral(o)
.
-
addLiteral
Resource addLiteral(Property value, float d)
Add the propertyp
with the typed-literal valueo
to this resource, ie add (this, p, typed(o)) to this's model. Answer this resource. The typed literal is equal to one constructed by usingthis.getModel().createTypedLiteral(o)
.
-
addLiteral
Resource addLiteral(Property p, java.lang.Object o)
Add the propertyp
with the typed-literal valueo
to this resource, ie add (this, p, typed(o)) to this's model. Answer this resource. The typed literal is equal to one constructed by usingthis.getModel().createTypedLiteral(o)
.
-
addLiteral
Resource addLiteral(Property p, Literal o)
Add the propertyp
with the pre-constructed Literal valueo
to this resource, ie add (this, p, o) to this's model. Answer this resource. NOTE thjat this is distinct from the other addLiteral methods in that the Literal is not turned into a Literal.
-
addProperty
Resource addProperty(Property p, java.lang.String o)
Add a property to this resource.A statement with this resource as the subject, p as the predicate and o as the object is added to the model associated with this resource.
- Parameters:
p
- The property to be added.o
- The value of the property to be added.- Returns:
- This resource to allow cascading calls.
-
addProperty
Resource addProperty(Property p, java.lang.String o, java.lang.String l)
Add a property to this resource.A statement with this resource as the subject, p as the predicate and o as the object is added to the model associated with this resource.
- Parameters:
p
- The property to be added.o
- The value of the property to be added.l
- the language of the property- Returns:
- This resource to allow cascading calls.
-
addProperty
Resource addProperty(Property p, java.lang.String lexicalForm, RDFDatatype datatype)
Add a property to this resource.A statement with this resource as the subject, p as the predicate and o as the object is added to the model associated with this resource.
- Parameters:
p
- The property to be added.lexicalForm
- The lexical form of the literaldatatype
- The datatype- Returns:
- This resource to allow cascading calls.
-
addProperty
Resource addProperty(Property p, RDFNode o)
Add a property to this resource.A statement with this resource as the subject, p as the predicate and o as the object is added to the model associated with this resource.
- Parameters:
p
- The property to be added.o
- The value of the property to be added.- Returns:
- This resource to allow cascading calls.
-
hasProperty
boolean hasProperty(Property p)
Determine whether this resource has any values for a given property.- Parameters:
p
- The property sought.- Returns:
- true if and only if this resource has at least one value for the property.
-
hasLiteral
boolean hasLiteral(Property p, boolean o)
Answer true iff this resource has the valueo
for propertyp
.o
is interpreted as a typed literal with the appropriate RDF type.
-
hasLiteral
boolean hasLiteral(Property p, long o)
Answer true iff this resource has the valueo
for propertyp
.o
is interpreted as a typed literal with the appropriate RDF type.
-
hasLiteral
boolean hasLiteral(Property p, char o)
Answer true iff this resource has the valueo
for propertyp
.o
is interpreted as a typed literal with the appropriate RDF type.
-
hasLiteral
boolean hasLiteral(Property p, double o)
Answer true iff this resource has the valueo
for propertyp
.o
is interpreted as a typed literal with the appropriate RDF type.
-
hasLiteral
boolean hasLiteral(Property p, float o)
Answer true iff this resource has the valueo
for propertyp
.o
is interpreted as a typed literal with the appropriate RDF type.
-
hasLiteral
boolean hasLiteral(Property p, java.lang.Object o)
Answer true iff this resource has the valueo
for propertyp
.o
is interpreted as a typed literal with the appropriate RDF type.
-
hasProperty
boolean hasProperty(Property p, java.lang.String o)
Test if this resource has a given property with a given value.- Parameters:
p
- The property sought.o
- The value of the property sought.- Returns:
- true if and only if this resource has property p with value o.
-
hasProperty
boolean hasProperty(Property p, java.lang.String o, java.lang.String l)
Test if this resource has a given property with a given value.- Parameters:
p
- The property sought.o
- The value of the property sought.l
- The language of the property sought.- Returns:
- true if and only if this resource has property p with value o.
-
hasProperty
boolean hasProperty(Property p, RDFNode o)
Test if this resource has a given property with a given value.- Parameters:
p
- The property sought.o
- The value of the property sought.- Returns:
- true if and only if this resource has property p with value o.
-
removeProperties
Resource removeProperties()
Delete all the properties for this resource from the associated model.- Returns:
- This resource to permit cascading.
-
removeAll
Resource removeAll(Property p)
Delete all the statements with predicatep
for this resource from its associated model.- Parameters:
p
- the property to remove- Returns:
- this resource, to permit cascading
-
begin
Resource begin()
Begin a transaction in the associated model.- Returns:
- This resource to permit cascading.
-
abort
Resource abort()
Abort the transaction in the associated model.- Returns:
- This resource to permit cascading.
-
commit
Resource commit()
Commit the transaction in the associated model.- Returns:
- This resource to permit cascading.
-
-