com.hp.hpl.mesa.rdf.jena.common
Class ResourceImpl

java.lang.Object
  |
  +--com.hp.hpl.mesa.rdf.jena.common.ResourceImpl
All Implemented Interfaces:
RDFNode, Resource, ResourceI
Direct Known Subclasses:
ContainerImpl, DAMLCommonImpl, PropertyImpl, ResourceImplRDB, StatementImpl

public class ResourceImpl
extends java.lang.Object
implements Resource, ResourceI

An implementation of Resource.

Version:
Release='$Name: $' Revision='$Revision: 1.7 $' Date='$Date: 2002/01/05 11:01:57 $'
Author:
bwm

Constructor Summary
ResourceImpl()
          Creates new ResourceImpl
ResourceImpl(AnonId id)
           
ResourceImpl(AnonId id, Model m)
           
ResourceImpl(Model m)
           
ResourceImpl(Resource r, Model m)
           
ResourceImpl(java.lang.String uri)
           
ResourceImpl(java.lang.String uri, Model m)
           
ResourceImpl(java.lang.String nameSpace, java.lang.String localName)
           
ResourceImpl(java.lang.String nameSpace, java.lang.String localName, Model m)
           
 
Method Summary
 Resource abort()
          Abort the transaction in the associated model.
 Resource addProperty(Property p, boolean o)
          Add a property to this resource.
 Resource addProperty(Property p, char o)
          Add a property to this resource.
 Resource addProperty(Property p, double o)
          Add a property to this resource.
 Resource addProperty(Property p, float o)
          Add a property to this resource.
 Resource addProperty(Property p, long o)
          Add a property to this resource.
 Resource addProperty(Property p, java.lang.Object o)
          Add a property to this resource.
 Resource addProperty(Property p, RDFNode o)
          Add a property to this resource.
 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 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.
 Resource getEmbeddedResource()
          For internal use only
 AnonId getId()
          Returns an a unique identifier for anonymous resources.
 java.lang.String getLocalName()
          Returns the name of this resource within its namespace.
 Model getModel()
          Return the model associated with this resource.
 java.lang.String getNameSpace()
          Returns the namespace associated with this resource.
 Statement getProperty(Property p)
          Get a property value of this resource.
 java.lang.String getURI()
          Return the URI of the resource, or the empty string if it is anonymous.
 int hashCode()
           
 boolean hasProperty(Property p)
          Determine whether this resource has any values for a given property.
 boolean hasProperty(Property p, boolean o)
          Test if this resource has a given property with a given value.
 boolean hasProperty(Property p, char o)
          Test if this resource has a given property with a given value.
 boolean hasProperty(Property p, double o)
          Test if this resource has a given property with a given value.
 boolean hasProperty(Property p, float o)
          Test if this resource has a given property with a given value.
 boolean hasProperty(Property p, long o)
          Test if this resource has a given property with a given value.
 boolean hasProperty(Property p, java.lang.Object o)
          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 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 isAnon()
          Determine whether this resource is anonymous.
 StmtIterator listProperties()
          Return an iterator over all the properties of this resource.
 StmtIterator listProperties(Property p)
          List all the values of the property p.
 Resource port(Model m)
          For internal use only
 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 class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ResourceImpl

public ResourceImpl()
Creates new ResourceImpl

ResourceImpl

public ResourceImpl(java.lang.String uri)

ResourceImpl

public ResourceImpl(java.lang.String nameSpace,
                    java.lang.String localName)

ResourceImpl

public ResourceImpl(Model m)

ResourceImpl

public ResourceImpl(AnonId id)

ResourceImpl

public ResourceImpl(AnonId id,
                    Model m)

ResourceImpl

public ResourceImpl(java.lang.String uri,
                    Model m)

ResourceImpl

public ResourceImpl(Resource r,
                    Model m)

ResourceImpl

public ResourceImpl(java.lang.String nameSpace,
                    java.lang.String localName,
                    Model m)
Method Detail

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.

