org.jrdf.graph
Class AbstractTriple

java.lang.Object
  extended by org.jrdf.graph.AbstractTriple
All Implemented Interfaces:
Serializable, Triple
Direct Known Subclasses:
TripleImpl

public class AbstractTriple
extends Object
implements Triple, Serializable

A base implementation of an RDF Triple.

Version:
$Revision: 1804 $
Author:
Andrew Newman
See Also:
Serialized Form

Field Summary
protected  ObjectNode objectNode
          The internal representation of the triple - object node.
protected  PredicateNode predicateNode
          The internal representation of the triple - predicate node.
protected  SubjectNode subjectNode
          The internal representation of the triple - subject node.
 
Constructor Summary
AbstractTriple()
           
 
Method Summary
 boolean equals(Object obj)
          Indicates whether some other object is "equal to" this one.
 ObjectNode getObject()
          Obtains the object of this statement.
 PredicateNode getPredicate()
          Obtains the predicate of this statement.
 SubjectNode getSubject()
          Obtains the subject of this statement.
 int hashCode()
          Returns a hash-code value for this triple.
 boolean isGrounded()
          Returns true if the subject and object nodes are not blank nodes.
 String toString()
          Provide a legible representation of a triple.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

subjectNode

protected SubjectNode subjectNode
The internal representation of the triple - subject node.


predicateNode

protected PredicateNode predicateNode
The internal representation of the triple - predicate node.


objectNode

protected ObjectNode objectNode
The internal representation of the triple - object node.

Constructor Detail

AbstractTriple

public AbstractTriple()
Method Detail

getSubject

public SubjectNode getSubject()
Description copied from interface: Triple
Obtains the subject of this statement.

Specified by:
getSubject in interface Triple
Returns:
an SubjectNode which is either a BlankNode or URIReference

getPredicate

public PredicateNode getPredicate()
Description copied from interface: Triple
Obtains the predicate of this statement.

Specified by:
getPredicate in interface Triple
Returns:
a PredicateNode which is a URIReference

getObject

public ObjectNode getObject()
Description copied from interface: Triple
Obtains the object of this statement.

Specified by:
getObject in interface Triple
Returns:
a ObjectNode which is either a BlankNode, URIReference or Literal

isGrounded

public boolean isGrounded()
Description copied from interface: Triple
Returns true if the subject and object nodes are not blank nodes.

Specified by:
isGrounded in interface Triple
Returns:
true if the subject and object nodes are not blank nodes.

equals

public boolean equals(Object obj)
Indicates whether some other object is "equal to" this one.

A triple is equal to another triple if the subject, predicate and object are all equal.

Specified by:
equals in interface Triple
Overrides:
equals in class Object
Parameters:
obj - the reference object with which to compare.
Returns:
true if this object is the same as the obj argument; false otherwise.

hashCode

public int hashCode()
Returns a hash-code value for this triple. The hash code is based upon XORing all of the components of a triple i.e. the subject, predicate and object.

Specified by:
hashCode in interface Triple
Overrides:
hashCode in class Object
Returns:
a hash-code value for this triple.

toString

public String toString()
Provide a legible representation of a triple.

Currently, square brackets with toString values of the parts of the triple.

Overrides:
toString in class Object
Returns:
the string value of the subject, predicate and object in square brackets.