org.datanucleus.store.mapped.expression
Class StringLiteral

java.lang.Object
  extended by org.datanucleus.store.mapped.expression.ScalarExpression
      extended by org.datanucleus.store.mapped.expression.StringExpression
          extended by org.datanucleus.store.mapped.expression.StringLiteral
All Implemented Interfaces:
Literal
Direct Known Subclasses:
MetaDataStringLiteral

public class StringLiteral
extends StringExpression
implements Literal

Representation of a string literal.


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
StringLiteral(QueryExpression qs, JavaTypeMapping mapping, char value)
          Constructor that takes a char.
StringLiteral(QueryExpression qs, JavaTypeMapping mapping, java.lang.String value)
          Constructor
 
Method Summary
 ScalarExpression add(ScalarExpression expr)
          Additive Operator.
 BooleanExpression endsWithMethod(ScalarExpression str)
          Returns whether this string ends with the specified string.
 BooleanExpression eq(ScalarExpression expr)
          Equality operator (equals to)
 void generateStatementWithoutQuotes()
          Convenience method to generate the statement without any quotes.
 java.lang.Object getRawValue()
          Accessor for the "raw" value that this literal represents.
 java.lang.Object getValue()
          Accessor to the literal value
 BooleanExpression gt(ScalarExpression expr)
          Relational operator (greater than)
 BooleanExpression gteq(ScalarExpression expr)
          Relational operator (greater than or equals)
 NumericExpression indexOfMethod(ScalarExpression str)
          Returns the index within this string of the first occurrence of the specified string.
 NumericExpression lengthMethod()
          Method to handle the starts with operation.
 BooleanExpression lt(ScalarExpression expr)
          Relational operator (lower than)
 BooleanExpression lteq(ScalarExpression expr)
          Relational operator (lower than or equals)
 BooleanExpression noteq(ScalarExpression expr)
          Equality operator (not equals to)
 void setRawValue(java.lang.Object val)
          Method to save a "raw" value that this literal represents.
 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(NumericExpression begin)
          Method to handle the substring operation.
 StringExpression substringMethod(NumericExpression begin, NumericExpression end)
          Method to handle the substring operation.
 StringExpression toLowerCaseMethod()
          Method to handle the lower case operation.
 StatementText toStatementText(int mode)
          StatementText representation of this expression.
 StringExpression toUpperCaseMethod()
          Method to handle the upper case operation.
 StringExpression trimMethod()
          Method to handle trimming of a string.
 
Methods inherited from class org.datanucleus.store.mapped.expression.StringExpression
charAtMethod, equalsMethod, in, indexOfMethod, likeMethod, matchesMethod, substringMethod, substringMethod, translateMethod, trimLeftMethod, trimRightMethod
 
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, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

StringLiteral

public StringLiteral(QueryExpression qs,
                     JavaTypeMapping mapping,
                     char value)
Constructor that takes a char. TODO we should not accept chars in String literal

Parameters:
qs - The QueryExpression
mapping - The mapping to the java type
value - The value that is further converted to a String

StringLiteral

public StringLiteral(QueryExpression qs,
                     JavaTypeMapping mapping,
                     java.lang.String value)
Constructor

Parameters:
qs - The QueryExpression
mapping - The mapping to the java type. null mapping is accepted
value - The value
Method Detail

generateStatementWithoutQuotes

public void generateStatementWithoutQuotes()
Convenience method to generate the statement without any quotes. This is called when we create a literal using a mapping, and dont want quotes because the string is an SQL keyword.


getValue

public java.lang.Object getValue()
Description copied from interface: Literal
Accessor to the literal value

Specified by:
getValue in interface Literal
Returns:
the value of the literal

eq

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

Overrides:
eq in class StringExpression
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 StringExpression
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 StringExpression
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 StringExpression
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 StringExpression
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 StringExpression
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 StringExpression
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;

endsWithMethod

public BooleanExpression endsWithMethod(ScalarExpression str)
Description copied from class: StringExpression
Returns whether this string ends with the specified string.

Overrides:
endsWithMethod in class StringExpression
Parameters:
str - The string to compare against.
Returns:
Whether it ends with the string.

indexOfMethod

public NumericExpression indexOfMethod(ScalarExpression str)
Description copied from class: StringExpression
Returns the index within this string of the first occurrence of the specified string.

Overrides:
indexOfMethod in class StringExpression
Parameters:
str - The string to find the index of
Returns:
The index of the string.

lengthMethod

public NumericExpression lengthMethod()
Description copied from class: StringExpression
Method to handle the starts with operation.

Overrides:
lengthMethod in class StringExpression
Returns:
The expression.

startsWithMethod

public BooleanExpression startsWithMethod(ScalarExpression str)
Description copied from class: StringExpression
Method to handle the starts with operation.

Overrides:
startsWithMethod in class StringExpression
Parameters:
str - The string to compare against
Returns:
The expression.

startsWithMethod

public BooleanExpression startsWithMethod(ScalarExpression str,
                                          ScalarExpression toffset)
Description copied from class: StringExpression
Method to handle the starts with operation.

Overrides:
startsWithMethod in class StringExpression
Parameters:
str - The string to compare against
toffset - The offset
Returns:
The expression.

substringMethod

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

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

substringMethod

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

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

toLowerCaseMethod

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

Overrides:
toLowerCaseMethod in class StringExpression
Returns:
The expression.

toUpperCaseMethod

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

Overrides:
toUpperCaseMethod in class StringExpression
Returns:
The expression.

trimMethod

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

Overrides:
trimMethod in class StringExpression
Returns:
The expression.

toStatementText

public StatementText toStatementText(int mode)
Description copied from class: ScalarExpression
StatementText representation of this expression. I.E. A Boolean field may be stored in boolean format like 0 or 1, and it can also be stored in other formats, like Y or N, TRUE or FALSE, and so on. The projection mode for the boolean field is the real content of the value stored, (e.g. Y or N), and opposed to that the filter mode for the boolean field is always represented by a boolean expression (e.g. Y=Y or N=N) In SQL, the projection can be exemplified as "SELECT BOOLEAN_FIELD ... " and the filter as "SELECT COLUMNS ... WHERE BOOLEAN_FIELD ='Y'"

Overrides:
toStatementText in class ScalarExpression
Parameters:
mode - (0=PROJECTION;1=FILTER)
Returns:
the StatementText

setRawValue

public void setRawValue(java.lang.Object val)
Method to save a "raw" value that this literal represents. This value differs from the literal value since that is of the same type as this literal.

Specified by:
setRawValue in interface Literal
Parameters:
val - The raw value

getRawValue

public java.lang.Object getRawValue()
Accessor for the "raw" value that this literal represents. This value differs from the literal value since that is of the same type as this literal.

Specified by:
getRawValue in interface Literal
Returns:
The raw value


Copyright © 2010. All Rights Reserved.