Package org.intermine.objectstore.query
Class QueryExpression
- java.lang.Object
-
- 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- Author:
- Mark Woodbridge, Richard Smith, Matthew Wakeling
-
-
Field Summary
Fields Modifier and Type Field Description static int
ADD
Addition of two numeric fieldsstatic int
DIVIDE
Division of two numeric fieldsstatic int
GREATEST
Return the greatest value from two expressions, e.g.static int
INDEX_OF
Position of specified string in other specified stringstatic int
LEAST
Return the lowest value from two expressions, e.g.static int
LOWER
Lower case version of the given stringstatic int
MODULO
Return the modulo of two expressions, e.g.static int
MULTIPLY
Multiplication of two numeric fieldsstatic int
SUBSTRING
Substring of specified length from index in stringstatic int
SUBTRACT
Subtraction of two numeric fieldsstatic int
UPPER
Upper case version of the given string
-
Constructor Summary
Constructors Constructor Description 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 itemsQueryExpression(QueryEvaluable arg, QueryEvaluable pos, QueryEvaluable len)
Constructs a substring QueryExpression from a QueryEvaluable and start and length QueryEvaluables
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.
-
-
-
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
-
GREATEST
public static final int GREATEST
Return the greatest value from two expressions, e.g. (col1, 0)- See Also:
- Constant Field Values
-
LEAST
public static final int LEAST
Return the lowest value from two expressions, e.g. (col1, 0)- See Also:
- Constant Field Values
-
MODULO
public static final int MODULO
Return the modulo of two expressions, e.g. (col1, 2)- 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 argumentop
- the required operationarg2
- 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 Stringpos
- start indexlen
- 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 operationarg
- 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 interfaceQueryOrderable
- Specified by:
getType
in interfaceQuerySelectable
- 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 interfaceQueryEvaluable
- 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 interfaceQueryEvaluable
- Returns:
- an int, as described in UnknownTypeValue
-
-