Specified by:
getId in interface Resource
Following copied from interface: com.hp.hpl.mesa.rdf.jena.model.Resource
Returns:
A unique id for an anonymous resource.
Throws:
RDFException - Generic RDF exception.

getURI

public java.lang.String getURI()
Description copied from interface: Resource
Return the URI of the resource, or the empty string if it is anonymous.
Specified by:
getURI in interface Resource
Following copied from interface: com.hp.hpl.mesa.rdf.jena.model.Resource
Returns:
The URI of the resource, or the empty string if it is anonymous.

getNameSpace

public java.lang.String getNameSpace()
Description copied from interface: Resource
Returns the namespace associated with this resource.
Specified by:
getNameSpace in interface Resource
Following copied from interface: com.hp.hpl.mesa.rdf.jena.model.Resource
Returns:
The namespace for this property.

getLocalName

public java.lang.String getLocalName()
Description copied from interface: Resource
Returns the name of this resource within its namespace.
Specified by:
getLocalName in interface Resource
Following copied from interface: com.hp.hpl.mesa.rdf.jena.model.Resource
Returns:
The name of this property within its namespace.

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.
Specified by:
toString in interface Resource
Overrides:
toString in class java.lang.Object
Following copied from interface: com.hp.hpl.mesa.rdf.jena.model.Resource
Returns:
Return a string representation of the resource. if it is anonymous.

equals

public boolean equals(java.lang.Object o)
Description copied from interface: Resource
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 there Id's are the same. If one resource is anonymous and the other is not, then they are not equal.

Specified by:
equals in interface Resource
Overrides:
equals in class java.lang.Object
Following copied from interface: com.hp.hpl.mesa.rdf.jena.model.Resource
Parameters:
o - The object to be compared.
Returns:
true if and only if both objects are equal

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

isAnon

public boolean isAnon()
Description copied from interface: Resource
Determine whether this resource is anonymous.
Specified by:
isAnon in interface Resource
Following copied from interface: com.hp.hpl.mesa.rdf.jena.model.Resource
Returns:
Return true if and only if this resource is anonymous.

getProperty

public Statement getProperty(Property p)
                      throws RDFException
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, and exception is thrown.

Specified by:
getProperty in interface Resource
Following copied from interface: com.hp.hpl.mesa.rdf.jena.model.Resource
Parameters:
p - The property sought.
Returns:
A statement specifying the property value.
Throws:
RDFException - Generic RDF exception.

listProperties

public StmtIterator listProperties(Property p)
                            throws RDFException
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 interface Resource
Following copied from interface: com.hp.hpl.mesa.rdf.jena.model.Resource
Parameters:
p - The predicate sought.
Returns:
An iterator over the statements.
Throws:
RDFException - Generic RDF exception.

listProperties

public StmtIterator listProperties()
                            throws RDFException
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 interface Resource
Following copied from interface: com.hp.hpl.mesa.rdf.jena.model.Resource
Returns:
An iterator over all the statements about this object.
Throws:
RDFException - Generic RDF exception.

addProperty

public Resource addProperty(Property p,
                            boolean o)
                     throws RDFException
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.

o is converted to a string by calling its toString() method.

Specified by:
addProperty in interface Resource
Following copied from interface: com.hp.hpl.mesa.rdf.jena.model.Resource
Parameters:
p - The property to be added.
o - The value of the property to be added.
Returns:
This resource to allow cascading calls.
Throws:
RDFException - Generic RDF exception.

addProperty

public Resource addProperty(Property p,
                            long o)
                     throws RDFException
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.

o is converted to a string by calling its toString() method.

Specified by:
addProperty in interface Resource
Following copied from interface: com.hp.hpl.mesa.rdf.jena.model.Resource
Parameters:
p - The property to be added.
o - The value of the property to be added.
Returns:
This resource to allow cascading calls.
Throws:
RDFException - Generic RDF exception.

addProperty

public Resource addProperty(Property p,
                            char o)
                     throws RDFException
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.

o is converted to a string by calling its toString() method.

