|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
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 conversions do not lose information about the overall magnitude of a numeric value.
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.
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 |
public NumericExpression toNumericExpression(CharacterExpression expr)
(int)'A'
expression. In SQL, it should compile something
like:
ASCII('A')
expr
- The CharacterExpression
public StringExpression toStringExpression(NumericExpression expr)
CAST(999999 AS VARCHAR(4000))
expr
- The NumericExpression
public StringExpression toStringExpression(StringLiteral expr)
CAST('value' AS VARCHAR(4000))
expr
- The StringLiteral
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |