public class ResourceImpl extends EnhNode implements Resource
| Modifier and Type | Field and Description |
|---|---|
static Implementation |
factory |
static Implementation |
rdfNodeFactory |
| Constructor and Description |
|---|
ResourceImpl()
Creates new ResourceImpl
|
ResourceImpl(AnonId id) |
ResourceImpl(AnonId id,
ModelCom m) |
ResourceImpl(ModelCom m) |
ResourceImpl(Node n,
EnhGraph m) |
ResourceImpl(Node n,
ModelCom m)
the master constructor: make a new Resource in the given model,
rooted in the given node.
|
ResourceImpl(Resource r,
ModelCom m) |
ResourceImpl(Statement statement,
ModelCom m) |
ResourceImpl(String uri) |
ResourceImpl(String uri,
ModelCom m) |
ResourceImpl(String nameSpace,
String localName) |
ResourceImpl(String nameSpace,
String localName,
ModelCom m) |
| Modifier and Type | Method and Description |
|---|---|
Resource |
abort()
Abort the transaction in the associated model.
|
Resource |
addLiteral(Property p,
boolean o)
Add the property
p with the typed-literal value o
to this resource, ie add (this, p, typed(o)) to this's model. |
Resource |
addLiteral(Property p,
char o)
Add the property
p with the typed-literal value o
to this resource, ie add (this, p, typed(o)) to this's model. |
Resource |
addLiteral(Property p,
double o)
Add the property
p with the typed-literal value o
to this resource, ie add (this, p, typed(o)) to this's model. |
Resource |
addLiteral(Property p,
float o)
Add the property
p with the typed-literal value o
to this resource, ie add (this, p, typed(o)) to this's model. |
Resource |
addLiteral(Property p,
Literal o)
Add the property
p with the pre-constructed Literal value
o to this resource, ie add (this, p, o) to this's
model. |
Resource |
addLiteral(Property p,
long o)
Add the property
p with the typed-literal value o
to this resource, ie add (this, p, typed(o)) to this's model. |
Resource |
addLiteral(Property p,
Object o)
Add the property
p with the typed-literal value o
to this resource, ie add (this, p, typed(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,
RDFNode o)
Add a property to this resource.
|
Resource |
addProperty(Property p,
String o)
Add a property to this resource.
|
Resource |
addProperty(Property p,
String lexicalForm,
RDFDatatype datatype)
Add a property to this resource.
|
Resource |
addProperty(Property p,
String o,
String l)
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.
|
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.
|
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,
String lang)
Answer some statement (this, p, O), in language
lang, 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,
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* triple term.
|
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 value
o for
property p. |
boolean |
hasLiteral(Property p,
char o)
Answer true iff this resource has the value
o for
property p. |
boolean |
hasLiteral(Property p,
double o)
Answer true iff this resource has the value
o for
property p. |
boolean |
hasLiteral(Property p,
float o)
Answer true iff this resource has the value
o for
property p. |
boolean |
hasLiteral(Property p,
long o)
Answer true iff this resource has the value
o for
property p. |
boolean |
hasLiteral(Property p,
Object o)
Answer true iff this resource has the value
o for
property p. |
boolean |
hasProperty(Property p)
Determine whether this resource has any values for a given property.
|
boolean |
hasProperty(Property p,
RDFNode o)
Test if this resource has a given property with a given value.
|
boolean |
hasProperty(Property p,
String o)
Test if this resource has a given property with a given value.
|
boolean |
hasProperty(Property p,
String o,
String l)
Test if this resource has a given property with a given value.
|
boolean |
hasURI(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,
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 predicate
p for this resource
from its associated model. |
Resource |
removeProperties()
Delete all the properties for this resource from the associated model.
|
String |
toString()
Return a string representation of the resource.
|
Object |
visitWith(RDFVisitor rv)
Apply the appropriate method of the visitor to this node's content and
return the result.
|
as, asNode, canAs, equals, getGraph, hashCode, isAnon, isLiteral, isResource, isStmtResource, isURIResource, isValid, viewAsaddView, supportsas, canAs, isAnon, isLiteral, isResource, isStmtResource, isURIResourceasNodepublic static final Implementation factory
public static final Implementation rdfNodeFactory
public ResourceImpl(Node n, ModelCom m)
public ResourceImpl()
public ResourceImpl(ModelCom m)
public ResourceImpl(String uri)
public ResourceImpl(AnonId id)
public Object visitWith(RDFVisitor rv)
RDFNodepublic Resource asResource()
RDFNodeasResource in interface RDFNodepublic Literal asLiteral()
RDFNodepublic Resource inModel(Model m)
Resourcepublic AnonId getId()
ResourceThe 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.
public String getURI()
Resourcepublic Statement getStmtTerm()
ResourcegetStmtTerm in interface Resourcepublic String getNameSpace()
ResourceThe 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.
getNameSpace in interface Resourcepublic String getLocalName()
ResourceNote: 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.
getLocalName in interface Resourcepublic boolean hasURI(String uri)
Resourcepublic String toString()
Resourcepublic Statement getRequiredProperty(Property p)
ResourceThe 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.
getRequiredProperty in interface Resourcep - The property sought.public Statement getRequiredProperty(Property p, String lang)
ResourceThe 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.
getRequiredProperty in interface Resourcep - The property sought.lang - The language of the statement with the property sought.public Statement getProperty(Property p)
ResourcegetProperty in interface Resourcep - the property soughtpublic Statement getProperty(Property p, String lang)
Resourcelang, 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.getProperty in interface Resourcep - The property sought.lang - The language of the property sought.public StmtIterator listProperties(Property p)
ResourceReturns an iterator over all the statements in the associated model whose subject is this resource and whose predicate is p.
listProperties in interface Resourcep - The predicate sought.public StmtIterator listProperties(Property p, String lang)
ResourceThe 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.
listProperties in interface Resourcepublic StmtIterator listProperties()
ResourceThe 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.
listProperties in interface Resourcepublic Resource addLiteral(Property p, boolean o)
Resourcep with the typed-literal value o
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 using
this.getModel().createTypedLiteral(o).addLiteral in interface Resourcepublic Resource addLiteral(Property p, long o)
Resourcep with the typed-literal value o
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 using
this.getModel().createTypedLiteral(o).addLiteral in interface Resourcepublic Resource addLiteral(Property p, char o)
Resourcep with the typed-literal value o
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 using
this.getModel().createTypedLiteral(o).addLiteral in interface Resourcepublic Resource addLiteral(Property p, double o)
Resourcep with the typed-literal value o
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 using
this.getModel().createTypedLiteral(o).addLiteral in interface Resourcepublic Resource addLiteral(Property p, float o)
Resourcep with the typed-literal value o
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 using
this.getModel().createTypedLiteral(o).addLiteral in interface Resourcepublic Resource addProperty(Property p, String o)
ResourceA 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.
addProperty in interface Resourcep - The property to be added.o - The value of the property to be added.public Resource addProperty(Property p, String o, String l)
ResourceA 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.
addProperty in interface Resourcep - The property to be added.o - The value of the property to be added.l - the language of the propertypublic Resource addProperty(Property p, String lexicalForm, RDFDatatype datatype)
ResourceA 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.
addProperty in interface Resourcep - The property to be added.lexicalForm - The lexical form of the literaldatatype - The datatypepublic Resource addLiteral(Property p, Object o)
Resourcep with the typed-literal value o
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 using
this.getModel().createTypedLiteral(o).addLiteral in interface Resourcepublic Resource addLiteral(Property p, Literal o)
Resourcep with the pre-constructed Literal value
o 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.addLiteral in interface Resourcepublic Resource addProperty(Property p, RDFNode o)
ResourceA 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.
addProperty in interface Resourcep - The property to be added.o - The value of the property to be added.public boolean hasProperty(Property p)
ResourcehasProperty in interface Resourcep - The property sought.public boolean hasLiteral(Property p, boolean o)
Resourceo for
property p. o is interpreted as
a typed literal with the appropriate RDF type.hasLiteral in interface Resourcepublic boolean hasLiteral(Property p, long o)
Resourceo for
property p. o is interpreted as
a typed literal with the appropriate RDF type.hasLiteral in interface Resourcepublic boolean hasLiteral(Property p, char o)
Resourceo for
property p. o is interpreted as
a typed literal with the appropriate RDF type.hasLiteral in interface Resourcepublic boolean hasLiteral(Property p, double o)
Resourceo for
property p. o is interpreted as
a typed literal with the appropriate RDF type.hasLiteral in interface Resourcepublic boolean hasLiteral(Property p, float o)
Resourceo for
property p. o is interpreted as
a typed literal with the appropriate RDF type.hasLiteral in interface Resourcepublic boolean hasProperty(Property p, String o)
ResourcehasProperty in interface Resourcep - The property sought.o - The value of the property sought.public boolean hasProperty(Property p, String o, String l)
ResourcehasProperty in interface Resourcep - The property sought.o - The value of the property sought.l - The language of the property sought.public boolean hasLiteral(Property p, Object o)
Resourceo for
property p. o is interpreted as
a typed literal with the appropriate RDF type.hasLiteral in interface Resourcepublic boolean hasProperty(Property p, RDFNode o)
ResourcehasProperty in interface Resourcep - The property sought.o - The value of the property sought.public Resource removeProperties()
ResourceremoveProperties in interface Resourcepublic Resource removeAll(Property p)
Resourcep for this resource
from its associated model.public Resource begin()
Resourcepublic Resource abort()
Resourcepublic Resource commit()
Resourcepublic Model getModel()
RDFNodepublic Resource getPropertyResourceValue(Property p)
ResourcegetPropertyResourceValue in interface ResourceLicenced under the Apache License, Version 2.0