Package com.mckoi.database
Class Operator
- java.lang.Object
-
- com.mckoi.database.Operator
-
- All Implemented Interfaces:
java.io.Serializable
- Direct Known Subclasses:
Operator.AddOperator
,Operator.AllOperator
,Operator.AndOperator
,Operator.AnyOperator
,Operator.ConcatOperator
,Operator.DivideOperator
,Operator.EqualOperator
,Operator.GreaterEqualOperator
,Operator.GreaterOperator
,Operator.IsNotOperator
,Operator.IsOperator
,Operator.LesserEqualOperator
,Operator.LesserOperator
,Operator.MultiplyOperator
,Operator.NotEqualOperator
,Operator.OrOperator
,Operator.ParenOperator
,Operator.PatternMatchFalseOperator
,Operator.PatternMatchTrueOperator
,Operator.RegexOperator
,Operator.SimpleOperator
,Operator.SubtractOperator
public abstract class Operator extends java.lang.Object implements java.io.Serializable
An operator for an expression.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
Operator.AddOperator
(package private) static class
Operator.AllOperator
(package private) static class
Operator.AndOperator
(package private) static class
Operator.AnyOperator
(package private) static class
Operator.ConcatOperator
(package private) static class
Operator.DivideOperator
(package private) static class
Operator.EqualOperator
(package private) static class
Operator.GreaterEqualOperator
(package private) static class
Operator.GreaterOperator
(package private) static class
Operator.IsNotOperator
(package private) static class
Operator.IsOperator
(package private) static class
Operator.LesserEqualOperator
(package private) static class
Operator.LesserOperator
(package private) static class
Operator.MultiplyOperator
(package private) static class
Operator.NotEqualOperator
(package private) static class
Operator.OrOperator
(package private) static class
Operator.ParenOperator
(package private) static class
Operator.PatternMatchFalseOperator
(package private) static class
Operator.PatternMatchTrueOperator
(package private) static class
Operator.RegexOperator
(package private) static class
Operator.SimpleOperator
(package private) static class
Operator.SubtractOperator
-
Field Summary
Fields Modifier and Type Field Description private static Operator.AddOperator
add_op
static int
ALL
The ANY and ALL enumerator.private static java.util.HashMap
all_map
private static Operator.AndOperator
and_op
static int
ANY
The ANY and ALL enumerator.private static java.util.HashMap
any_map
private static Operator.ConcatOperator
concat_op
private static Operator.DivideOperator
div_op
private static Operator.EqualOperator
eq_op
private static Operator.GreaterOperator
g_op
private static Operator.GreaterEqualOperator
geq_op
private static Operator
in_op
private static Operator.IsOperator
is_op
private static Operator.IsNotOperator
isn_op
private static Operator.LesserOperator
l_op
private static Operator.LesserEqualOperator
leq_op
private static Operator.PatternMatchTrueOperator
like_op
private static Operator.MultiplyOperator
mul_op
private static Operator.NotEqualOperator
neq_op
private static Operator
nin_op
private static Operator.PatternMatchFalseOperator
nlike_op
static int
NONE
The ANY and ALL enumerator.private static Operator
not_op
private java.lang.String
op
A string that represents this operator.private static Operator.OrOperator
or_op
private static Operator.ParenOperator
par1_op
private static Operator.ParenOperator
par2_op
private int
precedence
The precedence of this operator.private static Operator.RegexOperator
regex_op
(package private) static long
serialVersionUID
private int
set_type
If this is a set operator such as ANY or ALL then this is set with the flag type.private static Operator.SubtractOperator
sub_op
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object ob)
abstract TObject
eval(TObject ob1, TObject ob2, GroupResolver group, VariableResolver resolver, QueryContext context)
static Operator
get(java.lang.String op)
Returns an Operator with the given string.Operator
getSubQueryForm(int type)
Returns the ANY or ALL form of this operator.Operator
getSubQueryForm(java.lang.String type_str)
Same as above only it handles the type as a string.(package private) int
getSubQueryFormRepresentation()
Returns the sub query representation of this operator.Operator
inverse()
Returns the inverse operator of this operator.boolean
is(java.lang.String given_op)
Returns true if this operator is equal to the operator string.boolean
isCondition()
boolean
isLogical()
boolean
isMathematical()
boolean
isNot()
boolean
isNotInversible()
Returns true if this operator is not inversible.boolean
isPattern()
boolean
isSubQuery()
boolean
isSubQueryForm(int type)
Given a parameter of either NONE, ANY, ALL or SINGLE, this returns true if this operator is of the given type.private static boolean
isTrue(TObject bool)
Returns true if the given TObject is a boolean and is true.int
precedence()
TType
returnTType()
The type of object this Operator evaluates to.Operator
reverse()
Returns an Operator that is the reverse of this Operator.(package private) java.lang.String
stringRepresentation()
Returns the string value of this operator.java.lang.String
toString()
-
-
-
Field Detail
-
serialVersionUID
static final long serialVersionUID
- See Also:
- Constant Field Values
-
NONE
public static final int NONE
The ANY and ALL enumerator.- See Also:
- Constant Field Values
-
ANY
public static final int ANY
The ANY and ALL enumerator.- See Also:
- Constant Field Values
-
ALL
public static final int ALL
The ANY and ALL enumerator.- See Also:
- Constant Field Values
-
op
private java.lang.String op
A string that represents this operator.
-
set_type
private int set_type
If this is a set operator such as ANY or ALL then this is set with the flag type.
-
precedence
private int precedence
The precedence of this operator.
-
add_op
private static final Operator.AddOperator add_op
-
sub_op
private static final Operator.SubtractOperator sub_op
-
mul_op
private static final Operator.MultiplyOperator mul_op
-
div_op
private static final Operator.DivideOperator div_op
-
concat_op
private static final Operator.ConcatOperator concat_op
-
eq_op
private static final Operator.EqualOperator eq_op
-
neq_op
private static final Operator.NotEqualOperator neq_op
-
g_op
private static final Operator.GreaterOperator g_op
-
l_op
private static final Operator.LesserOperator l_op
-
geq_op
private static final Operator.GreaterEqualOperator geq_op
-
leq_op
private static final Operator.LesserEqualOperator leq_op
-
is_op
private static final Operator.IsOperator is_op
-
isn_op
private static final Operator.IsNotOperator isn_op
-
like_op
private static final Operator.PatternMatchTrueOperator like_op
-
nlike_op
private static final Operator.PatternMatchFalseOperator nlike_op
-
regex_op
private static final Operator.RegexOperator regex_op
-
in_op
private static final Operator in_op
-
nin_op
private static final Operator nin_op
-
not_op
private static final Operator not_op
-
and_op
private static final Operator.AndOperator and_op
-
or_op
private static final Operator.OrOperator or_op
-
par1_op
private static final Operator.ParenOperator par1_op
-
par2_op
private static final Operator.ParenOperator par2_op
-
any_map
private static final java.util.HashMap any_map
-
all_map
private static final java.util.HashMap all_map
-
-
Method Detail
-
is
public boolean is(java.lang.String given_op)
Returns true if this operator is equal to the operator string.
-
eval
public abstract TObject eval(TObject ob1, TObject ob2, GroupResolver group, VariableResolver resolver, QueryContext context)
-
precedence
public int precedence()
-
isCondition
public boolean isCondition()
-
isMathematical
public boolean isMathematical()
-
isPattern
public boolean isPattern()
-
isLogical
public boolean isLogical()
-
isNot
public boolean isNot()
-
isSubQuery
public boolean isSubQuery()
-
reverse
public Operator reverse()
Returns an Operator that is the reverse of this Operator. This is used for reversing a conditional expression. eg. 9 > id becomes id < 9.
-
isNotInversible
public boolean isNotInversible()
Returns true if this operator is not inversible.
-
inverse
public Operator inverse()
Returns the inverse operator of this operator. For example, = becomes <>, > becomes <=, AND becomes OR.
-
isSubQueryForm
public boolean isSubQueryForm(int type)
Given a parameter of either NONE, ANY, ALL or SINGLE, this returns true if this operator is of the given type.
-
getSubQueryFormRepresentation
int getSubQueryFormRepresentation()
Returns the sub query representation of this operator.
-
getSubQueryForm
public Operator getSubQueryForm(int type)
Returns the ANY or ALL form of this operator.
-
getSubQueryForm
public Operator getSubQueryForm(java.lang.String type_str)
Same as above only it handles the type as a string.
-
returnTType
public TType returnTType()
The type of object this Operator evaluates to.
-
stringRepresentation
java.lang.String stringRepresentation()
Returns the string value of this operator.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object ob)
- Overrides:
equals
in classjava.lang.Object
-
get
public static Operator get(java.lang.String op)
Returns an Operator with the given string.
-
isTrue
private static boolean isTrue(TObject bool)
Returns true if the given TObject is a boolean and is true. If the TObject is not a boolean value or is null or is false, then it returns false.
-
-