Specified by:
addProperty in interface Resource
Following copied from interface: com.hp.hpl.mesa.rdf.jena.model.Resource
Parameters:
p - The property to be added.
o - The value of the property to be added.
Returns:
This resource to allow cascading calls.
Throws:
RDFException - Generic RDF exception.

addProperty

public Resource addProperty(Property p,
                            float o)
                     throws RDFException
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.

o is converted to a string by calling its toString() method.

Specified by:
addProperty in interface Resource
Following copied from interface: com.hp.hpl.mesa.rdf.jena.model.Resource
Parameters:
p - The property to be added.
o - The value of the property to be added.
Returns:
This resource to allow cascading calls.
Throws:
RDFException - Generic RDF exception.

addProperty

public Resource addProperty(Property p,
                            double o)
                     throws RDFException
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.

o is converted to a string by calling its toString() method.

Specified by:
addProperty in interface Resource
Following copied from interface: com.hp.hpl.mesa.rdf.jena.model.Resource
Parameters:
p - The property to be added.
o - The value of the property to be added.
Returns:
This resource to allow cascading calls.
Throws:
RDFException - Generic RDF exception.

addProperty

public Resource addProperty(Property p,
                            java.lang.String o)
                     throws RDFException
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 interface Resource
Following copied from interface: com.hp.hpl.mesa.rdf.jena.model.Resource
Parameters:
p - The property to be added.
o - The value of the property to be added.
Returns:
This resource to allow cascading calls.
Throws:
RDFException - Generic RDF exception.

addProperty

public Resource addProperty(Property p,
                            java.lang.String o,
                            java.lang.String l)
                     throws RDFException
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 interface Resource
Following copied from interface: com.hp.hpl.mesa.rdf.jena.model.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.
Throws:
RDFException - Generic RDF exception.

addProperty

public Resource addProperty(Property p,
                            java.lang.Object o)
                     throws RDFException
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.

o is converted to a string by calling its toString() method.

Specified by:
addProperty in interface Resource
Following copied from interface: com.hp.hpl.mesa.rdf.jena.model.Resource
Parameters:
p - The property to be added.
o - The value of the property to be added.
Returns:
This resource to allow cascading calls.
Throws:
RDFException - Generic RDF exception.

addProperty

public Resource addProperty(Property p,
                            RDFNode o)
                     throws RDFException
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 interface Resource
Following copied from interface: com.hp.hpl.mesa.rdf.jena.model.Resource
Parameters:
p - The property to be added.
o - The value of the property to be added.
Returns:
This resource to allow cascading calls.
Throws:
RDFException - Generic RDF exception.

hasProperty

public boolean hasProperty(Property p)
                    throws RDFException
Description copied from interface: Resource
Determine whether this resource has any values for a given property.
Specified by:
hasProperty in interface Resource
Following copied from interface: com.hp.hpl.mesa.rdf.jena.model.Resource
Parameters:
p - The property sought.
Returns:
true if and only if this resource has at least one value for the property.
Throws:
RDFException - Generic RDF exception.

hasProperty

public boolean hasProperty(Property p,
                           boolean o)
                    throws RDFException
Description copied from interface: Resource
Test if this resource has a given property with a given value.
Specified by:
hasProperty in interface Resource
Following copied from interface: com.hp.hpl.mesa.rdf.jena.model.Resource
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.
Throws:
RDFException - Generic RDF exception.

hasProperty

public boolean hasProperty(Property p,
                           long o)
                    throws RDFException
Description copied from interface: Resource
Test if this resource has a given property with a given value.
Specified by:
hasProperty in interface Resource
Following copied from interface: com.hp.hpl.mesa.rdf.jena.model.Resource
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.
Throws:
RDFException - Generic RDF exception.

hasProperty

public boolean hasProperty(Property p,
                           char o)
                    throws RDFException
Description copied from interface: Resource
Test if this resource has a given property with a given value.
Specified by:
hasProperty in interface Resource
Following copied from interface: com.hp.hpl.mesa.rdf.jena.model.Resource
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.
Throws:
RDFException - Generic RDF exception.

hasProperty

public boolean hasProperty(Property p,
                           float o)
                    throws RDFException
