|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.datatools.sqltools.sqlbuilder.model.ExpressionHelper
public class ExpressionHelper
Helper class for manipulating QueryValueExpression
Constructor Summary | |
---|---|
ExpressionHelper()
|
Method Summary | |
---|---|
static void |
addExpression(QueryValueExpression prevExpr,
QueryValueExpression newExpr,
ValueExpressionCombinedOperator operator)
Adds an expression to the expression tree |
java.lang.String |
appendQuotes(DataType columnType,
java.lang.String value)
Adds quotes to the string value passed which has given DataType. |
java.lang.String |
appendQuotes(int columnType,
java.lang.String value)
Adds quotes to the string value passed |
java.lang.String |
appendQuotes(java.lang.String columnType,
java.lang.String value)
Adds quotes to the string value passed. |
boolean |
containsParameterName(java.lang.String source)
Determines whether or not the given SQL string contains a parameter name. |
ValueExpressionCast |
createCast(QueryValueExpression expr,
java.lang.String dataType)
Creates a cast expression |
static ValueExpressionColumn |
createColumnExpression(TableExpression table,
Column col)
Creates a SQLColumnExpression for the given table and column. |
static ValueExpressionCombinedOperator |
createCombinedOperator(java.lang.String opType)
|
static QueryValueExpression |
createExpression()
|
static QueryValueExpression |
createExpression(java.lang.Object item)
Build a QueryValueExpression object from the input |
static ValueExpressionFunction |
createFunction(java.lang.String functionName)
Create a ValueExpressionFunction , given a function name,
An example of using this call will be to create function such as
CURRENT DATE, CURRENT TIME |
static ValueExpressionFunction |
createFunction(java.lang.String functionName,
java.util.List parmList)
Create a ValueExpressionFunction given a function name and a parameter list. |
static ValueExpressionNested |
createNestedExpression(QueryValueExpression expr)
|
PredicateBasic |
createPredicate(java.lang.Object left,
java.lang.Object right,
java.lang.String comparisonKind)
Create a SQLPredicate object given a left, right and comparsionKind If the comparisonKind requires no right side, set the right side to "" |
ValueExpressionScalarSelect |
createScalarSelect(QueryStatement stmt)
Creates a subquery statement expression |
static ValueExpressionColumn |
createValueExpressionColumn(java.lang.String name,
TableExpression tblExpr)
Builds a ValueExpressionColumn object and sets the given name and TableExpression. |
static ValueExpressionColumn |
createValueExpressionColumn(ValueExpressionColumn oldValExpr)
Builds a ValueExpressionColumn object from the given ValueExpressionColumn. |
static QueryValueExpression |
createValueExpressionDefaultValue()
|
static QueryValueExpression |
createValueExpressionNullValue()
|
boolean |
firstParameterChar(java.lang.String source)
Determines whether or not the given SQL string starts with a parameter character name. |
static java.lang.String |
getDefaultValueForColumn(Column aColumn)
Gets an acceptable default value (as a string) for the given database column, based on its datatype. |
static java.lang.String |
getDisplayString(java.lang.String opString)
|
static QueryValueExpression |
getLowestLeftChild(QueryValueExpression expr)
|
java.lang.String |
getQuotesContext()
Get the Context of the variable which needs quotes. |
static QueryValueExpression |
getRoot(QueryValueExpression node)
Returns the root node of the tree in which the given node is a left side child. |
static TableExpression |
getTableExprForValueExpressionColumn(ValueExpressionColumn colValExp)
Returns the TableExpression for the given ValueExpressionColumn. |
static boolean |
isComplete(QueryValueExpression expr)
|
static void |
removeExpression(QueryValueExpression expr)
Removes the given expression from a tree of expressions The expression tree for the expression A + B - C is as follows - + C A B |
static void |
replaceExpression(QueryValueExpression oldExpr,
QueryValueExpression newExpr)
Replaces an expression in an expression tree with a new expression. |
static void |
replaceOperator(QueryValueExpression expression,
ValueExpressionCombinedOperator newOperator)
Replaces the operator on a ValueExpressionCombined node in the expression tree The expression tree for the expression A + B - C is as follows - + C A B |
void |
resolveColumnReferencesInTemporaryStatement(QuerySelect select,
java.util.List tableExprList)
Unhooks all the ValueExpressionColumn s in the given
temporary QuerySelect and hooks them into the corresponding
TableExpression s in the given tableExprList ,
regardless of duplicate column names - identical logical column references. |
void |
setQuotesContext(java.lang.String quotesContext)
Set the Context of the variable which needs quotes. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ExpressionHelper()
Method Detail |
---|
public boolean containsParameterName(java.lang.String source)
source
- the SQL source to check
public boolean firstParameterChar(java.lang.String source)
source
- the SQL source to check
public static ValueExpressionColumn createValueExpressionColumn(java.lang.String name, TableExpression tblExpr)
ValueExpressionColumn
object and sets the given name and TableExpression.
name
- the String name for the new ValueExpressionColumntblExpr
- the TableExpression that needs to be set for the new ValueExpressionColumn
public static ValueExpressionColumn createValueExpressionColumn(ValueExpressionColumn oldValExpr)
oldValExpr
- the ValueExpressionColumn that needs to be set for the new ValueExpressionColumn
public static QueryValueExpression createValueExpressionNullValue()
public static QueryValueExpression createValueExpressionDefaultValue()
public static QueryValueExpression createExpression()
public static QueryValueExpression createExpression(java.lang.Object item)
QueryValueExpression
object from the input
public static ValueExpressionColumn createColumnExpression(TableExpression table, Column col)
table
- the table containing the columncol
- the column for which a column expression object is wanted
public PredicateBasic createPredicate(java.lang.Object left, java.lang.Object right, java.lang.String comparisonKind)
public static ValueExpressionFunction createFunction(java.lang.String functionName)
ValueExpressionFunction
, given a function name,
An example of using this call will be to create function such as
CURRENT DATE, CURRENT TIME
functionName
- - the name of the functionpublic static ValueExpressionFunction createFunction(java.lang.String functionName, java.util.List parmList)
ValueExpressionFunction
given a function name and a parameter list.
Examples of using this call be:
- MAX(Salary)
- CORRELATION(Salary, Bonus)
- CHAR(Staring + Duration, USA)
functionName
- - the name of the functionparmList
- - the parm list
See createList, and createExpressionGroup for more informationpublic ValueExpressionScalarSelect createScalarSelect(QueryStatement stmt)
public ValueExpressionCast createCast(QueryValueExpression expr, java.lang.String dataType)
public java.lang.String getQuotesContext()
public void setQuotesContext(java.lang.String quotesContext)
quotesContext
- The quotesContext to set.public java.lang.String appendQuotes(DataType columnType, java.lang.String value)
the
- DataType of the value passedvalue
- the String value that needs quotes
public java.lang.String appendQuotes(java.lang.String columnType, java.lang.String value)
columntype
- the name of the datatypevalue
- the String value that needs quotes
public java.lang.String appendQuotes(int columnType, java.lang.String value)
columntype
- - SQLDefinedType datatypevalue
- - string value needs quotes
public void resolveColumnReferencesInTemporaryStatement(QuerySelect select, java.util.List tableExprList)
ValueExpressionColumn
s in the given
temporary QuerySelect
and hooks them into the corresponding
TableExpression
s in the given tableExprList
,
regardless of duplicate column names - identical logical column references.
All the ValueExpressionColumn
s in the given temporary
QuerySelect
must reference to one
TableReference
in the given temporary
QuerySelect
'sfromClause
, in order to be
detached from their temporary TableReference
and attached to
a corresponding TableReference
in the given
tableExprList
.
Note:
All TableReference
in the given QuerySelect
's
fromClause
and the given tableExprList
, that
belong to the default Schema, must all either be not qualified with their
Schema name or must all be qualified with their Schema name.
select
- a temporary valid QuerySelect
with
fromClause
tableExpressionList
- a List of TableExpression
spublic static ValueExpressionNested createNestedExpression(QueryValueExpression expr)
public static boolean isComplete(QueryValueExpression expr)
public static void replaceExpression(QueryValueExpression oldExpr, QueryValueExpression newExpr)
oldExpr
- the QueryValueExpression to be replacednewExpr
- the new QueryValueExpressionpublic static void replaceOperator(QueryValueExpression expression, ValueExpressionCombinedOperator newOperator)
expression
- the expression in the same row as that of the operator being replaced, int the expressionbuilder UInewOperator
- the new operator to be set in the treepublic static void addExpression(QueryValueExpression prevExpr, QueryValueExpression newExpr, ValueExpressionCombinedOperator operator)
prevExpr
- the expression the row above this expression is to be added in the expression builder UInewExpr
- the new expression to be added to the treeoperator
- the new operatorpublic static void removeExpression(QueryValueExpression expr)
expr
- the expression to be removedpublic static java.lang.String getDisplayString(java.lang.String opString)
public static ValueExpressionCombinedOperator createCombinedOperator(java.lang.String opType)
public static QueryValueExpression getRoot(QueryValueExpression node)
node
- a node in the tree
public static QueryValueExpression getLowestLeftChild(QueryValueExpression expr)
public static TableExpression getTableExprForValueExpressionColumn(ValueExpressionColumn colValExp)
colValExp
- the given ValueExpressionColumn for which TableExpression is needed
public static java.lang.String getDefaultValueForColumn(Column aColumn)
aColumn
- a column for which the default value is needed
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |