org.jrdf.graph
Class AbstractTripleFactory

java.lang.Object
  extended by org.jrdf.graph.AbstractTripleFactory
All Implemented Interfaces:
TripleFactory

public abstract class AbstractTripleFactory
extends Object
implements TripleFactory

The base implementation of the Triple Factory which adds to a given graph reified statements, containers and collections.

Version:
$Revision: 1880 $
Author:
Paul Gearon, Andrew Newman

Field Summary
protected  GraphElementFactory elementFactory
          The graph element factory.
protected  Graph graph
          The graph that this factory constructs nodes for.
 
Constructor Summary
protected AbstractTripleFactory(Graph newGraph, GraphElementFactory newElementFactory)
           
 
Method Summary
 void addAlternative(SubjectNode subjectNode, Alternative alternative)
          Inserts a alternative using the given subject.
 void addBag(SubjectNode subjectNode, Bag bag)
          Inserts a bag using the given subject.
 void addCollection(SubjectNode firstNode, Collection collection)
          Inserts a collection using the given subject.
 void addSequence(SubjectNode subjectNode, Sequence sequence)
          Inserts a sequence using the given subject.
 Triple addTriple(URI subject, URI predicate, Object object)
          Creates and adds a new triple to the graph.
 Triple addTriple(URI subject, URI predicate, String object)
          Creates and adds a new triple to the graph.
 Triple addTriple(URI subject, URI predicate, String object, String language)
          Creates and adds new triple to the graph.
 Triple addTriple(URI subject, URI predicate, String object, URI dataType)
          Creates and adds new triple to graph.
 Triple addTriple(URI subject, URI predicate, URI object)
          Creates and adds a new triple to the graph.
 Triple createTriple(SubjectNode subject, PredicateNode predicate, ObjectNode object)
          Creates a new triple to be used in the graph.
 void reifyTriple(SubjectNode subjectNode, PredicateNode predicateNode, ObjectNode objectNode, SubjectNode reificationNode)
          Reifies a triple. 4 statements are added with the given subject, predicate and object.
 void reifyTriple(Triple triple, SubjectNode reificationNode)
          Reifies a triple. 4 statements are added with the triple's subject, predicate and object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

graph

protected Graph graph
The graph that this factory constructs nodes for.


elementFactory

protected GraphElementFactory elementFactory
The graph element factory.

Constructor Detail

AbstractTripleFactory

protected AbstractTripleFactory(Graph newGraph,
                                GraphElementFactory newElementFactory)
Method Detail

createTriple

public Triple createTriple(SubjectNode subject,
                           PredicateNode predicate,
                           ObjectNode object)
Description copied from interface: TripleFactory
Creates a new triple to be used in the graph. Does not add it to an associated graph. Use @see Graph#add or #addTriple.

Specified by:
createTriple in interface TripleFactory
Parameters:
subject - The subject of the statement.
predicate - The predicate of the statement.
object - The object of the statement.
Returns:
the newly created triple object.

addTriple

public Triple addTriple(URI subject,
                        URI predicate,
                        URI object)
                 throws GraphElementFactoryException
Description copied from interface: TripleFactory
Creates and adds a new triple to the graph.

Specified by:
addTriple in interface TripleFactory
Parameters:
subject - The subject of the statement.
predicate - The predicate of the statement.
object - The object of the statement.
Returns:
the newly created triple object.
Throws:
GraphElementFactoryException - if it fails to create the given subject, predicate object.

addTriple

public Triple addTriple(URI subject,
                        URI predicate,
                        String object)
                 throws GraphElementFactoryException
Description copied from interface: TripleFactory
Creates and adds a new triple to the graph.

Specified by:
addTriple in interface TripleFactory
Parameters:
subject - The subject of the statement.
predicate - The predicate of the statement.
object - The object of the statement. Creates a literal without a language or datatype with the given lexical value.
Returns:
the newly created triple object.
Throws:
GraphElementFactoryException - if it fails to create the given subject, predicate and object.

addTriple

public Triple addTriple(URI subject,
                        URI predicate,
                        Object object)
                 throws GraphElementFactoryException
Description copied from interface: TripleFactory
Creates and adds a new triple to the graph.

