org.jrdf.graph.local
Class AbstractResource

java.lang.Object
  extended by org.jrdf.graph.local.AbstractResource
All Implemented Interfaces:
Serializable, BlankNode, LocalizedNode, Node, ObjectNode, PredicateNode, Resource, SubjectNode, TypedNodeVisitable, URIReference
Direct Known Subclasses:
BlankNodeResourceImpl, URIReferenceResourceImpl

public abstract class AbstractResource
extends Object
implements Resource, LocalizedNode

See Also:
Serialized Form

Constructor Summary
protected AbstractResource()
           
  AbstractResource(ReadWriteGraph newGraph, GraphValueFactory newValueFactory, LocalizedNode newNode)
           
 
Method Summary
 void addValue(PredicateNode predicate, ObjectNode object)
          Add a new triple with this as the subject, with the given predicate and object.
 void addValue(URI predicate, Object object)
          Add a new triple with this as the subject, with the given predicate and object.
 void addValue(URI predicate, Resource object)
          Add a new triple with this as the subject, with the given predicate and object.
 void addValue(URI predicate, String lexicalValue)
          Add a new triple with this as the subject, with the given predicate and object.
 void addValue(URI predicate, String lexicalValue, String language)
          Add a new triple with this as the subject, with the given predicate and object.
 void addValue(URI predicate, String lexicalValue, URI dataType)
          Add a new triple with this as the subject, with the given predicate and object.
 void addValue(URI predicate, URI object)
          Add a new triple with this as the subject, with the given predicate and object.
 Triple asTriple(PredicateNode predicate, ObjectNode object)
           
 Triple asTriple(URI predicate, Object object)
           
 Triple asTriple(URI predicate, Resource object)
           
 Triple asTriple(URI predicate, String lexicalValue)
           
 Triple asTriple(URI predicate, String lexicalValue, String language)
           
 Triple asTriple(URI predicate, String lexicalValue, URI dataType)
           
 Triple asTriple(URI predicate, URI object)
           
 boolean containsTriple(PredicateNode predicate, ObjectNode object)
           
 Long getId()
          Retrieves an internal identifier for a node.
 ClosableIterator<ObjectNode> getObjects(PredicateNode predicate)
          With this as the subject and using the given predicate return all the objects.
 ClosableIterator<ObjectNode> getObjects(URI predicate)
           
 ClosableIterator<SubjectNode> getSubjects(PredicateNode predicate)
          With this as the object and using the given predicate return all the subjects.
 ClosableIterator<SubjectNode> getSubjects(URI predicate)
           
 void removeSubject(SubjectNode subject, PredicateNode predicate)
          Remove the triple with this as the object, the given subject and predicate.
 void removeSubject(URI subject, URI predicate)
           
 void removeValue(PredicateNode predicate, ObjectNode object)
          Remove the triple with this as the subject, the given predicate and object.
 void removeValue(URI predicate, Object object)
           
 void removeValue(URI predicate, Resource object)
           
 void removeValue(URI predicate, String lexicalValue)
           
 void removeValue(URI predicate, String lexicalValue, String language)
           
 void removeValue(URI predicate, String lexicalValue, URI dataType)
           
 void removeValue(URI predicate, URI object)
           
 void removeValues(PredicateNode predicate)
          Remove all the triples with this as the subject and the given predicate.
 void removeValues(URI predicate)
           
 void setValue(PredicateNode predicate, ObjectNode object)
          Remove any other triples with this as the subject, the given predicate and any object and add a new triple with this as the subject and the given predicate and object.
 void setValue(URI predicate, Object object)
          Removes any other triples with this as the subject, the given predicate and any object and add a new triple with this as the subject and the given predicate and object.
 void setValue(URI predicate, Resource object)
          Removes any other triples with this as the subject, the given predicate and any object and add a new triple with this as the subject and the given predicate and object.
 void setValue(URI predicate, String lexicalValue)
          Removes any other triples with this as the subject, the given predicate and any object and add a new triple with this as the subject and the given predicate and object.
 void setValue(URI predicate, String lexicalValue, String language)
          Removes any other triples with this as the subject, the given predicate and any object and add a new triple with this as the subject and the given predicate and object.
 void setValue(URI predicate, String lexicalValue, URI dataType)
          Removes any other triples with this as the subject, the given predicate and any object and add a new triple with this as the subject and the given predicate and object.
 void setValue(URI predicate, URI object)
          Removes any other triples with this as the subject, the given predicate and any object and add a new triple with this as the subject and the given predicate and object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jrdf.graph.Resource
getUnderlyingNode, isURIReference
 
Methods inherited from interface org.jrdf.graph.URIReference
equals, getURI, hashCode
 
Methods inherited from interface org.jrdf.graph.BlankNode
equals, hashCode
 
Methods inherited from interface org.jrdf.graph.TypedNodeVisitable
accept
 

Constructor Detail

AbstractResource

protected AbstractResource()

AbstractResource

public AbstractResource(ReadWriteGraph newGraph,
                        GraphValueFactory newValueFactory,
                        LocalizedNode newNode)
Method Detail

getId

public Long getId()
Description copied from interface: LocalizedNode
Retrieves an internal identifier for a node.

Specified by:
getId in interface LocalizedNode
Returns:
A numeric identifier for a node.

addValue

public void addValue(PredicateNode predicate,
                     ObjectNode object)
              throws GraphException
Description copied from interface: Resource
Add a new triple with this as the subject, with the given predicate and object.

Specified by:
addValue in interface Resource
Parameters:
predicate - the existing predicate in the graph to use to create the triple.
object - the existing object in the graph to use to create the triple.
Throws:
GraphException - if the predicate or object do not exist in the graph.

addValue

public void addValue(URI predicate,
                     URI object)
              throws GraphException
Description copied from interface: Resource
Add a new triple with this as the subject, with the given predicate and object.

Specified by:
addValue in interface Resource
Parameters:
predicate - a new or existing predicate to use to create the triple.
object - a new or existing object to use to create the triple.
Throws:
GraphException - if there was an error adding the triple (for example localising the nodes).

addValue

public void addValue(URI predicate,
                     String lexicalValue)
              throws GraphException
Description copied from interface: Resource
Add a new triple with this as the subject, with the given predicate and object. The last parameter is equivalent to calling GraphValueFactory.createLiteral(String)

Specified by:
addValue in interface Resource
Parameters:
predicate - a new or existing predicate to use to create the triple.
lexicalValue - a new or existing literal value to use to create the triple.
Throws:
GraphException - if there was an error adding the triple (for example localising the nodes).

addValue

public void addValue(URI predicate,
                     Resource object)
              throws GraphException
Description copied from interface: Resource
Add a new triple with this as the subject, with the given predicate and object.

Specified by:
addValue in interface Resource
Parameters:
predicate - a new or existing predicate to use to create the triple.
object - an existing resource from the graph used to create the triple.
Throws:
GraphException - if there was an error adding the triple (for example localising the nodes) or the Resource was not from this Graph.

addValue

public void addValue(URI predicate,
                     Object object)
              throws GraphException
Description copied from interface: Resource
Add a new triple with this as the subject, with the given predicate and object. The last parameter is equivalent to calling GraphValueFactory.createLiteral(Object)

Specified by:
addValue in interface Resource
Parameters:
predicate - a new or existing predicate to use to create the triple.
object - a new or existing object to use to create the triple.
Throws:
GraphException - if there was an error adding the triple (for example localising the nodes).

addValue

public void addValue(URI predicate,
                     String lexicalValue,
                     String language)
              throws GraphException
Description copied from interface: Resource
Add a new triple with this as the subject, with the given predicate and object. The last two parameters are equivalent to calling GraphValueFactory.createLiteral(String, String)

Specified by:
addValue in interface Resource
Parameters:
predicate - a new or existing predicate to use to create the triple.
lexicalValue - a new or existing literal value to use to create the triple.
language - the language used to create the literal.
Throws:
GraphException - if there was an error adding the triple (for example localising the nodes).

addValue

public void addValue(URI predicate,
                     String lexicalValue,
                     URI dataType)
              throws GraphException
Description copied from interface: Resource
Add a new triple with this as the subject, with the given predicate and object. The last parameter is equivalent to calling GraphValueFactory.createLiteral(String, URI)

Specified by:
addValue in interface Resource
Parameters:
predicate - a new or existing predicate to use to create the triple.
lexicalValue - a new or existing literal value to use to create the triple.
dataType - the datatype URI used to create the literal.
Throws:
GraphException - if there was an error adding the triple (for example localising the nodes).

setValue