Description copied from interface: Resource
Test if this resource has a given property with a given value.
Specified by:
hasProperty in interface Resource
Following copied from interface: com.hp.hpl.mesa.rdf.jena.model.Resource
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.
Throws:
RDFException - Generic RDF exception.

hasProperty

public boolean hasProperty(Property p,
                           double o)
                    throws RDFException
Description copied from interface: Resource
Test if this resource has a given property with a given value.
Specified by:
hasProperty in interface Resource
Following copied from interface: com.hp.hpl.mesa.rdf.jena.model.Resource
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.
Throws:
RDFException - Generic RDF exception.

hasProperty

public boolean hasProperty(Property p,
                           java.lang.String o)
                    throws RDFException
Description copied from interface: Resource
Test if this resource has a given property with a given value.
Specified by:
hasProperty in interface Resource
Following copied from interface: com.hp.hpl.mesa.rdf.jena.model.Resource
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.
Throws:
RDFException - Generic RDF exception.

hasProperty

public boolean hasProperty(Property p,
                           java.lang.String o,
                           java.lang.String l)
                    throws RDFException
Description copied from interface: Resource
Test if this resource has a given property with a given value.
Specified by:
hasProperty in interface Resource
Following copied from interface: com.hp.hpl.mesa.rdf.jena.model.Resource
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.
Throws:
RDFException - Generic RDF exception.

hasProperty

public boolean hasProperty(Property p,
                           java.lang.Object o)
                    throws RDFException
Description copied from interface: Resource
Test if this resource has a given property with a given value.
Specified by:
hasProperty in interface Resource
Following copied from interface: com.hp.hpl.mesa.rdf.jena.model.Resource
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.
Throws:
RDFException - Generic RDF exception.

hasProperty

public boolean hasProperty(Property p,
                           RDFNode o)
                    throws RDFException
Description copied from interface: Resource
Test if this resource has a given property with a given value.
Specified by:
hasProperty in interface Resource
Following copied from interface: com.hp.hpl.mesa.rdf.jena.model.Resource
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.
Throws:
RDFException - Generic RDF exception.

removeProperties

public Resource removeProperties()
                          throws RDFException
Description copied from interface: Resource
Delete all the properties for this resource from the associated model.
Specified by:
removeProperties in interface Resource
Following copied from interface: com.hp.hpl.mesa.rdf.jena.model.Resource
Returns:
This resource to permit cascading.
Throws:
RDFException - Generic RDF exception.

begin

public Resource begin()
               throws RDFException
Description copied from interface: Resource
Begin a transaction in the associated model.
Specified by:
begin in interface Resource
Following copied from interface: com.hp.hpl.mesa.rdf.jena.model.Resource
Returns:
This resource to permit cascading.
Throws:
RDFException - Generic RDF exception.

abort

public Resource abort()
               throws RDFException
Description copied from interface: Resource
Abort the transaction in the associated model.
Specified by:
abort in interface Resource
Following copied from interface: com.hp.hpl.mesa.rdf.jena.model.Resource
Returns:
This resource to permit cascading.
Throws:
RDFException - Generic RDF exception.

commit

public Resource commit()
                throws RDFException
Description copied from interface: Resource
Commit the transaction in the associated model.
Specified by:
commit in interface Resource
Following copied from interface: com.hp.hpl.mesa.rdf.jena.model.Resource
Returns:
This resource to permit cascading.
Throws:
RDFException - Generic RDF exception.

port

public Resource port(Model m)
              throws RDFException
Description copied from interface: ResourceI
For internal use only
Specified by:
port in interface ResourceI

getModel

public Model getModel()
Description copied from interface: Resource
Return the model associated with this resource.
Specified by:
getModel in interface Resource
Following copied from interface: com.hp.hpl.mesa.rdf.jena.model.Resource
Returns:
The model associated with this resource.

getEmbeddedResource

public Resource getEmbeddedResource()
Description copied from interface: ResourceI
For internal use only
Specified by:
getEmbeddedResource in interface ResourceI


Copyright © 2001 Hewlett-Packard. All Rights Reserved.