@Override public void visit( Cast cast ) { append("CAST("); cast.getOperand().accept(this); append(" AS "); append(cast.getDesiredTypeName()); append(")"); } }
protected Cast cast( DynamicOperand operand, String desiredType ) { return new Cast(operand, desiredType); }
DynamicOperand oldOperand = operation.getOperand(); DynamicOperand newOperand = replaceAliasesWithProperties(context, oldOperand, propertyByAlias); if (oldOperand == newOperand) return operation; return new Cast(newOperand, operation.getDesiredTypeName());
SelectorName replacement = rewrittenSelectors.get(operation.selectorName()); if (replacement == null) return operand; return new Cast(replaceReferencesToRemovedSource(context, operation.getOperand(), rewrittenSelectors), operation.getDesiredTypeName());
@Test @FixFor( "MODE-2166" ) public void shouldParseDynamicOperandFromStringContainingCast() { DynamicOperand operand = parser.parseDynamicOperand(tokens("CAST(tableA.property AS DOUBLE)"), typeSystem, mock(Source.class)); assertThat(operand, is(instanceOf(Cast.class))); Cast cast = (Cast)operand; assertThat(cast.selectorName(), is(selectorName("tableA"))); assertThat(cast.getOperand(), is(instanceOf(PropertyValue.class))); PropertyValue value = (PropertyValue)cast.getOperand(); assertThat(value.getPropertyName(), is("property")); assertThat(value.selectorName(), is(selectorName("tableA"))); assertEquals(PropertyType.DOUBLE.toString(), cast.getDesiredTypeName()); }
@Override public int hashCode() { return getOperand().hashCode(); }
return types.getTypeFactory(((Cast)operand).getDesiredTypeName());
DynamicOperand oldOperand = operation.getOperand(); DynamicOperand newOperand = replaceAliasesWithProperties(context, oldOperand, propertyByAlias); if (oldOperand == newOperand) return operation; return new Cast(newOperand, operation.getDesiredTypeName());
SelectorName replacement = rewrittenSelectors.get(operation.selectorName()); if (replacement == null) return operand; return new Cast(replaceReferencesToRemovedSource(context, operation.getOperand(), rewrittenSelectors), operation.getDesiredTypeName());
@Test @FixFor( "MODE-2166" ) public void shouldParseDynamicOperandFromStringContainingCastOfLowerCaseOfAnotherOperand() { DynamicOperand operand = parser.parseDynamicOperand(tokens("CAST(LOWER(tableA.property) AS DATE)"), typeSystem, mock(Source.class)); assertThat(operand, is(instanceOf(Cast.class))); Cast cast = (Cast)operand; assertThat(cast.selectorName(), is(selectorName("tableA"))); assertThat(cast.getOperand(), is(instanceOf(LowerCase.class))); assertEquals(PropertyType.DATE.toString(), cast.getDesiredTypeName()); LowerCase lower = (LowerCase)cast.getOperand(); assertThat(lower.selectorName(), is(selectorName("tableA"))); assertThat(lower.getOperand(), is(instanceOf(PropertyValue.class))); PropertyValue value = (PropertyValue)lower.getOperand(); assertThat(value.getPropertyName(), is("property")); assertThat(value.selectorName(), is(selectorName("tableA"))); }
@Override public int hashCode() { return getOperand().hashCode(); }
return types.getTypeFactory(((Cast)operand).getDesiredTypeName());
return new Cast(replaceViewReferences(context, operation.getOperand(), mapping, node), operation.getDesiredTypeName());
@Override public void visit( Cast cast ) { append("CAST("); cast.getOperand().accept(this); append(" AS "); append(cast.getDesiredTypeName()); append(")"); } }
protected boolean applies( Cast operand ) { return applies(operand.getOperand()); }
protected Cast cast( DynamicOperand operand, String desiredType ) { return new Cast(operand, desiredType); }
return new Cast(replaceViewReferences(context, operation.getOperand(), mapping, node), operation.getDesiredTypeName());
final ExtractFromRow delegate = createExtractFromRow(cast.getOperand(), context, columns, sources, defaultType, allowMultiValued, false); final String desiredTypeName = cast.getDesiredTypeName(); final TypeFactory<?> typeFactory = context.getTypeSystem().getTypeFactory(desiredTypeName); final Class<?> desiredType = typeFactory.getType();
protected boolean applies( Cast operand ) { return applies(operand.getOperand()); }
@Override public Cast cast( javax.jcr.query.qom.DynamicOperand operand, String desiredType ) throws InvalidQueryException, RepositoryException { DynamicOperand jcrOperand = CheckArg.getInstanceOf(operand, DynamicOperand.class, "operand"); return new org.modeshape.jcr.query.model.Cast(jcrOperand, desiredType); }