org.datanucleus.store.mapped.expression
Class StringExpression

java.lang.Object
  extended by org.datanucleus.store.mapped.expression.ScalarExpression
      extended by org.datanucleus.store.mapped.expression.StringExpression
Direct Known Subclasses:
ConcatOperatorExpression, StringLiteral, SubstringExpression

public class StringExpression
extends ScalarExpression

Representation of an expression with a string.


Nested Class Summary
 
Nested classes/interfaces inherited from class org.datanucleus.store.mapped.expression.ScalarExpression
ScalarExpression.DatastoreFieldExpression, ScalarExpression.DyadicOperator, ScalarExpression.ExpressionList, ScalarExpression.IllegalArgumentTypeException, ScalarExpression.IllegalOperationException, ScalarExpression.MethodInvocationException, ScalarExpression.MonadicOperator, ScalarExpression.Operator
 
Field Summary
 
Fields inherited from class org.datanucleus.store.mapped.expression.ScalarExpression
aliasIdentifier, checkForTypeAssignability, expressionList, FILTER, LOCALISER, lowestOperator, mapping, OP_ADD, OP_AND, OP_BETWEEN, OP_COM, OP_CONCAT, OP_DIV, OP_EQ, OP_GT, OP_GTEQ, OP_IN, OP_IS, OP_ISNOT, OP_LIKE, OP_LT, OP_LTEQ, OP_MOD, OP_MUL, OP_NEG, OP_NOT, OP_NOTEQ, OP_NOTIN, OP_NOTLIKE, OP_OR, OP_SUB, parameterName, PROJECTION, qs, st, te
 
Constructor Summary
protected StringExpression(QueryExpression qs)
           
  StringExpression(QueryExpression qs, JavaTypeMapping mapping, LogicSetExpression te)
           
  StringExpression(ScalarExpression operand1, ScalarExpression.DyadicOperator op, ScalarExpression operand2)
          Performs a function on two arguments.
  StringExpression(java.lang.String functionName, java.util.List args)
          Generates statement as e.g.
  StringExpression(java.lang.String functionName, java.util.List args, java.util.List types)
          Generates statement as e.g.
 
Method Summary
 ScalarExpression add(ScalarExpression expr)
          Additive Operator.
 StringExpression charAtMethod(ScalarExpression index)
          Returns the character at a position.
 BooleanExpression endsWithMethod(ScalarExpression str)
          Returns whether this string ends with the specified string.
 BooleanExpression eq(ScalarExpression expr)
          Equality operator (equals to)
 BooleanExpression equalsMethod(ScalarExpression expr)
          Returns whether this string is equal to the expression.
 BooleanExpression gt(ScalarExpression expr)
          Relational operator (greater than)
 BooleanExpression gteq(ScalarExpression expr)
          Relational operator (greater than or equals)
 BooleanExpression in(ScalarExpression expr)
          In expression.
 NumericExpression indexOfMethod(ScalarExpression str)
          Returns the index within this string of the first occurrence of the specified string.
 NumericExpression indexOfMethod(ScalarExpression str, ScalarExpression fromIndex)
          Returns the index within this string of the first occurrence of the specified character, starting the search at the specified index.
 NumericExpression lengthMethod()
          Method to handle the starts with operation.
 BooleanExpression likeMethod(ScalarExpression expr)
          Perform a database "like" operation
 BooleanExpression lt(ScalarExpression expr)
          Relational operator (lower than)
 BooleanExpression lteq(ScalarExpression expr)
          Relational operator (lower than or equals)
 BooleanExpression matchesMethod(ScalarExpression expr)
          Matches this to the argument expression pattern.
 BooleanExpression noteq(ScalarExpression expr)
          Equality operator (not equals to)
 BooleanExpression startsWithMethod(ScalarExpression str)
          Method to handle the starts with operation.
 BooleanExpression startsWithMethod(ScalarExpression str, ScalarExpression toffset)
          Method to handle the starts with operation.
 StringExpression substringMethod(ScalarExpression begin)
          Method to handle the substring operation.
 StringExpression substringMethod(ScalarExpression begin, ScalarExpression end)
          Method to handle the substring operation.
 StringExpression toLowerCaseMethod()
          Method to handle the lower case operation.
 StringExpression toUpperCaseMethod()
          Method to handle the upper case operation.
 StringExpression translateMethod(ScalarExpression toExpr, ScalarExpression fromExpr)
          Method to translate all chars in this expression to the fromExpr which corresponds to toExpr.
 StringExpression trimLeftMethod()
          Method to handle trimming of the left side of a string (leading spaces).
 StringExpression trimMethod()
          Method to handle trimming of both ends of a string.
 StringExpression trimRightMethod()
          Method to handle trimming of the right side of a string (trailing spaces).
 