public void setValue(PredicateNode predicate,
                     ObjectNode object)
              throws GraphException
Description copied from interface: Resource
Remove any other triples with this as the subject, the given predicate and any object and add a new triple with this as the subject and the given predicate and object. This means that multiple object values will be replaced by a single object value.

Specified by:
setValue in interface Resource
Parameters:
predicate - the existing predicate in the graph to set.
object - the existing object in the graph to set.
Throws:
GraphException - if the predicate or object do not exist in the graph.

setValue

public void setValue(URI predicate,
                     URI object)
              throws GraphException
Description copied from interface: Resource
Removes any other triples with this as the subject, the given predicate and any object and add a new triple with this as the subject and the given predicate and object. This means that multiple object values will be replaced by a single object value.

Specified by:
setValue in interface Resource
Parameters:
predicate - the existing predicate in the graph to set.
object - a new or existing object to use to create the triple.
Throws:
GraphException - if the predicate or object do not exist in the graph.

setValue

public void setValue(URI predicate,
                     String lexicalValue)
              throws GraphException
Description copied from interface: Resource
Removes any other triples with this as the subject, the given predicate and any object and add a new triple with this as the subject and the given predicate and object. This means that multiple object values will be replaced by a single object value.

Specified by:
setValue in interface Resource
Parameters:
predicate - a new or existing predicate to set.
lexicalValue - a new or existing literal value to use to create the triple.
Throws:
GraphException - if there was an error adding the triple (for example localising the nodes).

setValue

public void setValue(URI predicate,
                     Resource object)
              throws GraphException
Description copied from interface: Resource
Removes any other triples with this as the subject, the given predicate and any object and add a new triple with this as the subject and the given predicate and object. This means that multiple object values will be replaced by a single object value.

Specified by:
setValue in interface Resource
Parameters:
predicate - a new or existing predicate to set.
object - an existing resource from the graph to set.
Throws:
GraphException - if there was an error adding the triple (for example localising the nodes) or the Resource was not from this Graph.

setValue

public void setValue(URI predicate,
                     Object object)
              throws GraphException
Description copied from interface: Resource
Removes any other triples with this as the subject, the given predicate and any object and add a new triple with this as the subject and the given predicate and object. This means that multiple object values will be replaced by a single object value.

Specified by:
setValue in interface Resource
Parameters:
predicate - a new or existing predicate to set.
object - a new or existing object to set.
Throws:
GraphException - if there was an error adding the triple (for example localising the nodes).

setValue

public void setValue(URI predicate,
                     String lexicalValue,
                     String language)
              throws GraphException
Description copied from interface: Resource
Removes any other triples with this as the subject, the given predicate and any object and add a new triple with this as the subject and the given predicate and object. This means that multiple object values will be replaced by a single object value.

Specified by:
setValue in interface Resource
Parameters:
predicate - a new or existing predicate to set.
lexicalValue - a new or existing literal value to use to create the triple.
language - the language used to create the literal.
Throws:
GraphException - if there was an error adding the triple (for example localising the nodes).

setValue

public void setValue(URI predicate,
                     String lexicalValue,
                     URI dataType)
              throws GraphException
Description copied from interface: Resource
Removes any other triples with this as the subject, the given predicate and any object and add a new triple with this as the subject and the given predicate and object. This means that multiple object values will be replaced by a single object value.

Specified by:
setValue in interface Resource
Parameters:
predicate - a new or existing predicate to set.
lexicalValue - a new or existing literal value to use to create the triple.
dataType - the datatype URI used to create the literal.
Throws:
GraphException - if there was an error adding the triple (for example localising the nodes).

removeValue

public void removeValue(PredicateNode predicate,
                        ObjectNode object)
                 throws GraphException
Description copied from interface: Resource
Remove the triple with this as the subject, the given predicate and object.

Specified by:
removeValue in interface Resource
Parameters:
predicate - the existing predicate in the graph to remove.
object - the existing object in the graph to remove.
Throws:
GraphException - if the predicate or object does not exist in the graph.

removeValue

public void removeValue(URI predicate,
                        URI object)
                 throws GraphException
Specified by:
removeValue in interface Resource
Throws:
GraphException

removeValue

public void removeValue(URI predicate,
                        String lexicalValue)
                 throws GraphException
Specified by:
removeValue in interface Resource
Throws:
GraphException

removeValue

public void removeValue(URI predicate,
                        Resource object)
                 throws GraphException
