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.SerializableAn operator for an expression.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classOperator.AddOperator(package private) static classOperator.AllOperator(package private) static classOperator.AndOperator(package private) static classOperator.AnyOperator(package private) static classOperator.ConcatOperator(package private) static classOperator.DivideOperator(package private) static classOperator.EqualOperator(package private) static classOperator.GreaterEqualOperator(package private) static classOperator.GreaterOperator(package private) static classOperator.IsNotOperator(package private) static classOperator.IsOperator(package private) static classOperator.LesserEqualOperator(package private) static classOperator.LesserOperator(package private) static classOperator.MultiplyOperator(package private) static classOperator.NotEqualOperator(package private) static classOperator.OrOperator(package private) static classOperator.ParenOperator(package private) static classOperator.PatternMatchFalseOperator(package private) static classOperator.PatternMatchTrueOperator(package private) static classOperator.RegexOperator(package private) static classOperator.SimpleOperator(package private) static classOperator.SubtractOperator
-
Field Summary
Fields Modifier and Type Field Description private static Operator.AddOperatoradd_opstatic intALLThe ANY and ALL enumerator.private static java.util.HashMapall_mapprivate static Operator.AndOperatorand_opstatic intANYThe ANY and ALL enumerator.private static java.util.HashMapany_mapprivate static Operator.ConcatOperatorconcat_opprivate static Operator.DivideOperatordiv_opprivate static Operator.EqualOperatoreq_opprivate static Operator.GreaterOperatorg_opprivate static Operator.GreaterEqualOperatorgeq_opprivate static Operatorin_opprivate static Operator.IsOperatoris_opprivate static Operator.IsNotOperatorisn_opprivate static Operator.LesserOperatorl_opprivate static Operator.LesserEqualOperatorleq_opprivate static Operator.PatternMatchTrueOperatorlike_opprivate static Operator.MultiplyOperatormul_opprivate static Operator.NotEqualOperatorneq_opprivate static Operatornin_opprivate static Operator.PatternMatchFalseOperatornlike_opstatic intNONEThe ANY and ALL enumerator.private static Operatornot_opprivate java.lang.StringopA string that represents this operator.private static Operator.OrOperatoror_opprivate static Operator.ParenOperatorpar1_opprivate static Operator.ParenOperatorpar2_opprivate intprecedenceThe precedence of this operator.private static Operator.RegexOperatorregex_op(package private) static longserialVersionUIDprivate intset_typeIf this is a set operator such as ANY or ALL then this is set with the flag type.private static Operator.SubtractOperatorsub_op
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object ob)abstract TObjecteval(TObject ob1, TObject ob2, GroupResolver group, VariableResolver resolver, QueryContext context)static Operatorget(java.lang.String op)Returns an Operator with the given string.OperatorgetSubQueryForm(int type)Returns the ANY or ALL form of this operator.OperatorgetSubQueryForm(java.lang.String type_str)Same as above only it handles the type as a string.(package private) intgetSubQueryFormRepresentation()Returns the sub query representation of this operator.Operatorinverse()Returns the inverse operator of this operator.booleanis(java.lang.String given_op)Returns true if this operator is equal to the operator string.booleanisCondition()booleanisLogical()booleanisMathematical()booleanisNot()booleanisNotInversible()Returns true if this operator is not inversible.booleanisPattern()booleanisSubQuery()booleanisSubQueryForm(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 booleanisTrue(TObject bool)Returns true if the given TObject is a boolean and is true.intprecedence()TTypereturnTType()The type of object this Operator evaluates to.Operatorreverse()Returns an Operator that is the reverse of this Operator.(package private) java.lang.StringstringRepresentation()Returns the string value of this operator.java.lang.StringtoString()
-
-
-
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:
toStringin classjava.lang.Object
-
equals
public boolean equals(java.lang.Object ob)
- Overrides:
equalsin 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.
-
-