Methods inherited from class org.datanucleus.store.mapped.expression.ScalarExpression
accessField, and, as, assertValidTypeForParameterComparison, callMethod, cast, checkForTypeAssignability, com, div, encloseWithInParentheses, eor, equals, getAlias, getConsistentTypeForParameterComparison, getExpressionList, getLogicSetExpression, getMapping, getNonAliasExpression, getQueryExpression, instanceOf, ior, mod, mul, neg, not, setParameterName, sub, toStatementText, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

StringExpression

protected StringExpression(QueryExpression qs)

StringExpression

public StringExpression(QueryExpression qs,
                        JavaTypeMapping mapping,
                        LogicSetExpression te)
Parameters:
qs - the QueryExpression
mapping - the mapping associated to this expression
te - the TableExpression where this expression refers to

StringExpression

public StringExpression(java.lang.String functionName,
                        java.util.List args)
Generates statement as e.g. FUNCTION_NAME(arg[,argN])

Parameters:
functionName -
args - ScalarExpression list

StringExpression

public StringExpression(java.lang.String functionName,
                        java.util.List args,
                        java.util.List types)
Generates statement as e.g. FUNCTION_NAME(arg AS type[,argN as typeN])

Parameters:
functionName - Name of function
args - ScalarExpression list
types - String or ScalarExpression list

StringExpression

public StringExpression(ScalarExpression operand1,
                        ScalarExpression.DyadicOperator op,
                        ScalarExpression operand2)
Performs a function on two arguments. op(operand1,operand2) operand1 op operand2

Parameters:
operand1 - the first expression
op - the operator between operands
operand2 - the second expression
Method Detail

eq

public BooleanExpression eq(ScalarExpression expr)
Description copied from class: ScalarExpression
Equality operator (equals to)

Overrides:
eq in class ScalarExpression
Parameters:
expr - the right-hand operand
Returns:
The type of an equality expression is a boolean

noteq

public BooleanExpression noteq(ScalarExpression expr)
Description copied from class: ScalarExpression
Equality operator (not equals to)

Overrides:
noteq in class ScalarExpression
Parameters:
expr - the right-hand operand
Returns:
The type of an equality expression is a boolean

lt

public BooleanExpression lt(ScalarExpression expr)
Description copied from class: ScalarExpression
Relational operator (lower than)

Overrides:
lt in class ScalarExpression
Parameters:
expr - the right-hand operand
Returns:
true if the value of the left-hand operand is less than the value of the right-hand operand, and otherwise is false.

lteq

public BooleanExpression lteq(ScalarExpression expr)
Description copied from class: ScalarExpression
Relational operator (lower than or equals)

Overrides:
lteq in class ScalarExpression
Parameters:
expr - the right-hand operand
Returns:
true if the value of the left-hand operand is less than or equal to the value of the right-hand operand, and otherwise is false.

gt

public BooleanExpression gt(ScalarExpression expr)
Description copied from class: ScalarExpression
Relational operator (greater than)

Overrides:
gt in class ScalarExpression
Parameters:
expr - the right-hand operand
Returns:
true if the value of the left-hand operand is greater than the value of the right-hand operand, and otherwise is false.

gteq

public BooleanExpression gteq(ScalarExpression expr)
Description copied from class: ScalarExpression
Relational operator (greater than or equals)

Overrides:
gteq in class ScalarExpression
Parameters:
expr - the right-hand operand
Returns:
true if the value of the left-hand operand is greater than or equal the value of the right-hand operand, and otherwise is false.

add

public ScalarExpression add(ScalarExpression expr)
Description copied from class: ScalarExpression
Additive Operator. The binary + operator performs addition when applied to two operands of numeric type, producing the sum of the operands. If the type of either operand of a + operator is String, then the operation is string concatenation.

Overrides:
add in class ScalarExpression
Parameters:
expr - the right-hand operand
Returns:
If one of the operands is String, the returned value is the string concatenation; The sum of two operands of numeric type. The left-hand operand is the minuend and the right-hand operand is the subtrahend;

in

public BooleanExpression in(ScalarExpression expr)
Description copied from class: ScalarExpression
In expression. Return true if this is contained by expr

Overrides:
in in class ScalarExpression
Parameters:
expr - the right-hand expression
Returns:
true if the left-hand expression is contained by the right-hand expression. Otherwise the result is false.

equalsMethod

public BooleanExpression equalsMethod(ScalarExpression expr)
Returns whether this string is equal to the expression. This is provided as an operation on String.

Parameters:
expr - The expression to compare against.
Returns:
Expression whether they are equal.

charAtMethod

public StringExpression charAtMethod(ScalarExpression index)
Returns the character at a position.

Parameters:
index - The position of the character required.
Returns:
The expression.

endsWithMethod

public BooleanExpression endsWithMethod(ScalarExpression str)
Returns whether this string ends with the specified string.

Parameters:
str - The string to compare against.
Returns:
Whether it ends with the string.

indexOfMethod

public NumericExpression indexOfMethod(ScalarExpression str)
Returns the index within this string of the first occurrence of the specified string.

Parameters:
str - The string to find the index of
Returns:
The index of the string.

indexOfMethod

public NumericExpression indexOfMethod(ScalarExpression str,
                                       ScalarExpression fromIndex)
Returns the index within this string of the first occurrence of the specified character, starting the search at the specified index.

Parameters:
str - The string to find the index of
fromIndex - the index to start the search from.
Returns:
The index of the string.

lengthMethod

public NumericExpression lengthMethod()
Method to handle the starts with operation.

Returns:
The expression.

startsWithMethod

public BooleanExpression startsWithMethod(ScalarExpression str)
Method to handle the starts with operation.

Parameters:
str - The string to compare against
Returns:
The expression.

startsWithMethod

public BooleanExpression startsWithMethod(ScalarExpression str,
                                          ScalarExpression toffset)
Method to handle the starts with operation.

Parameters:
str - The string to compare against
toffset - The offset
Returns:
The expression.

substringMethod

public StringExpression substringMethod(ScalarExpression begin)
Method to handle the substring operation.

Parameters:
begin - The start position
Returns:
The expression.

substringMethod

public StringExpression substringMethod(ScalarExpression begin,
                                        ScalarExpression end)
Method to handle the substring operation.

Parameters:
begin - The start position
end - The end position
Returns:
The expression.

translateMethod

public StringExpression translateMethod(ScalarExpression toExpr,
                                        ScalarExpression fromExpr)
Method to translate all chars in this expression to the fromExpr which corresponds to toExpr.

Returns:
The expression.

toLowerCaseMethod

public StringExpression toLowerCaseMethod()
Method to handle the lower case operation.

Returns:
The expression.

toUpperCaseMethod

public StringExpression toUpperCaseMethod()
Method to handle the upper case operation.

Returns:
The expression.

matchesMethod

public BooleanExpression matchesMethod(ScalarExpression expr)
Matches this to the argument expression pattern. Use "." to find any character and ".*" for wildcard matches. A global case-insensitive flag "(?i)" can be set for the pattern. If used, the global case-insensitive flag must prefix the pattern. The pattern passed to matches must be a literal or parameter.

Parameters:
expr - The literal expression with the pattern.
Returns:
the match expression.

likeMethod

public BooleanExpression likeMethod(ScalarExpression expr)
Perform a database "like" operation

Parameters:
expr - The expression with the pattern.
Returns:
the match expression.

trimMethod

public StringExpression trimMethod()
Method to handle trimming of both ends of a string.

Returns:
The expression.

trimLeftMethod

public StringExpression trimLeftMethod()
Method to handle trimming of the left side of a string (leading spaces).

Returns:
The expression.

trimRightMethod

public StringExpression trimRightMethod()
Method to handle trimming of the right side of a string (trailing spaces).

Returns:
The expression.


Copyright © 2010. All Rights Reserved.