org.jrdf.graph.global
Class GlobalizedGraphImpl

java.lang.Object
  extended by org.jrdf.graph.global.AbstractGlobalizedGraph
      extended by org.jrdf.graph.global.GlobalizedGraphImpl
All Implemented Interfaces:
GlobalizedGraph

public class GlobalizedGraphImpl
extends AbstractGlobalizedGraph

In memory implementation of Globalized Graph.

Version:
$Revision: 1317 $
Author:
Imran Khan

Field Summary
 
Fields inherited from class org.jrdf.graph.global.AbstractGlobalizedGraph
indexes, iteratorFactory, tripleComparator
 
Fields inherited from interface org.jrdf.graph.global.GlobalizedGraph
OBJECT_INDEX, PREDICATE_INDEX, SUBJECT_INDEX
 
Constructor Summary
GlobalizedGraphImpl(MoleculeIndex[] newIndexes, MoleculeIteratorFactory newIteratorFactory, TripleComparator newTripleComparator)
          Default constructor.
 
Method Summary
 void add(Molecule molecule)
          Adds the given molecule and its associated triples to the graph.
 void clear()
          Remove all molecules from the graph.
 void close()
          Closes any open resources.
 boolean contains(Molecule molecule)
          Check to see if a given molecule exists - or part thereof.
 boolean contains(SubjectNode subject, PredicateNode predicate, ObjectNode object)
          Check to see if the given triple exists within the graph.
 boolean contains(Triple triple)
          Check to see if the given triple exists within the graph.
 ClosableIterator<Molecule> find(SubjectNode subject, PredicateNode predicate, ObjectNode object)
          Find a triple that may contain wildcards - any subject, any predicate, and any object.
 Molecule getMolecule(Triple headTriple)
          Retrieves the molecule with the given head triple.
 MoleculeIteratorFactory getMoleculeIteratorFactory()
          Returns a iterator factory for generating the various types of iterators required.
 long getNumberOfMolecules()
          Returns number of molecules in the graph.
 long getNumberOfTriples()
          Returns the number of triples in the graph.
 boolean isEmpty()
          Returns true if the graph is empty i.e. the number of triples is 0.
 void remove(Molecule molecule)
          This will find the given molecule and remove it and any statements it contains.
 
Methods inherited from class org.jrdf.graph.global.AbstractGlobalizedGraph
containsValue, findValue, init, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GlobalizedGraphImpl

public GlobalizedGraphImpl(MoleculeIndex[] newIndexes,
                           MoleculeIteratorFactory newIteratorFactory,
                           TripleComparator newTripleComparator)
Default constructor.

Parameters:
newIndexes -
newIteratorFactory -
Method Detail

find

public ClosableIterator<Molecule> find(SubjectNode subject,
                                       PredicateNode predicate,
                                       ObjectNode object)
Description copied from interface: GlobalizedGraph
Find a triple that may contain wildcards - any subject, any predicate, and any object.

Parameters:
subject - The subject to find or AnySubjectNode to indicate any subject.
predicate - The predicate to find or AnyPredicateNode to indicate any predicate.
object - The object to find or AnyObjectNode to indicate any object.
Returns:
an iterator of molecules.

contains

public boolean contains(Molecule molecule)
Description copied from interface: GlobalizedGraph
Check to see if a given molecule exists - or part thereof. So if there are more statements in the molecule it will still match.

Parameters:
molecule - The triple to find.
Returns:
True if the triple is found in the graph, otherwise false.

contains

public boolean contains(SubjectNode subject,
                        PredicateNode predicate,
                        ObjectNode object)
Description copied from interface: GlobalizedGraph
Check to see if the given triple exists within the graph. If it contains blank nodes will only check ones that are not in a molecule.

Parameters:
subject - The subject to find or AnySubjectNode to indicate any subject.
predicate - The predicate to find or AnyPredicateNode to indicate any predicate.
object - The object to find or AnyObjectNode to indicate any object.
Returns:
True if the statement is found in the model, otherwise false.

contains

public boolean contains(Triple triple)
Description copied from interface: GlobalizedGraph
Check to see if the given triple exists within the graph. If it contains blank nodes will only check ones that are not in a molecule.

Parameters:
triple - The triple to find.
Returns:
True if the triple is found in the graph, otherwise false.

add

public void add(Molecule molecule)
Description copied from interface: GlobalizedGraph
Adds the given molecule and its associated triples to the graph. If a molecule already exists new tail triples will be added in place. A molecule with a single grounded node is equivalent to add(subject, predicate, object) or add(triple).

Parameters:
molecule - the molecule to add.

remove

public void remove(Molecule molecule)
            throws GraphException
Description copied from interface: GlobalizedGraph
This will find the given molecule and remove it and any statements it contains. It will first search for the molecules head triple, and then progressively remove the tail triples from the main index. A molecule with a single grounded node is equivalent to remove(subject, predicate, object) or remove(triple).

Parameters:
molecule - the molecule to remove.
Throws:
GraphException

getMolecule

public Molecule getMolecule(Triple headTriple)
Description copied from interface: GlobalizedGraph
Retrieves the molecule with the given head triple. Returns null in case the head triple does not exist.

Parameters:
headTriple - the head triple to use to get the molecule.
Returns:
the moelcule.

clear

public void clear()
Description copied from interface: GlobalizedGraph
Remove all molecules from the graph.


isEmpty

public boolean isEmpty()
Description copied from interface: GlobalizedGraph
Returns true if the graph is empty i.e. the number of triples is 0.

Returns:
true if the graph is empty i.e. the number of triples is 0.

getNumberOfMolecules

public long getNumberOfMolecules()
Description copied from interface: GlobalizedGraph
Returns number of molecules in the graph.

Returns:
the number of molecules in the graph.

getNumberOfTriples

public long getNumberOfTriples()
Description copied from interface: GlobalizedGraph
Returns the number of triples in the graph.

Returns:
the number of triples in the graph.

getMoleculeIteratorFactory

public MoleculeIteratorFactory getMoleculeIteratorFactory()
Description copied from interface: GlobalizedGraph
Returns a iterator factory for generating the various types of iterators required.

Returns:
a iterator factory for generating the various types of iterators required.

close

public void close()
Description copied from interface: GlobalizedGraph
Closes any open resources.