Class ResourceImpl
- java.lang.Object
-
- org.apache.jena.enhanced.Polymorphic<RDFNode>
-
- org.apache.jena.enhanced.EnhNode
-
- org.apache.jena.rdf.model.impl.ResourceImpl
-
- All Implemented Interfaces:
FrontsNode
,RDFNode
,Resource
- Direct Known Subclasses:
ContainerImpl
,OntResourceImpl
,PropertyImpl
,RDFListImpl
,ReifiedStatementImpl
public class ResourceImpl extends EnhNode implements Resource
An implementation of Resource.
-
-
Field Summary
Fields Modifier and Type Field Description static Implementation
factory
static Implementation
rdfNodeFactory
-
Constructor Summary
Constructors Constructor Description ResourceImpl()
Creates new ResourceImplResourceImpl(java.lang.String uri)
ResourceImpl(java.lang.String nameSpace, java.lang.String localName)
ResourceImpl(java.lang.String nameSpace, java.lang.String localName, ModelCom m)
ResourceImpl(java.lang.String uri, ModelCom m)
ResourceImpl(Node n, EnhGraph m)
ResourceImpl(Node n, ModelCom m)
the main constructor: make a new Resource in the given model, rooted in the given node.ResourceImpl(AnonId id)
ResourceImpl(AnonId id, ModelCom m)
ResourceImpl(ModelCom m)
ResourceImpl(Resource r, ModelCom m)
ResourceImpl(Statement statement, ModelCom m)
-
Method Summary
All Methods Instance Methods Concrete 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 p, double 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, float 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, 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, double o)
Resource
addProperty(Property p, float o)
Resource
addProperty(Property p, long o)
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.Literal
asLiteral()
If this node is a Literal, answer that literal; otherwise throw an exception.Resource
asResource()
If this node is a Resource, answer that resource; otherwise throw an exception.Resource
begin()
Begin a transaction in the associated model.Resource
commit()
Commit the transaction in the associated model.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.Model
getModel()
Return the model associated with this resource.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.java.lang.Object
visitWith(RDFVisitor rv)
Apply the appropriate method of the visitor to this node's content and return the result.-
Methods inherited from class org.apache.jena.enhanced.EnhNode
as, asNode, canAs, equals, getGraph, hashCode, isAnon, isLiteral, isResource, isStmtResource, isURIResource, isValid, viewAs
-
Methods inherited from class org.apache.jena.enhanced.Polymorphic
addView, supports
-
Methods inherited from interface org.apache.jena.graph.FrontsNode
asNode
-
Methods inherited from interface org.apache.jena.rdf.model.RDFNode
as, canAs, isAnon, isLiteral, isResource, isStmtResource, isURIResource
-
-
-
-
Field Detail
-
factory
public static final Implementation factory
-
rdfNodeFactory
public static final Implementation rdfNodeFactory
-
-
Constructor Detail
-
ResourceImpl
public ResourceImpl(Node n, ModelCom m)
the main constructor: make a new Resource in the given model, rooted in the given node. NOT FOR PUBLIC USE - used in ModelCom [and ContainerImpl]
-
ResourceImpl
public ResourceImpl()
Creates new ResourceImpl
-
ResourceImpl
public ResourceImpl(ModelCom m)
-
ResourceImpl
public ResourceImpl(java.lang.String uri)
-
ResourceImpl
public ResourceImpl(java.lang.String nameSpace, java.lang.String localName)
-
ResourceImpl
public ResourceImpl(AnonId id)
-
ResourceImpl
public ResourceImpl(java.lang.String uri, ModelCom m)
-
ResourceImpl
public ResourceImpl(java.lang.String nameSpace, java.lang.String localName, ModelCom m)
-
-
Method Detail
-
visitWith
public java.lang.Object visitWith(RDFVisitor rv)
Description copied from interface:RDFNode
Apply the appropriate method of the visitor to this node's content and return the result.
-
asResource
public Resource asResource()
Description copied from interface:RDFNode
If this node is a Resource, answer that resource; otherwise throw an exception.- Specified by:
asResource
in interfaceRDFNode
-
asLiteral
public Literal asLiteral()
Description copied from interface:RDFNode
If this node is a Literal, answer that literal; otherwise throw an exception.
-
inModel
public Resource inModel(Model m)
Description copied from interface:Resource
Override RDFNode.inModel() to produce a statically-typed Resource in the given Model.
-
getId
public AnonId getId()
Description copied from interface:Resource
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.
-
getURI
public java.lang.String getURI()
Description copied from interface:Resource
Return the URI of the resource, or null if it's a bnode or statement.
-
getStmtTerm
public Statement getStmtTerm()
Description copied from interface:Resource
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.- Specified by:
getStmtTerm
in interfaceResource
- Returns:
- The statement of this resource,or null if it is not an RDF-star triple term.
-
getNameSpace
public java.lang.String getNameSpace()
Description copied from interface:Resource
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.- Specified by:
getNameSpace
in interfaceResource
- Returns:
- The namespace for this resource or null.
-
getLocalName
public java.lang.String getLocalName()
Description copied from interface:Resource
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.- Specified by:
getLocalName
in interfaceResource
- Returns:
- The localname of this property within its namespace.
-
hasURI
public boolean hasURI(java.lang.String uri)
Description copied from interface:Resource
Answer true iff this Resource is a URI resource with the given URI. Using this is preferred to using getURI() and .equals().
-
toString
public java.lang.String toString()
Description copied from interface:Resource
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.
-
getRequiredProperty
public Statement getRequiredProperty(Property p)
Description copied from interface:Resource
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.
- Specified by:
getRequiredProperty
in interfaceResource
- Parameters:
p
- The property sought.- Returns:
- some (this, p, ?O) statement if one exists
-
getRequiredProperty
public Statement getRequiredProperty(Property p, java.lang.String lang)
Description copied from interface:Resource
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.
- Specified by:
getRequiredProperty
in interfaceResource
- 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
-
getProperty
public Statement getProperty(Property p)
Description copied from interface:Resource
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.- Specified by:
getProperty
in interfaceResource
- Parameters:
p
- the property sought- Returns:
- a statement (this, p, O), or null if no such statements exist here
-
getProperty
public Statement getProperty(Property p, java.lang.String lang)
Description copied from interface:Resource
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.- Specified by:
getProperty
in interfaceResource
- Parameters:
p
- The property sought.lang
- The language of the property sought.- Returns:
- some (this, p, ?O@lang) statement if one exists
-
listProperties
public StmtIterator listProperties(Property p)
Description copied from interface:Resource
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.
- Specified by:
listProperties
in interfaceResource
- Parameters:
p
- The predicate sought.- Returns:
- An iterator over the statements.
-
listProperties
public StmtIterator listProperties(Property p, java.lang.String lang)
Description copied from interface:Resource
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.
- Specified by:
listProperties
in interfaceResource
- Returns:
- An iterator over all the statements about this object.
-
listProperties
public StmtIterator listProperties()
Description copied from interface:Resource
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.
- Specified by:
listProperties
in interfaceResource
- Returns:
- An iterator over all the statements about this object.
-
addLiteral
public Resource addLiteral(Property p, boolean o)
Description copied from interface:Resource
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)
.- Specified by:
addLiteral
in interfaceResource
-
addLiteral
public Resource addLiteral(Property p, long o)
Description copied from interface:Resource
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)
.- Specified by:
addLiteral
in interfaceResource
-
addLiteral
public Resource addLiteral(Property p, char o)
Description copied from interface:Resource
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)
.- Specified by:
addLiteral
in interfaceResource
-
addLiteral
public Resource addLiteral(Property p, double o)
Description copied from interface:Resource
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)
.- Specified by:
addLiteral
in interfaceResource
-
addLiteral
public Resource addLiteral(Property p, float o)
Description copied from interface:Resource
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)
.- Specified by:
addLiteral
in interfaceResource
-
addProperty
public Resource addProperty(Property p, java.lang.String o)
Description copied from interface:Resource
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.
- Specified by:
addProperty
in interfaceResource
- Parameters:
p
- The property to be added.o
- The value of the property to be added.- Returns:
- This resource to allow cascading calls.
-
addProperty
public Resource addProperty(Property p, java.lang.String o, java.lang.String l)
Description copied from interface:Resource
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.
- Specified by:
addProperty
in interfaceResource
- 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
public Resource addProperty(Property p, java.lang.String lexicalForm, RDFDatatype datatype)
Description copied from interface:Resource
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.
- Specified by:
addProperty
in interfaceResource
- Parameters:
p
- The property to be added.lexicalForm
- The lexical form of the literaldatatype
- The datatype- Returns:
- This resource to allow cascading calls.
-
addLiteral
public Resource addLiteral(Property p, java.lang.Object o)
Description copied from interface:Resource
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)
.- Specified by:
addLiteral
in interfaceResource
-
addLiteral
public Resource addLiteral(Property p, Literal o)
Description copied from interface:Resource
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.- Specified by:
addLiteral
in interfaceResource
-
addProperty
public Resource addProperty(Property p, RDFNode o)
Description copied from interface:Resource
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.
- Specified by:
addProperty
in interfaceResource
- Parameters:
p
- The property to be added.o
- The value of the property to be added.- Returns:
- This resource to allow cascading calls.
-
hasProperty
public boolean hasProperty(Property p)
Description copied from interface:Resource
Determine whether this resource has any values for a given property.- Specified by:
hasProperty
in interfaceResource
- Parameters:
p
- The property sought.- Returns:
- true if and only if this resource has at least one value for the property.
-
hasLiteral
public boolean hasLiteral(Property p, boolean o)
Description copied from interface:Resource
Answer true iff this resource has the valueo
for propertyp
.o
is interpreted as a typed literal with the appropriate RDF type.- Specified by:
hasLiteral
in interfaceResource
-
hasLiteral
public boolean hasLiteral(Property p, long o)
Description copied from interface:Resource
Answer true iff this resource has the valueo
for propertyp
.o
is interpreted as a typed literal with the appropriate RDF type.- Specified by:
hasLiteral
in interfaceResource
-
hasLiteral
public boolean hasLiteral(Property p, char o)
Description copied from interface:Resource
Answer true iff this resource has the valueo
for propertyp
.o
is interpreted as a typed literal with the appropriate RDF type.- Specified by:
hasLiteral
in interfaceResource
-
hasLiteral
public boolean hasLiteral(Property p, double o)
Description copied from interface:Resource
Answer true iff this resource has the valueo
for propertyp
.o
is interpreted as a typed literal with the appropriate RDF type.- Specified by:
hasLiteral
in interfaceResource
-
hasLiteral
public boolean hasLiteral(Property p, float o)
Description copied from interface:Resource
Answer true iff this resource has the valueo
for propertyp
.o
is interpreted as a typed literal with the appropriate RDF type.- Specified by:
hasLiteral
in interfaceResource
-
hasProperty
public boolean hasProperty(Property p, java.lang.String o)
Description copied from interface:Resource
Test if this resource has a given property with a given value.- Specified by:
hasProperty
in interfaceResource
- 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
public boolean hasProperty(Property p, java.lang.String o, java.lang.String l)
Description copied from interface:Resource
Test if this resource has a given property with a given value.- Specified by:
hasProperty
in interfaceResource
- 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.
-
hasLiteral
public boolean hasLiteral(Property p, java.lang.Object o)
Description copied from interface:Resource
Answer true iff this resource has the valueo
for propertyp
.o
is interpreted as a typed literal with the appropriate RDF type.- Specified by:
hasLiteral
in interfaceResource
-
hasProperty
public boolean hasProperty(Property p, RDFNode o)
Description copied from interface:Resource
Test if this resource has a given property with a given value.- Specified by:
hasProperty
in interfaceResource
- 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
public Resource removeProperties()
Description copied from interface:Resource
Delete all the properties for this resource from the associated model.- Specified by:
removeProperties
in interfaceResource
- Returns:
- This resource to permit cascading.
-
removeAll
public Resource removeAll(Property p)
Description copied from interface:Resource
Delete all the statements with predicatep
for this resource from its associated model.
-
begin
public Resource begin()
Description copied from interface:Resource
Begin a transaction in the associated model.
-
abort
public Resource abort()
Description copied from interface:Resource
Abort the transaction in the associated model.
-
commit
public Resource commit()
Description copied from interface:Resource
Commit the transaction in the associated model.
-
getModel
public Model getModel()
Description copied from interface:RDFNode
Return the model associated with this resource. If the Resource was not created by a Model, the result may be null.
-
getPropertyResourceValue
public Resource getPropertyResourceValue(Property p)
Description copied from interface:Resource
Answer some resource R for which this.hasProperty( p, R ), or null if no such R exists.- Specified by:
getPropertyResourceValue
in interfaceResource
-
-