org.intermine.objectstore.query
Class SimpleConstraint

java.lang.Object
  extended by org.intermine.objectstore.query.Constraint
      extended by org.intermine.objectstore.query.SimpleConstraint

public class SimpleConstraint
extends Constraint

Represents a constraint between two QueryEvaluable types. These are query elements that can be resolved to a value - fields, expressions, aggregate functions and constants. Constraint ops can be standard numeric comparison, IS_NULL, and also MATCHES for simple string pattern matching.


Field Summary
protected static java.util.List<ConstraintOp> ALL_OPS
           
protected static java.util.List<ConstraintOp> BOOLEAN_OPS
           
protected static java.util.List<ConstraintOp> DATE_OPS
           
protected static java.util.List<ConstraintOp> NUMBER_OPS
           
protected  QueryEvaluable qe1
           
protected  QueryEvaluable qe2
           
protected static java.util.List<ConstraintOp> STRING_OPS
           
 
Fields inherited from class org.intermine.objectstore.query.Constraint
op
 
Constructor Summary
SimpleConstraint(QueryEvaluable qe1, ConstraintOp op)
          Construct a Constraint.
SimpleConstraint(QueryEvaluable qe1, ConstraintOp op, QueryEvaluable qe2)
          Construct a Constraint.
 
Method Summary
static boolean comparable(java.lang.Class<?> arg1, java.lang.Class<?> arg2)
          Check whether the two arguments are of comparable types i.e. they are of similiar type and we know how to handle that type
 boolean equals(java.lang.Object obj)
          Test whether two SimpleConstraints are equal, overrides Object.equals()
static java.util.List<ConstraintOp> fixedEnumOps(java.lang.Class<?> arg)
          For an argument type which an enumerated value set, return the list of operators for which it makes sense only to provide the enumerated values and not allow the user to enter an arbitrary string.
 QueryEvaluable getArg1()
          Returns the left argument of the constraint.
 QueryEvaluable getArg2()
          Returns the right argument of the constraint.
 int hashCode()
          Get the hashCode for this object overrides Object.hashCode()
 java.lang.String toString()
          
static boolean validComparison(java.lang.Class<?> arg1, ConstraintOp op, java.lang.Class<?> arg2)
          Check whether a comparison is valid i.e. the arguments are comparable types and the the operator is permitted for those types
static java.util.List<ConstraintOp> validOps(java.lang.Class<?> arg)
          Return the list of valid (binary) operator codes given arguments of a specified type
 
Methods inherited from class org.intermine.objectstore.query.Constraint
getOp, negate
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

qe1

protected QueryEvaluable qe1

qe2

protected QueryEvaluable qe2

NUMBER_OPS

protected static final java.util.List<ConstraintOp> NUMBER_OPS

DATE_OPS

protected static final java.util.List<ConstraintOp> DATE_OPS

STRING_OPS

protected static final java.util.List<ConstraintOp> STRING_OPS

BOOLEAN_OPS

protected static final java.util.List<ConstraintOp> BOOLEAN_OPS

ALL_OPS

protected static final java.util.List<ConstraintOp> ALL_OPS
Constructor Detail

SimpleConstraint

public SimpleConstraint(QueryEvaluable qe1,
                        ConstraintOp op,
                        QueryEvaluable qe2)
Construct a Constraint. Check that java types of QueryEvaluables are compatible with the constraint type selected.

Parameters:
qe1 - first QueryEvaluable for comparison
op - define comparison op
qe2 - second QueryEvaluable for comparison
Throws:
java.lang.IllegalArgumentException - if type does not correspond to a defined operation

SimpleConstraint

public SimpleConstraint(QueryEvaluable qe1,
                        ConstraintOp op)
Construct a Constraint. Check that correct constraint op is selected for single QueryEvaluable constructor

Parameters:
qe1 - first QueryEvaluable for comparison
op - define op of comparison
Throws:
java.lang.IllegalArgumentException - if op does not correspond to a defined operation
Method Detail

getArg1

public QueryEvaluable getArg1()
Returns the left argument of the constraint.

Returns:
the left-hand argument

getArg2

public QueryEvaluable getArg2()
Returns the right argument of the constraint.

Returns:
the right-hand argument

equals

public boolean equals(java.lang.Object obj)
Test whether two SimpleConstraints are equal, overrides Object.equals()

Overrides:
equals in class java.lang.Object
Parameters:
obj - the object to compare with
Returns:
true if objects are equal

hashCode

public int hashCode()
Get the hashCode for this object overrides Object.hashCode()

Overrides:
hashCode in class java.lang.Object
Returns:
the hashCode

validComparison

public static boolean validComparison(java.lang.Class<?> arg1,
                                      ConstraintOp op,
                                      java.lang.Class<?> arg2)
Check whether a comparison is valid i.e. the arguments are comparable types and the the operator is permitted for those types

Parameters:
arg1 - the first argument
op - how to compare the arguments
arg2 - the second argument
Returns:
whether the comparison is valid

comparable

public static boolean comparable(java.lang.Class<?> arg1,
                                 java.lang.Class<?> arg2)
Check whether the two arguments are of comparable types i.e. they are of similiar type and we know how to handle that type

Parameters:
arg1 - the first argument
arg2 - the second argument
Returns:
whether the types are comparable

validOps

public static java.util.List<ConstraintOp> validOps(java.lang.Class<?> arg)
Return the list of valid (binary) operator codes given arguments of a specified type

Parameters:
arg - the argument type
Returns:
an array of character codes

fixedEnumOps

public static java.util.List<ConstraintOp> fixedEnumOps(java.lang.Class<?> arg)
For an argument type which an enumerated value set, return the list of operators for which it makes sense only to provide the enumerated values and not allow the user to enter an arbitrary string.

Parameters:
arg - the argument type
Returns:
constraint operators that will only accept an enumerated value

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object