org.intermine.sql.query
Class Constraint

java.lang.Object
  extended by org.intermine.sql.query.AbstractConstraint
      extended by org.intermine.sql.query.Constraint
All Implemented Interfaces:
SQLStringable

public class Constraint
extends AbstractConstraint

A representation of a normal constraint, comparing two AbstractValue objects.


Field Summary
static int EQ
          An operation for this constraint indicating that left is equal to right.
static int GORNULL
          An operation for this constraint indicating that the left is greater than the right, or the left is null.
protected  AbstractValue left
           
static int LIKE
          An operation for this constraint indicating that left should be pattern-matched against right.
static int LT
          An operation for this constraint indicating that left is less than right.
protected  int operation
           
protected  AbstractValue right
           
 
Fields inherited from class org.intermine.sql.query.AbstractConstraint
BOTH_FALSE, BOTH_TRUE, EQUAL, EXCLUDES, IMPLIED_BY, IMPLIES, INDEPENDENT, LEFT_FALSE, LEFT_FALSE_RIGHT_TRUE, LEFT_TRUE, LEFT_TRUE_RIGHT_FALSE, OPPOSITE, OR, RIGHT_FALSE, RIGHT_TRUE
 
Constructor Summary
Constraint(AbstractValue left, int operation, AbstractValue right)
          Constructor for a Constraint object.
 
Method Summary
 int compare(AbstractConstraint obj, java.util.Map<AbstractTable,AbstractTable> tableMap, java.util.Map<AbstractTable,AbstractTable> reverseTableMap)
          Compare this Constraint with another AbstractConstraint, ignoring aliases in member fields and tables.
 AbstractValue getLeft()
          Returns the left argument of the constraint.
 int getOperation()
          Returns the operation of the constraint.
 AbstractValue getRight()
          Returns the right argument of the constraint.
 java.lang.String getSQLString()
          Returns a String representation of this Constraint object, suitable for forming part of an SQL query.
 int hashCode()
          Overrides Object.hashCode().
 java.lang.String toString()
          
 
Methods inherited from class org.intermine.sql.query.AbstractConstraint
alterComparisonAnd, alterComparisonAORB, alterComparisonNotObj, alterComparisonNotThis, alterComparisonSwitch, checkComparisonEquals, checkComparisonImplies, compare, equals
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

EQ

public static final int EQ
An operation for this constraint indicating that left is equal to right.

See Also:
Constant Field Values

LT

public static final int LT
An operation for this constraint indicating that left is less than right.

See Also:
Constant Field Values

LIKE

public static final int LIKE
An operation for this constraint indicating that left should be pattern-matched against right.

See Also:
Constant Field Values

GORNULL

public static final int GORNULL
An operation for this constraint indicating that the left is greater than the right, or the left is null.

See Also:
Constant Field Values

left

protected AbstractValue left

right

protected AbstractValue right

operation

protected int operation
Constructor Detail

Constraint

public Constraint(AbstractValue left,
                  int operation,
                  AbstractValue right)
Constructor for a Constraint object.

Parameters:
left - the AbstractValue on the left of the constraint
operation - EQ for an equivalence constraint, LT for a Less-Than constraint, LIKE for a String pattern match constraint - right must be the pattern to match against the value of left
right - the AbstractValue on the right of the constraint
Throws:
java.lang.IllegalArgumentException - if operation is not EQ, LT, or LIKE
Method Detail

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object

getSQLString

public java.lang.String getSQLString()
Returns a String representation of this Constraint object, suitable for forming part of an SQL query.

Specified by:
getSQLString in interface SQLStringable
Specified by:
getSQLString in class AbstractConstraint
Returns:
the String representation

compare

public int compare(AbstractConstraint obj,
                   java.util.Map<AbstractTable,AbstractTable> tableMap,
                   java.util.Map<AbstractTable,AbstractTable> reverseTableMap)
Compare this Constraint with another AbstractConstraint, ignoring aliases in member fields and tables. Compare this AbstractConstraint with another, ignoring aliases in member fields and tables.

Specified by:
compare in class AbstractConstraint
Parameters:
obj - an AbstractConstraint to compare to
tableMap - a Map from tables in this constraint to tables in obj
reverseTableMap - a reverse of tableMap
Returns:
INDEPENDENT, IMPLIED_BY, IMPLIES, EQUAL, OPPOSITE, EXCLUDES, or OR, depending on the constraints.

hashCode

public int hashCode()
Overrides Object.hashCode().

Specified by:
hashCode in class AbstractConstraint
Returns:
an arbitrary integer based on the contents of the Constraint

getLeft

public AbstractValue getLeft()
Returns the left argument of the constraint.

Returns:
left

getRight

public AbstractValue getRight()
Returns the right argument of the constraint.

Returns:
right

getOperation

public int getOperation()
Returns the operation of the constraint.

Returns:
operation