Package org.intermine.sql.query
Class Function
- java.lang.Object
-
- org.intermine.sql.query.AbstractValue
-
- org.intermine.sql.query.Function
-
- All Implemented Interfaces:
SQLStringable
public class Function extends AbstractValue
A representation of a function in an SQL query.- Author:
- Matthew wakeling, Andrew Varley
-
-
Field Summary
Fields Modifier and Type Field Description static int
AVG
AVG(v) aggregate function - takes one operand.static int
COALESCE
COALESCE operator - used by the precomputed tables' orderby fields.static int
COUNT
COUNT(*) aggregate function - takes no operands.static int
DIVIDE
DIVIDE function - takes two operands.static int
GREATEST
GREATEST(x, y) - takes two operandsstatic int
LEAST
LEAST(x, y) - takes two operandsstatic int
LOWER
LOWER operator - takes one operandstatic int
MAX
MAX(v) aggregate function - takes one operand.static int
MIN
MIN(v) aggregate function - takes one operand.static int
MINUS
MINUS function - takes two operands.static int
MODULO
MODULO arithmetic function - takes two operands.static int
MULTIPLY
MULTIPLY function - takes two or more operands.protected java.util.List<AbstractValue>
operands
protected int
operation
static int
PLUS
PLUS function - takes two or more operands.static int
POWER
POWER function - takes two operands.static int
STDDEV
STDDEV operator - takes one operandstatic int
STRPOS
STRPOS operator - takes two operands.static int
SUBSTR
SUBSTR operator - takes two or three operands.static int
SUM
SUM(v) aggregate function - takes one operand.static int
TYPECAST
Type casts - takes two operands.static int
UPPER
UPPER operator - takes one operand-
Fields inherited from class org.intermine.sql.query.AbstractValue
EQUAL, GREATER, INCOMPARABLE, LESS, NOT_EQUAL
-
-
Constructor Summary
Constructors Constructor Description Function(int operation)
Constructor for this Function object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(AbstractValue obj)
Adds an operand to this Function object.int
compare(AbstractValue obj, java.util.Map<AbstractTable,AbstractTable> tableMap, java.util.Map<AbstractTable,AbstractTable> reverseTableMap)
Compare the value of this AbstractValue with another.boolean
equals(java.lang.Object obj)
Overrides Object.equals.java.util.List<AbstractValue>
getOperands()
Returns the List of operands of this function.int
getOperation()
Returns the operation of the function.java.lang.String
getSQLString()
Returns a String representation of this Function object, suitable for forming part of an SQL query.int
hashCode()
Overrides Object.hashcode.boolean
isAggregate()
Returns true if this value is an aggregate function.-
Methods inherited from class org.intermine.sql.query.AbstractValue
greaterOrEqual, greaterThan, lessOrEqual, lessThan, notEqualTo, valueEquals
-
-
-
-
Field Detail
-
operation
protected int operation
-
operands
protected java.util.List<AbstractValue> operands
-
COUNT
public static final int COUNT
COUNT(*) aggregate function - takes no operands.- See Also:
- Constant Field Values
-
MAX
public static final int MAX
MAX(v) aggregate function - takes one operand.- See Also:
- Constant Field Values
-
MIN
public static final int MIN
MIN(v) aggregate function - takes one operand.- See Also:
- Constant Field Values
-
SUM
public static final int SUM
SUM(v) aggregate function - takes one operand.- See Also:
- Constant Field Values
-
AVG
public static final int AVG
AVG(v) aggregate function - takes one operand.- See Also:
- Constant Field Values
-
PLUS
public static final int PLUS
PLUS function - takes two or more operands.- See Also:
- Constant Field Values
-
MINUS
public static final int MINUS
MINUS function - takes two operands.- See Also:
- Constant Field Values
-
MULTIPLY
public static final int MULTIPLY
MULTIPLY function - takes two or more operands.- See Also:
- Constant Field Values
-
DIVIDE
public static final int DIVIDE
DIVIDE function - takes two operands.- See Also:
- Constant Field Values
-
POWER
public static final int POWER
POWER function - takes two operands.- See Also:
- Constant Field Values
-
MODULO
public static final int MODULO
MODULO arithmetic function - takes two operands.- See Also:
- Constant Field Values
-
TYPECAST
public static final int TYPECAST
Type casts - takes two operands.- See Also:
- Constant Field Values
-
STRPOS
public static final int STRPOS
STRPOS operator - takes two operands.- See Also:
- Constant Field Values
-
SUBSTR
public static final int SUBSTR
SUBSTR operator - takes two or three operands.- See Also:
- Constant Field Values
-
COALESCE
public static final int COALESCE
COALESCE operator - used by the precomputed tables' orderby fields.- See Also:
- Constant Field Values
-
LOWER
public static final int LOWER
LOWER operator - takes one operand- See Also:
- Constant Field Values
-
UPPER
public static final int UPPER
UPPER operator - takes one operand- See Also:
- Constant Field Values
-
STDDEV
public static final int STDDEV
STDDEV operator - takes one operand- See Also:
- Constant Field Values
-
GREATEST
public static final int GREATEST
GREATEST(x, y) - takes two operands- See Also:
- Constant Field Values
-
LEAST
public static final int LEAST
LEAST(x, y) - takes two operands- See Also:
- Constant Field Values
-
-
Method Detail
-
add
public void add(AbstractValue obj)
Adds an operand to this Function object. Operands are stored in the order they are added.- Parameters:
obj
- the AbstractValue to add as an operand- Throws:
java.lang.IllegalArgumentException
- if the operation cannot handle that many operands
-
getSQLString
public java.lang.String getSQLString()
Returns a String representation of this Function object, suitable for forming part of an SQL query.- Specified by:
getSQLString
in interfaceSQLStringable
- Specified by:
getSQLString
in classAbstractValue
- Returns:
- the String representation
- Throws:
java.lang.IllegalStateException
- if there aren't the correct number of operands for the operation yet.
-
equals
public boolean equals(java.lang.Object obj)
Overrides Object.equals.- Specified by:
equals
in classAbstractValue
- Parameters:
obj
- the Object to compare to- Returns:
- true if they are equal
-
compare
public int compare(AbstractValue obj, java.util.Map<AbstractTable,AbstractTable> tableMap, java.util.Map<AbstractTable,AbstractTable> reverseTableMap)
Compare the value of this AbstractValue with another.- Specified by:
compare
in classAbstractValue
- Parameters:
obj
- an AbstractValue to compare totableMap
- a mapping between tablenames of the two elementsreverseTableMap
- a reverse of tableMap- Returns:
- EQUAL, LESS, GREATER, NOT_EQUAL, or INCOMPARABLE
-
hashCode
public int hashCode()
Overrides Object.hashcode.- Specified by:
hashCode
in classAbstractValue
- Returns:
- an arbitrary integer based on the contents of the Function
-
getOperation
public int getOperation()
Returns the operation of the function.- Returns:
- operation
-
getOperands
public java.util.List<AbstractValue> getOperands()
Returns the List of operands of this function.- Returns:
- all operands in a List
-
isAggregate
public boolean isAggregate()
Returns true if this value is an aggregate function.- Specified by:
isAggregate
in classAbstractValue
- Returns:
- a boolean
-
-