org.datanucleus.store.mapped.expression
Interface ExpressionConversionAdapter

All Known Subinterfaces:
DatastoreAdapter

public interface ExpressionConversionAdapter

Every expression written in the Java programming language has a type that can be deduced from the structure of the expression and the types of the literals, variables, and methods mentioned in the expression. It is possible, however, to write an expression in a context where the type of the expression is not appropriate. In some cases, this leads to an error at compile time. In other cases, the context may be able to accept a type that is related to the type of the expression; as a convenience, rather than requiring the programmer to indicate a type conversion explicitly, the language performs an implicit conversion from the type of the expression to a type acceptable for its surrounding context.

Supported conversion types:

Widening conversion

Widening conversions do not lose information about the overall magnitude of a numeric value.

String conversion

If only one operand expression is of type String, then string conversion is performed on the other operand to produce a string at run time. The result is a reference to a String object (newly created, unless the expression is a compile-time constant expression (15.28))that is the concatenation of the two operand strings. The characters of the left-hand operand precede the characters of the right-hand operand in the newly created string. If an operand of type String is null, then the string "null" is used instead of that operand.

Version:
$Revision: 1.2 $

Method Summary
 NumericExpression toNumericExpression(CharacterExpression expr)
          A Widening conversion that returns the appropriate expression for the (int)'A' expression.
 StringExpression toStringExpression(NumericExpression expr)
          A String conversion that converts a numeric expression to string.
 StringExpression toStringExpression(StringLiteral expr)
          A String conversion that converts a String literal to String expression.
 

Method Detail

toNumericExpression

NumericExpression toNumericExpression(CharacterExpression expr)
A Widening conversion that returns the appropriate expression for the (int)'A' expression. In SQL, it should compile something like:

 ASCII('A')
 

Parameters:
expr - The CharacterExpression
Returns:
The NumericExpression

toStringExpression

StringExpression toStringExpression(NumericExpression expr)
A String conversion that converts a numeric expression to string. If the expr argument represents a Literal value, converts to a Literal string. In SQL, it should compile something like:

 CAST(999999 AS VARCHAR(4000))
 

Parameters:
expr - The NumericExpression
Returns:
the StringExpression

toStringExpression

StringExpression toStringExpression(StringLiteral expr)
A String conversion that converts a String literal to String expression. It will allow the String to be evaluated only at runtime. In SQL, it should compile something like:

 CAST('value' AS VARCHAR(4000))
 

Parameters:
expr - The StringLiteral
Returns:
the StringExpression


Copyright © 2010. All Rights Reserved.