org.jrdf.graph.global
Interface GlobalizedGraph

All Known Implementing Classes:
AbstractGlobalizedGraph, GlobalizedGraphImpl

public interface GlobalizedGraph

Represents a globalized graph, which maintains molecules. This allows us to better handle blank nodes.


Field Summary
static int OBJECT_INDEX
          Position in the index for OSP.
static int PREDICATE_INDEX
          Position in the index for POS.
static int SUBJECT_INDEX
          Position in the index for SPO.
 
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.
 

Field Detail

SUBJECT_INDEX

static final int SUBJECT_INDEX
Position in the index for SPO.

See Also:
Constant Field Values

PREDICATE_INDEX

static final int PREDICATE_INDEX
Position in the index for POS.

See Also:
Constant Field Values

OBJECT_INDEX

static final int OBJECT_INDEX
Position in the index for OSP.

See Also:
Constant Field Values
Method Detail

contains

boolean contains(SubjectNode subject,
                 PredicateNode predicate,
                 ObjectNode object)
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

boolean contains(Triple triple)
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.

contains

boolean contains(Molecule molecule)
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.

find

ClosableIterator<Molecule> find(SubjectNode subject,
                                PredicateNode predicate,
                                ObjectNode object)
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.

add

void add(Molecule molecule)
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

void remove(Molecule molecule)
            throws GraphException
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

Molecule getMolecule(Triple headTriple)
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.

close

void close()
Closes any open resources.


clear

void clear()
Remove all molecules from the graph.


isEmpty

boolean isEmpty()
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.
Throws:
GraphException - If the statements number of statements in the graph fails to be found.

getNumberOfMolecules

long getNumberOfMolecules()
Returns number of molecules in the graph.

Returns:
the number of molecules in the graph.

getNumberOfTriples

long getNumberOfTriples()
Returns the number of triples in the graph.

Returns:
the number of triples in the graph.

getMoleculeIteratorFactory

MoleculeIteratorFactory getMoleculeIteratorFactory()
Returns a iterator factory for generating the various types of iterators required.

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