org.openanzo.sqlscribe
Class LogicalOperator

java.lang.Object
  extended by org.openanzo.sqlscribe.LogicalOperator
All Implemented Interfaces:
Constraint

public class LogicalOperator
extends java.lang.Object
implements Constraint

Simple logical operators to be applied on constraints to build more complex constraints.

Author:
Joe Betz

Constructor Summary
LogicalOperator(java.lang.String operation)
          Create a new logical constraint
LogicalOperator(java.lang.String operation, Constraint... constraints)
          Create a new logical constraint
LogicalOperator(java.lang.String operation, java.util.List<Constraint> operands)
          Create a new logical constraint between list of operands
 
Method Summary
 void addOperand(Constraint constraint)
          Add a constraint to the list of constraints to logically join
static LogicalOperator and(Constraint... constraints)
          Create a new AND logical constraint
 java.lang.String getConstraint(java.util.List<java.lang.String> unboundVariables)
          Get the SQL text for this constraint, using any variables from the provided list
 java.util.List<Constraint> getOperands()
          Get the set of operands
 java.util.Set<ITable> listTables()
          Get the set of tables to which this constraint is based
static LogicalOperator or(Constraint... constraints)
          Create a new OR logical constraint
 void writeConstraint(java.lang.StringBuffer buf, java.util.List<java.lang.String> unboundVariables)
          Write the SQL text for this constraint to the provided buffer, using any variables from the provided list
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LogicalOperator

public LogicalOperator(java.lang.String operation,
                       Constraint... constraints)
Create a new logical constraint

Parameters:
operation - Operation text used to logically join to constraints
constraints - array of constraints

LogicalOperator

public LogicalOperator(java.lang.String operation,
                       java.util.List<Constraint> operands)
Create a new logical constraint between list of operands

Parameters:
operation - Operation text used to logically join to constraints
operands - list of constraints to logically join

LogicalOperator

public LogicalOperator(java.lang.String operation)
Create a new logical constraint

Parameters:
operation - Operation text used to logically join to constraints
Method Detail

and

public static LogicalOperator and(Constraint... constraints)
Create a new AND logical constraint

Parameters:
constraints - array of constraints
Returns:
a new AND logical constraint

or

public static LogicalOperator or(Constraint... constraints)
Create a new OR logical constraint

Parameters:
constraints - array of constraints
Returns:
a new OR logical constraint

addOperand

public void addOperand(Constraint constraint)
Add a constraint to the list of constraints to logically join

Parameters:
constraint - to add to operands

getOperands

public java.util.List<Constraint> getOperands()
Get the set of operands

Returns:
the set of operands

getConstraint

public java.lang.String getConstraint(java.util.List<java.lang.String> unboundVariables)
Description copied from interface: Constraint
Get the SQL text for this constraint, using any variables from the provided list

Specified by:
getConstraint in interface Constraint
Parameters:
unboundVariables - set of variables that can be used within constraints
Returns:
the SQL text for this constraint, using any variables from the provided list

writeConstraint

public void writeConstraint(java.lang.StringBuffer buf,
                            java.util.List<java.lang.String> unboundVariables)
Description copied from interface: Constraint
Write the SQL text for this constraint to the provided buffer, using any variables from the provided list

Specified by:
writeConstraint in interface Constraint
Parameters:
buf - StringBuffer to which the SQL text for this constraint is appended
unboundVariables - set of variables that can be used within constraints

listTables

public java.util.Set<ITable> listTables()
Description copied from interface: Constraint
Get the set of tables to which this constraint is based

Specified by:
listTables in interface Constraint
Returns:
the set of tables to which this constraint is based


Copyright © 2007 Cambridge Semantics Inc.. All Rights Reserved.