Package com.ptsmods.mysqlw.query
Class QueryFunction
java.lang.Object
com.ptsmods.mysqlw.query.QueryFunction
- All Implemented Interfaces:
CharSequence
To make sure that functions don't get enquoted when putting them in a query, wrap them in this class.
An example would be
JSON_CONTAINS(`column`, '{"value": {"child": 7}}')
or GeomFromText('POINT(42.8, 69.7)')
although that one is obsolete.
This class also implements CharSequence
so that it can be passed as a key when selecting. (Otherwise it gets put between graves unless it's an asterisk.)-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic QueryFunction
Creates a basic new QueryFunction that adds two columns or variables together.char
charAt
(int index) static QueryFunction
Creates a basic new QueryFunction that counts rows.static QueryFunction
Creates a basic new QueryFunction that divides two columns or variables.int
length()
static QueryFunction
Creates a basic new QueryFunction that multiplies two columns or variables.subSequence
(int start, int end) static QueryFunction
Creates a basic new QueryFunction that subtracts two columns or variables from each other.toString()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.CharSequence
chars, codePoints, isEmpty
-
Constructor Details
-
QueryFunction
Creates a new QueryFunction.- Parameters:
function
- The function this QueryFunction should contain
-
-
Method Details
-
add
Creates a basic new QueryFunction that adds two columns or variables together.- Parameters:
arg1
- The first column or variablearg2
- The second column or variable- Returns:
- Addition QueryFunction
-
subtract
Creates a basic new QueryFunction that subtracts two columns or variables from each other.- Parameters:
arg1
- The first column or variablearg2
- The second column or variable- Returns:
- Subtraction QueryFunction
-
multiply
Creates a basic new QueryFunction that multiplies two columns or variables.- Parameters:
arg1
- The first column or variablearg2
- The second column or variable- Returns:
- Multiplication QueryFunction
-
divide
Creates a basic new QueryFunction that divides two columns or variables.- Parameters:
arg1
- The first column or variablearg2
- The second column or variable- Returns:
- Division QueryFunction
-
count
Creates a basic new QueryFunction that counts rows.- Parameters:
arg
- What to count- Returns:
- Count QueryFunction
-
getFunction
- Returns:
- The function this QueryFunction contains.
-
length
public int length()- Specified by:
length
in interfaceCharSequence
-
charAt
public char charAt(int index) - Specified by:
charAt
in interfaceCharSequence
-
subSequence
- Specified by:
subSequence
in interfaceCharSequence
-
toString
- Specified by:
toString
in interfaceCharSequence
- Overrides:
toString
in classObject
-