Package com.mckoi.database.sql
Class Util
- java.lang.Object
-
- com.mckoi.database.sql.Util
-
public class Util extends java.lang.Object
Various utility methods for the iterpreter.
-
-
Field Summary
Fields Modifier and Type Field Description private static TObject
ZERO_NUMBER
-
Constructor Summary
Constructors Constructor Description Util()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.String
asNonQuotedRef(Token token)
Returns the Token as a non quoted reference.private static java.lang.String
escapeTranslated(java.lang.String input)
Translate a string with escape codes into a un-escaped Java string.static java.lang.String
expressionListToString(Expression[] list)
Returns an array of Expression objects as a comma deliminated string.static Expression
normalize(Expression exp)
Normalizes the Expression by removing all NOT operators and altering the expression as appropriate.private static Expression
normalize(Expression exp, boolean inverse)
Normalizes the Expression by removing all NOT operators and altering the expression as appropriate.static TObject
parseNumberToken(Token token, boolean negative)
Parses a NUMBER_LITERAL Token with a sign boolean.static FunctionDef
resolveFunctionName(java.lang.String name, Expression[] exp_list)
Returns a Function object that represents the name and expression list (of parameters) of a function.private static Expression
standardInverse(Expression exp)
Returns an expression that is (exp) = false which is the natural inverse of all expressions.static TObject
toArrayParamObject(Expression[] arr)
Converts an expression array to an array type that can be added to an expression.static java.lang.Object
toParamObject(Token token, boolean upper_identifiers)
Converts a Token which is either a STRING_LITERAL, NUMBER_LITERAL or IDENTIFIER into a Java Object.static TObject
zeroNumber()
Returns numeric 0
-
-
-
Field Detail
-
ZERO_NUMBER
private static TObject ZERO_NUMBER
-
-
Method Detail
-
asNonQuotedRef
public static java.lang.String asNonQuotedRef(Token token)
Returns the Token as a non quoted reference. For example, a QUOTED_VARIABLE token will have the first and last '"' character removed. A QUOTED_DELIMINATED_REF will have " removed in each deliminated section. For example, '"re1"."re2"."a"' becomes 're1.re2.a" and '"re1.re2.a"' becomes 're1.re2.a'.
-
toParamObject
public static java.lang.Object toParamObject(Token token, boolean upper_identifiers)
Converts a Token which is either a STRING_LITERAL, NUMBER_LITERAL or IDENTIFIER into a Java Object. If 'upper_identifiers' is true then all identifiers are made upper case before being returned (eg. if the object returns is a Variable object).
-
zeroNumber
public static TObject zeroNumber()
Returns numeric 0
-
parseNumberToken
public static TObject parseNumberToken(Token token, boolean negative)
Parses a NUMBER_LITERAL Token with a sign boolean.
-
toArrayParamObject
public static TObject toArrayParamObject(Expression[] arr)
Converts an expression array to an array type that can be added to an expression.
-
expressionListToString
public static java.lang.String expressionListToString(Expression[] list)
Returns an array of Expression objects as a comma deliminated string.
-
normalize
public static Expression normalize(Expression exp)
Normalizes the Expression by removing all NOT operators and altering the expression as appropriate. For example, the expression; not ((a + b) = c and c = 5) would be normalized to; (a + b) <> c or c <> 5
-
normalize
private static Expression normalize(Expression exp, boolean inverse)
Normalizes the Expression by removing all NOT operators and altering the expression as appropriate. For example, the expression; not ((a + b) = c and c = 5) would be normalized to; (a + b) <> c or c <> 5
-
standardInverse
private static Expression standardInverse(Expression exp)
Returns an expression that is (exp) = false which is the natural inverse of all expressions. This should only be used if the expression can't be inversed in any other way.
-
resolveFunctionName
public static FunctionDef resolveFunctionName(java.lang.String name, Expression[] exp_list)
Returns a Function object that represents the name and expression list (of parameters) of a function. Throws an exception if the function doesn't exist.
-
escapeTranslated
private static java.lang.String escapeTranslated(java.lang.String input)
Translate a string with escape codes into a un-escaped Java string. \' is converted to ', \n is a newline, \t is a tab, \\ is \, etc.
-
-