Specified by:
addTriple in interface TripleFactory
Parameters:
subject - The subject of the statement.
predicate - The predicate of the statement.
object - The native value of the object of the statement.
Returns:
the newly created triple object.
Throws:
GraphElementFactoryException - if it fails to create the given subject, predicate and object. The object must have a type registered in the DatatypeFactory.

addTriple

public Triple addTriple(URI subject,
                        URI predicate,
                        String object,
                        String language)
                 throws GraphElementFactoryException
Description copied from interface: TripleFactory
Creates and adds new triple to the graph.

Specified by:
addTriple in interface TripleFactory
Parameters:
subject - The subject of the statement.
predicate - The predicate of the statement.
object - The lexical value of the literal.
language - The language of the object.
Returns:
the newly created triple object.
Throws:
GraphElementFactoryException - if it fails to create the given subject, predicate and object.

addTriple

public Triple addTriple(URI subject,
                        URI predicate,
                        String object,
                        URI dataType)
                 throws GraphElementFactoryException
Description copied from interface: TripleFactory
Creates and adds new triple to graph.

Specified by:
addTriple in interface TripleFactory
Parameters:
subject - The subject of the statement.
predicate - The predicate of the statement.
object - The lexical value of the literal.
dataType - The datatype of the object.
Returns:
the newly created triple object.
Throws:
GraphElementFactoryException - if it fails to create the given subject, predicate and object.

reifyTriple

public void reifyTriple(SubjectNode subjectNode,
                        PredicateNode predicateNode,
                        ObjectNode objectNode,
                        SubjectNode reificationNode)
                 throws TripleFactoryException
Description copied from interface: TripleFactory
Reifies a triple. 4 statements are added with the given subject, predicate and object. These are added as objects to the the reified triple. The triple being reified is not added to the graph.

Specified by:
reifyTriple in interface TripleFactory
Parameters:
subjectNode - the subject of the triple.
predicateNode - the predicate of the triple.
objectNode - the object of the triple.
reificationNode - a node denoting the reified triple.
Throws:
TripleFactoryException - If the resource failed to be added.
AlreadyReifiedException - If there was already a triple URI for the given triple.

reifyTriple

public void reifyTriple(Triple triple,
                        SubjectNode reificationNode)
                 throws TripleFactoryException
Description copied from interface: TripleFactory
Reifies a triple. 4 statements are added with the triple's subject, predicate and object. These are added as objects to the reified triple. The triple being reified is not added to the graph.

Specified by:
reifyTriple in interface TripleFactory
Parameters:
triple - the triple to be reified.
reificationNode - a node denoting the reified triple.
Throws:
TripleFactoryException - If the resource failed to be added, for example already reified.

addAlternative

public void addAlternative(SubjectNode subjectNode,
                           Alternative alternative)
                    throws TripleFactoryException
Description copied from interface: TripleFactory
Inserts a alternative using the given subject. The subject is also the object of a proceeding statement that identifies the container.

Specified by:
addAlternative in interface TripleFactory
Parameters:
subjectNode - the subject node of the triple.
alternative - the alternative to add.
Throws:
TripleFactoryException - If the resources were failed to be added.

addBag

public void addBag(SubjectNode subjectNode,
                   Bag bag)
            throws TripleFactoryException
Description copied from interface: TripleFactory
Inserts a bag using the given subject. The subject is also the object of a proceeding statement that identifies the container.

Specified by:
addBag in interface TripleFactory
Parameters:
subjectNode - the subject node of the triple.
bag - the bag to add.
Throws:
TripleFactoryException - If the resources were failed to be added.

addSequence

public void addSequence(SubjectNode subjectNode,
                        Sequence sequence)
                 throws TripleFactoryException
Description copied from interface: TripleFactory
Inserts a sequence using the given subject. The subject is also the object of a proceeding statement that identifies the container.

Specified by:
addSequence in interface TripleFactory
Parameters:
subjectNode - the subject node of the triple.
sequence - the sequence to add.
Throws:
TripleFactoryException - If the resources were failed to be added.

addCollection

public void addCollection(SubjectNode firstNode,
                          Collection collection)
                   throws TripleFactoryException
Description copied from interface: TripleFactory
Inserts a collection using the given subject. The subject is also the object of a proceeding statement that identifies the collection.

Specified by:
addCollection in interface TripleFactory
Parameters:
firstNode - the subject node of the triple.
collection - the collection to add.
Throws:
TripleFactoryException - If the resources were failed to be added.