Specified by:
removeValue in interface Resource
Throws:
GraphException

removeValue

public void removeValue(URI predicate,
                        Object object)
                 throws GraphException
Specified by:
removeValue in interface Resource
Throws:
GraphException

removeValue

public void removeValue(URI predicate,
                        String lexicalValue,
                        String language)
                 throws GraphException
Specified by:
removeValue in interface Resource
Throws:
GraphException

removeValue

public void removeValue(URI predicate,
                        String lexicalValue,
                        URI dataType)
                 throws GraphException
Specified by:
removeValue in interface Resource
Throws:
GraphException

removeValues

public void removeValues(PredicateNode predicate)
                  throws GraphException
Description copied from interface: Resource
Remove all the triples with this as the subject and the given predicate.

Specified by:
removeValues in interface Resource
Parameters:
predicate - the existing predicate in the graph.
Throws:
GraphException - if the predicate does not exist in the graph.

removeValues

public void removeValues(URI predicate)
                  throws GraphException
Specified by:
removeValues in interface Resource
Throws:
GraphException

asTriple

public Triple asTriple(PredicateNode predicate,
                       ObjectNode object)
                throws GraphException
Specified by:
asTriple in interface Resource
Throws:
GraphException

asTriple

public Triple asTriple(URI predicate,
                       URI object)
                throws GraphException
Specified by:
asTriple in interface Resource
Throws:
GraphException

asTriple

public Triple asTriple(URI predicate,
                       String lexicalValue)
                throws GraphException
Specified by:
asTriple in interface Resource
Throws:
GraphException

asTriple

public Triple asTriple(URI predicate,
                       Resource object)
                throws GraphException
Specified by:
asTriple in interface Resource
Throws:
GraphException

asTriple

public Triple asTriple(URI predicate,
                       Object object)
                throws GraphException
Specified by:
asTriple in interface Resource
Throws:
GraphException

asTriple

public Triple asTriple(URI predicate,
                       String lexicalValue,
                       String language)
                throws GraphException
Specified by:
asTriple in interface Resource
Throws:
GraphException

asTriple

public Triple asTriple(URI predicate,
                       String lexicalValue,
                       URI dataType)
                throws GraphException
Specified by:
asTriple in interface Resource
Throws:
GraphException

removeSubject

public void removeSubject(SubjectNode subject,
                          PredicateNode predicate)
                   throws GraphException
Description copied from interface: Resource
Remove the triple with this as the object, the given subject and predicate.

Specified by:
removeSubject in interface Resource
Parameters:
subject - the existing subject in the graph to remove.
predicate - the existing predicate in the graph to remove.
Throws:
GraphException - if the subject or predicate do not exist in the graph.

removeSubject

public void removeSubject(URI subject,
                          URI predicate)
                   throws GraphException
Specified by:
removeSubject in interface Resource
Throws:
GraphException

getObjects

public ClosableIterator<ObjectNode> getObjects(PredicateNode predicate)
                                        throws GraphException
Description copied from interface: Resource
With this as the subject and using the given predicate return all the objects.

Specified by:
getObjects in interface Resource
Parameters:
predicate - the existing predicate in the graph to use to find the objects.
Returns:
all the objects in the graph with this resource as the subject and the given predicate.
Throws:
GraphException - if the subject or predicate do not exist in the graph.

getObjects

public ClosableIterator<ObjectNode> getObjects(URI predicate)
                                        throws GraphException
Specified by:
getObjects in interface Resource
Throws:
GraphException

getSubjects

public ClosableIterator<SubjectNode> getSubjects(PredicateNode predicate)
                                          throws GraphException
Description copied from interface: Resource
With this as the object and using the given predicate return all the subjects.

Specified by:
getSubjects in interface Resource
Parameters:
predicate - the existing predicate in the graph to use to find the subjects.
Returns:
all the objects in the graph with this resource as the subject and the given predicate.
Throws:
GraphException - if the subject or predicate do not exist in the graph.

getSubjects

public ClosableIterator<SubjectNode> getSubjects(URI predicate)
                                          throws GraphException
Specified by:
getSubjects in interface Resource
Throws:
GraphException

containsTriple

public boolean containsTriple(PredicateNode predicate,
                              ObjectNode object)
                       throws GraphException
Specified by:
containsTriple in interface Resource
Throws:
GraphException