org.openrdf.sesame.sail.query
Class GraphPattern

java.lang.Object
  extended byorg.openrdf.sesame.sail.query.GraphPattern
All Implemented Interfaces:
PathExpression

public class GraphPattern
extends Object
implements PathExpression

A pattern consisting of a set of path expressions and boolean constraints on the values in the path expressions, and zero or more optional child graph patterns.

Author:
Arjohn Kampman

Constructor Summary
GraphPattern()
          Creates a new GraphPattern.
 
Method Summary
 void add(PathExpression pathExpr)
          Adds a path expression to the this object.
 void addAll(Collection triplePatterns)
          Adds a collection of PathExpression objects to this object.
 void addConstraint(BooleanExpr constraint)
          Adds the supplied constraint to the set of constraints for this graph pattern.
 void addOptional(GraphPattern optionalGP)
          Adds an optional child graph pattern to this graph pattern.
 void clear()
          Clears the internal state of this object.
 boolean findFirst(RdfSource rdfSource)
           
 boolean findNext(RdfSource rdfSource)
           
 List getConjunctiveConstraints()
          Gets a list of conjunctive constraints.
 List getExpressions()
           
 void getLocalVariables(Collection variables)
          Gets all variables that are used in the path expressions of this GraphPattern.
 List getOptionals()
          Gets a list of optional child graph patterns.
 List getPathExpressions()
          Gets a list of path expressions contained in this object.
 List getPathExpressionsRecursively()
          Gets a list of path expressions contained in this object and all of its optional child graph patterns recursively.
 BooleanExpr getRootConstraint()
          Gets the constraints on this graph pattern as a single boolean 'root' constraint.
 void getVariables(Collection variables)
          Gets all variables that are used in this PathExpression.
 void initialize(RdfSource rdfSource)
          Initializes the PathExpression.
 boolean selectNext(RdfSource rdfSource)
          Selects the next path matching this path expression.
 void setConstraints(BooleanExpr constraint)
          Sets the constraints for this graph pattern to the supplied constraint, removing any existing constraints.
 void setConstraints(List constraints)
          Sets the constraints for this graph pattern to the supplied constraints, removing any existing constraints.
 void setExpressions(List expressions)
           
 void setOptionals(Collection optionals)
          Sets the optional child graph patterns for this object to the supplied set.
 void setPathExpressions(List pathExpressions)
          Sets the list of path expressions for this object.
 String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GraphPattern

public GraphPattern()
Creates a new GraphPattern.

Method Detail

addAll

public void addAll(Collection triplePatterns)
Adds a collection of PathExpression objects to this object.


add

public void add(PathExpression pathExpr)
Adds a path expression to the this object.


getPathExpressions

public List getPathExpressions()
Gets a list of path expressions contained in this object.

Returns:
An unmodifiable List of PathExpression objects.

setPathExpressions

public void setPathExpressions(List pathExpressions)
Sets the list of path expressions for this object.


getPathExpressionsRecursively

public List getPathExpressionsRecursively()
Gets a list of path expressions contained in this object and all of its optional child graph patterns recursively.

Returns:
An unmodifiable List of PathExpression objects.

getRootConstraint

public BooleanExpr getRootConstraint()
Gets the constraints on this graph pattern as a single boolean 'root' constraint. Separate constraints are joined using AND operators to create the root constraint.

Returns:
A BooleanExpr object representing all boolean constraints, or null if the graph pattern doesn't have any constraints.
See Also:
getConjunctiveConstraints()

getConjunctiveConstraints

public List getConjunctiveConstraints()
Gets a list of conjunctive constraints. Any constraints that have an AND operator as their root have been split (recursively) before being added to the list. If the graph pattern doesn't have any constraints, an empty list will be returned.

Returns:
An unmodifiableList containing BooleanExpr objects that, when applied conjunctively, result in the same constraint as the root constraint.
See Also:
getRootConstraint()

setConstraints

public void setConstraints(BooleanExpr constraint)
Sets the constraints for this graph pattern to the supplied constraint, removing any existing constraints.

Parameters:
constraint - The new constraint(s) for the graph pattern.

setConstraints

public void setConstraints(List constraints)
Sets the constraints for this graph pattern to the supplied constraints, removing any existing constraints.

Parameters:
constraints - The new constraints for the graph pattern.

addConstraint

public void addConstraint(BooleanExpr constraint)
Adds the supplied constraint to the set of constraints for this graph pattern. Constraints that have an AND operator as their root are split into separate conjunctively constraints (recursively) before being added to the list.

Parameters:
constraint - A new constraint.

addOptional

public void addOptional(GraphPattern optionalGP)
Adds an optional child graph pattern to this graph pattern.


getOptionals

public List getOptionals()
Gets a list of optional child graph patterns.

Returns:
An unmodifiable List of GraphPattern objects.

setOptionals

public void setOptionals(Collection optionals)
Sets the optional child graph patterns for this object to the supplied set.


getExpressions

public List getExpressions()

setExpressions

public void setExpressions(List expressions)

findFirst

public boolean findFirst(RdfSource rdfSource)
                  throws SailQueryException
Throws:
SailQueryException

findNext

public boolean findNext(RdfSource rdfSource)
                 throws SailQueryException
Throws:
SailQueryException

initialize

public void initialize(RdfSource rdfSource)
Description copied from interface: PathExpression
Initializes the PathExpression. After a call to this method, the path expression should be able to select all matching path expressions when selectNext is called.

Specified by:
initialize in interface PathExpression

selectNext

public boolean selectNext(RdfSource rdfSource)
                   throws SailQueryException
Description copied from interface: PathExpression
Selects the next path matching this path expression. Any variables in this path expression should be instantiated after a successful call to this method. When no more matching paths could be found, any bound variables should be uninstantiated.

Specified by:
selectNext in interface PathExpression
Returns:
true if a next path has been found, false if no more paths could be found.
Throws:
SailQueryException

clear

public void clear()
Clears the internal state of this object.

Specified by:
clear in interface PathExpression

getLocalVariables

public void getLocalVariables(Collection variables)
Gets all variables that are used in the path expressions of this GraphPattern. This does not include the variables that are used in any optional child graph patterns.


getVariables

public void getVariables(Collection variables)
Description copied from interface: PathExpression
Gets all variables that are used in this PathExpression.

Specified by:
getVariables in interface PathExpression
Parameters:
variables - A Collection to add the Var objects to.

toString

public String toString()


Copyright © 2002-2006 Aduna BV, GNU LGPL License applies.