org.intermine.objectstore.query
Class QueryExpression

java.lang.Object
  extended by org.intermine.objectstore.query.QueryExpression
All Implemented Interfaces:
QueryEvaluable, QueryNode, QueryOrderable, QuerySelectable

public class QueryExpression
extends java.lang.Object
implements QueryEvaluable

Represents an arithmetic or substring expression, analogous to those in SQL


Field Summary
static int ADD
          Addition of two numeric fields
static int DIVIDE
          Division of two numeric fields
static int INDEX_OF
          Position of specified string in other specified string
static int LOWER
          Lower case version of the given string
static int MULTIPLY
          Multiplication of two numeric fields
static int SUBSTRING
          Substring of specified length from index in string
static int SUBTRACT
          Subtraction of two numeric fields
static int UPPER
          Upper case version of the given string
 
Constructor Summary
QueryExpression(int op, QueryEvaluable arg)
          Constructs a String QueryExpression to perform upper and lowercase conversions.
QueryExpression(QueryEvaluable arg1, int op, QueryEvaluable arg2)
          Constructs an arithmetic QueryExpression from two evaluable items
QueryExpression(QueryEvaluable arg, QueryEvaluable pos, QueryEvaluable len)
          Constructs a substring QueryExpression from a QueryEvaluable and start and length QueryEvaluables
 
Method Summary
 int getApproximateType()
          Returns an integer representing the approximate type of this QueryEvaluable, in the case where an accurate type cannot be ascertained.
 QueryEvaluable getArg1()
          Returns the left argument of the expression.
 QueryEvaluable getArg2()
          Returns the right argument, or the position argument of the substring.
 QueryEvaluable getArg3()
          Returns the length argument of a substring expression.
 int getOperation()
          Returns the operation.
 java.lang.Class<?> getType()
          Get Java type represented by this item.
 void youAreType(java.lang.Class<?> cls)
          Allows a caller to suggest to this object that it holds a value of a certain type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ADD

public static final int ADD
Addition of two numeric fields

See Also:
Constant Field Values

SUBTRACT

public static final int SUBTRACT
Subtraction of two numeric fields

See Also:
Constant Field Values

MULTIPLY

public static final int MULTIPLY
Multiplication of two numeric fields

See Also:
Constant Field Values

DIVIDE

public static final int DIVIDE
Division of two numeric fields

See Also:
Constant Field Values

SUBSTRING

public static final int SUBSTRING
Substring of specified length from index in string

See Also:
Constant Field Values

INDEX_OF

public static final int INDEX_OF
Position of specified string in other specified string

See Also:
Constant Field Values

LOWER

public static final int LOWER
Lower case version of the given string

See Also:
Constant Field Values

UPPER

public static final int UPPER
Upper case version of the given string

See Also:
Constant Field Values
Constructor Detail

QueryExpression

public QueryExpression(QueryEvaluable arg1,
                       int op,
                       QueryEvaluable arg2)
Constructs an arithmetic QueryExpression from two evaluable items

Parameters:
arg1 - the first argument
op - the required operation
arg2 - the second argument
Throws:
java.lang.IllegalArgumentException - if there is a mismatch between any of the argument types and the specified operation

QueryExpression

public QueryExpression(QueryEvaluable arg,
                       QueryEvaluable pos,
                       QueryEvaluable len)
Constructs a substring QueryExpression from a QueryEvaluable and start and length QueryEvaluables

Parameters:
arg - A QueryEvaluable representing a String
pos - start index
len - length in characters
Throws:
java.lang.IllegalArgumentException - if there is a mismatch between the argument type and the specified operation

QueryExpression

public QueryExpression(int op,
                       QueryEvaluable arg)
Constructs a String QueryExpression to perform upper and lowercase conversions.

Parameters:
op - the required operation
arg - the String argument
Throws:
java.lang.IllegalArgumentException - if there is a mismatch between the argument and operation
Method Detail

getType

public java.lang.Class<?> getType()
Get Java type represented by this item.

Specified by:
getType in interface QueryOrderable
Specified by:
getType in interface QuerySelectable
Returns:
class describing the type

getOperation

public int getOperation()
Returns the operation.

Returns:
the operation of the expression

getArg1

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

Returns:
the left argument

getArg2

public QueryEvaluable getArg2()
Returns the right argument, or the position argument of the substring.

Returns:
argument 2

getArg3

public QueryEvaluable getArg3()
Returns the length argument of a substring expression.

Returns:
argument 3

youAreType

public void youAreType(java.lang.Class<?> cls)
Allows a caller to suggest to this object that it holds a value of a certain type. This method should only be called on objects which report their type to be UnknownTypeValue. Otherwise, this method will throw and exception.

Specified by:
youAreType in interface QueryEvaluable
Parameters:
cls - the Class of the type to be imposed on this object

getApproximateType

public int getApproximateType()
Returns an integer representing the approximate type of this QueryEvaluable, in the case where an accurate type cannot be ascertained.

Specified by:
getApproximateType in interface QueryEvaluable
Returns:
an int, as described in UnknownTypeValue