org.jrdf.graph.global.molecule
Class MoleculeImpl

java.lang.Object
  extended by org.jrdf.graph.global.molecule.MoleculeImpl
All Implemented Interfaces:
Molecule

public class MoleculeImpl
extends Object
implements Molecule


Constructor Summary
MoleculeImpl(Set<Triple> newTriples, TripleComparator newComparator)
           
MoleculeImpl(TripleComparator newComparator)
           
 
Method Summary
 Molecule add(Set<Triple> set)
          Adds a set of triples to this molecule.
 Molecule add(Triple triple)
          Adds the given triple to the molecule.
 boolean contains(SubjectNode subject, PredicateNode predicate, ObjectNode object)
          Checks to see if the given triple exists within the molecule.
 boolean contains(Triple triple)
          Checks to see if the given triple exists within the molecule.
 boolean equals(Object obj)
           
 Triple getHeadTriple()
          Returns the head triple of the molecule.
 LinkedHashSet<Triple> getTailTriples()
           
 SortedSet<Triple> getTriples()
          Returns all triples in the molecule.
 int hashCode()
           
 Iterator<Triple> iterator()
          Returns an iterator for the set of triples which make up this molecule.
 Molecule remove(Triple triple)
          Removes a triple from the molecule.
 int size()
          Number of triples contained in the molecule.
 Iterator<Triple> tailTriples()
          An iterator that contains tail triples i.e. all triples except head triple.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MoleculeImpl

public MoleculeImpl(TripleComparator newComparator)

MoleculeImpl

public MoleculeImpl(Set<Triple> newTriples,
                    TripleComparator newComparator)
Method Detail

getHeadTriple

public Triple getHeadTriple()
Description copied from interface: Molecule
Returns the head triple of the molecule.

Specified by:
getHeadTriple in interface Molecule
Returns:
the head triple of the molecule.

remove

public Molecule remove(Triple triple)
Description copied from interface: Molecule
Removes a triple from the molecule.

Specified by:
remove in interface Molecule
Parameters:
triple - the triple to remove.
Returns:
a new Molecule that contains all triples except the one removed.

contains

public boolean contains(SubjectNode subject,
                        PredicateNode predicate,
                        ObjectNode object)
Description copied from interface: Molecule
Checks to see if the given triple exists within the molecule.

Specified by:
contains in interface Molecule
Parameters:
subject - the subject to search for - does not currently support ANY_SUBJECT.
predicate - the predicate to search for - does not currently support ANY_PREDICATE.
object - the object to search for - does not currently support ANY_OBJECT.
Returns:
true if found.

contains

public boolean contains(Triple triple)
Description copied from interface: Molecule
Checks to see if the given triple exists within the molecule.

Specified by:
contains in interface Molecule
Parameters:
triple - the triple to search for - does not currently support ANY_SUBJECT, etc.
Returns:
true if found.

iterator

public Iterator<Triple> iterator()
Description copied from interface: Molecule
Returns an iterator for the set of triples which make up this molecule.

Specified by:
iterator in interface Molecule
Returns:
all the triples in the molecule.

getTriples

public SortedSet<Triple> getTriples()
Description copied from interface: Molecule
Returns all triples in the molecule.

Specified by:
getTriples in interface Molecule
Returns:
all triples in the molecule.

tailTriples

public Iterator<Triple> tailTriples()
Description copied from interface: Molecule
An iterator that contains tail triples i.e. all triples except head triple.

Specified by:
tailTriples in interface Molecule
Returns:
the iterator of tail triples.

getTailTriples

public LinkedHashSet<Triple> getTailTriples()

add

public Molecule add(Triple triple)
Description copied from interface: Molecule
Adds the given triple to the molecule.

Specified by:
add in interface Molecule
Parameters:
triple - the triple to add.
Returns:
a new molecule based on the current one plus the new triple.

add

public Molecule add(Set<Triple> set)
Description copied from interface: Molecule
Adds a set of triples to this molecule.

Specified by:
add in interface Molecule
Parameters:
set - the set of triples.
Returns:
a new molecule based on the current one plus the new triples.

size

public int size()
Description copied from interface: Molecule
Number of triples contained in the molecule.

Specified by:
size in interface Molecule
Returns:
the number of triples contains in the molecule.

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object