org.ontonym.logan
Class LoganGraphSet

java.lang.Object
  extended by de.fuberlin.wiwiss.ng4j.impl.NamedGraphSetIterable
      extended by de.fuberlin.wiwiss.ng4j.impl.NamedGraphSetIO
          extended by org.ontonym.logan.LoganGraphSet
All Implemented Interfaces:
NamedGraphSet, Iterable<NamedGraph>

public class LoganGraphSet
extends NamedGraphSetIO

A NamedGraphSet implementation backed by a Jess-based quad store. Can be extended to add additional functionality if desired.

Author:
Graeme Stevenson (graeme@ontonym.org)

Constructor Summary
LoganGraphSet()
          Creates a new LoganGraphSet.
LoganGraphSet(File... some_rules)
          Creates a new LoganGraphSet and loads a set of rules into the underlying Jess engine.
LoganGraphSet(String... some_rules)
          Creates a new LoganGraphSet and loads a set of rule files into the underlying Jess engine.
 
Method Summary
 void addGraph(NamedGraph a_graph)
          Adds a NamedGraph to the graph set.
 void addQuad(Quad a_quad)
          Adds a Quad to the graph set.
 Graph asJenaGraph(Node a_defaultGraph)
          Presents a view of the entire graph set as a single Jena Graph, with a specified graph for adding new triples.
 NamedGraphModel asJenaModel(String a_defautGraph)
          View this graph set as a NamedGraphModel.
 void clear()
          Removes all graphs (and therefore statements) from this graph set.
 void close()
          The close operation has no effect.
 boolean containsGraph(Node a_graphNode)
          Checks to see if the graph set contains a graph with a given Node identifier.
 boolean containsGraph(String a_graphNameURI)
          Checks to see if the graph set contains a graph with a given URI identifier.
 boolean containsQuad(Quad a_pattern)
          Checks if a given Quad pattern exists in the graph set.
 long countGraphs()
          Counts the number of graphs in the model.
 int countQuads()
          Counts the number of quads in the model.
 NamedGraph createGraph(Node a_graphNode)
          Creates a new graph using the given Node as an identifier.
 NamedGraph createGraph(String a_graphNameURI)
          Creates a new graph using the given identifier.
 Iterator<Quad> findQuads(Node a_graphName, Node a_subject, Node a_predicate, Node an_object)
          Creates an iterator over a set of quads matching the specified pattern.
 Iterator<Quad> findQuads(Quad a_pattern)
          Creates an iterator over a set of quads matching the specified pattern.
 NamedGraph getGraph(Node a_graphNode)
          Returns the graph identified by the given node if it exists.
 NamedGraph getGraph(String a_graphNameURI)
          Returns the graph identified by the given URI identifier if it exists.
 boolean isEmpty()
          Whether the graph set is empty.
 Iterator<NamedGraph> listGraphs()
          Lists all the named graphs in this model.
 void removeGraph(Node a_graphNode)
          Removes a graph from the model.
 void removeGraph(String a_graphNameURI)
          Removes a graph from the model.
 void removeQuad(Quad a_pattern)
          Removes any quads from the model that match a Quad pattern.
 
Methods inherited from class de.fuberlin.wiwiss.ng4j.impl.NamedGraphSetIO
read, read, read, write, write
 
Methods inherited from class de.fuberlin.wiwiss.ng4j.impl.NamedGraphSetIterable
iterator
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.lang.Iterable
iterator
 

Constructor Detail

LoganGraphSet

public LoganGraphSet()
Creates a new LoganGraphSet.


LoganGraphSet

public LoganGraphSet(File... some_rules)
Creates a new LoganGraphSet and loads a set of rules into the underlying Jess engine.

Parameters:
some_rules - the files containing the rules to be loaded into the model.

LoganGraphSet

public LoganGraphSet(String... some_rules)
Creates a new LoganGraphSet and loads a set of rule files into the underlying Jess engine.

Parameters:
some_rules - the files containing the rules to be loaded into the model.
Method Detail

addGraph

public final void addGraph(NamedGraph a_graph)
Adds a NamedGraph to the graph set.

Parameters:
a_graph - the NamedGraph to add to the graph set.

addQuad

public final void addQuad(Quad a_quad)
Adds a Quad to the graph set.

Parameters:
a_quad - the Quad to add to the graph set.

asJenaGraph

