Class CastExpression
java.lang.Object
dev.frostlake.executor.expressions.CastExpression
- All Implemented Interfaces:
Expression
Represents a type cast (e.g., CAST(x AS INTEGER), x::VARCHAR). When
tryMode is set (TRY_CAST),
a failed conversion yields NULL instead of raising an error.
A PARAMETERIZED target whose parameters decide the cast's legality and result — a STRUCTURED type
(OBJECT(x VARCHAR), ARRAY(INT), MAP(k,v)) or a VECTOR(FLOAT|INT, n) —
is carried as a parsed DataType alongside the target-type text, together with the optional
RENAME FIELDS / ADD FIELDS modifier. Those parameters must survive from the parse
tree rather than being re-derived from the (whitespace-stripped) target text.
-
Constructor Summary
ConstructorsConstructorDescriptionCastExpression(Expression expression, String targetType) CastExpression(Expression expression, String targetType, boolean tryMode) CastExpression(Expression expression, String targetType, boolean tryMode, DataType declaredTarget, CastFieldsModifier fieldsModifier) -
Method Summary
Modifier and TypeMethodDescription<T> Taccept(ExpressionVisitor<T> visitor) Accept a visitor for the visitor patternThe parsed target type when its PARAMETERS matter (a structured type, or aVECTOR(t, n)), or null when the plain target-type text says everything.TheRENAME FIELDS/ADD FIELDSmodifier, never null.Where the cast was written, relative to its fragment — the::of the shorthand, the CAST or TRY_CAST keyword otherwise — or null for a cast the engine built itself.booleanvoidsetPosition(SourcePosition position) toString()
-
Constructor Details
-
CastExpression
-
CastExpression
-
CastExpression
public CastExpression(Expression expression, String targetType, boolean tryMode, DataType declaredTarget, CastFieldsModifier fieldsModifier)
-
-
Method Details
-
getExpression
-
getTargetType
-
isTryMode
public boolean isTryMode() -
getDeclaredTarget
The parsed target type when its PARAMETERS matter (a structured type, or aVECTOR(t, n)), or null when the plain target-type text says everything. -
getFieldsModifier
TheRENAME FIELDS/ADD FIELDSmodifier, never null. -
getPosition
Where the cast was written, relative to its fragment — the::of the shorthand, the CAST or TRY_CAST keyword otherwise — or null for a cast the engine built itself. A refusal of the cast as a whole is positioned there: live pointsv::VECTOR(INT,3)at the::. -
setPosition
-
accept
Description copied from interface:ExpressionAccept a visitor for the visitor pattern- Specified by:
acceptin interfaceExpression
-
toString
-