public final Graph asJenaGraph(Node a_defaultGraph)
Presents a view of the entire graph set as a single Jena Graph, with a specified graph for adding new triples. If null, the graph name urn:default is used.

Parameters:
a_defaultGraph - the default graph for adding new triples.
Returns:
a single model view over the graph set.

asJenaModel

public final NamedGraphModel asJenaModel(String a_defautGraph)
View this graph set as a NamedGraphModel.

Parameters:
a_defautGraph - the default graph for adding new triples.
Returns:
this graph set as a named graph model.

clear

public final void clear()
Removes all graphs (and therefore statements) from this graph set.


close

public final void close()
The close operation has no effect.


containsGraph

public final boolean containsGraph(Node a_graphNode)
Checks to see if the graph set contains a graph with a given Node identifier.

Parameters:
a_graphNode - the node identifier for the graph of interest.
Returns:
true if the graph set contains a graph with the same identifier as the parameter, false otherwise.

containsGraph

public final boolean containsGraph(String a_graphNameURI)
Checks to see if the graph set contains a graph with a given URI identifier.

Parameters:
a_graphNameURI - the node identifier for the graph of interest.
Returns:
true if the graph set contains a graph with the same identifier as the parameter, false otherwise.

containsQuad

public final boolean containsQuad(Quad a_pattern)
Checks if a given Quad pattern exists in the graph set.

Parameters:
a_pattern - the pattern of quads we are looking for.
Returns:
true if at least one quad in the model matching the pattern exists, false otherwise.

countGraphs

public final long countGraphs()
Counts the number of graphs in the model.

Returns:
the number of graphs in the model.

countQuads

public final int countQuads()
Counts the number of quads in the model.

Returns:
the number of quads in the model.

createGraph

public final NamedGraph createGraph(Node a_graphNode)
Creates a new graph using the given Node as an identifier. If the graph already exists, all the statements it contains will be removed before the new graph is created.

Parameters:
a_graphNode - the node to use for the new graph.
Returns:
the new graph identified by the a_graphNode parameter.

createGraph

public final NamedGraph createGraph(String a_graphNameURI)
Creates a new graph using the given identifier. If the graph already exists, all the statements it contains will be removed.

Parameters:
a_graphNameURI - the identifier to use for the new graph.
Returns:
the new graph identified by the a_graphNameURI parameter.

findQuads

public final Iterator<Quad> findQuads(Node a_graphName,
                                      Node a_subject,
                                      Node a_predicate,
                                      Node an_object)
Creates an iterator over a set of quads matching the specified pattern.

Parameters:
a_graphName - the graph component of the pattern.
a_subject - the subject component of the pattern.
a_predicate - the predicate component of the pattern.
an_object - the object component of the pattern.
Returns:
an iterator over the matching quads.

findQuads

public final Iterator<Quad> findQuads(Quad a_pattern)
Creates an iterator over a set of quads matching the specified pattern.

Parameters:
a_pattern - the quad pattern.
Returns:
an iterator over the matching quads.

getGraph

public final NamedGraph getGraph(Node a_graphNode)
Returns the graph identified by the given node if it exists.

Parameters:
a_graphNode - the node representing the graph we wish to return.
Returns:
the named graph identified by the parameter, or null if it cannot be found.

getGraph

public final NamedGraph getGraph(String a_graphNameURI)
Returns the graph identified by the given URI identifier if it exists.

Parameters:
a_graphNameURI - the identifier of the graph we wish to return.
Returns:
the named graph identified by the parameter, or null if it cannot be found.

isEmpty

public final boolean isEmpty()
Whether the graph set is empty.

Returns:
true if this graph set contains no graphs, false otherwise.

listGraphs

public final Iterator<NamedGraph> listGraphs()
Lists all the named graphs in this model.

Returns:
an iterator over all the named graphs in this model.

removeGraph

public final void removeGraph(Node a_graphNode)
Removes a graph from the model.

Parameters:
a_graphNode - a node representing the graph to remove.

removeGraph

public final void removeGraph(String a_graphNameURI)
Removes a graph from the model.

Parameters:
a_graphNameURI - the identifier of the graph to remove.

removeQuad

public final void removeQuad(Quad a_pattern)
Removes any quads from the model that match a Quad pattern.

Parameters:
a_pattern - the quad pattern we wish to remove from the model.


Copyright © 2010 Graeme Stevenson.