/** * Attempt to convert a typed value to a float using the supplied type converter. */ public static float toFloat(TypeConverter typeConverter, TypedValue typedValue) { return convertValue(typeConverter, typedValue, Float.class); }
@Override public Expression parseExpression(String expressionString) throws ParseException { return parseExpression(expressionString, null); }
private Expression parseTemplate(String expressionString, ParserContext context) throws ParseException { if (expressionString.isEmpty()) { return new LiteralExpression(""); } Expression[] expressions = parseExpressions(expressionString, context); if (expressions.length == 1) { return expressions[0]; } else { return new CompositeStringExpression(expressionString, expressions); } }
@Override @Nullable public <T> T getValue(EvaluationContext context, Object rootObject, @Nullable Class<T> desiredResultType) throws EvaluationException { Object value = getValue(context, rootObject); return ExpressionUtils.convertTypedValue(context, new TypedValue(value), desiredResultType); }
@Override @Nullable public <T> T getValue(Object rootObject, @Nullable Class<T> desiredResultType) throws EvaluationException { Object value = getValue(rootObject); return ExpressionUtils.convertTypedValue(null, new TypedValue(value), desiredResultType); }
private void populateFloatArray(ExpressionState state, Object newArray, TypeConverter typeConverter, InlineList initializer) { float[] newFloatArray = (float[]) newArray; for (int i = 0; i < newFloatArray.length; i++) { TypedValue typedValue = initializer.getChild(i).getTypedValue(state); newFloatArray[i] = ExpressionUtils.toFloat(typeConverter, typedValue); } }
private void populateShortArray(ExpressionState state, Object newArray, TypeConverter typeConverter, InlineList initializer) { short[] newShortArray = (short[]) newArray; for (int i = 0; i < newShortArray.length; i++) { TypedValue typedValue = initializer.getChild(i).getTypedValue(state); newShortArray[i] = ExpressionUtils.toShort(typeConverter, typedValue); } }
@Override @Nullable public <T> T getValue(@Nullable Class<T> expectedResultType) throws EvaluationException { Object value = getValue(); return ExpressionUtils.convertTypedValue(null, new TypedValue(value), expectedResultType); }
@Override @Nullable public <T> T getValue(EvaluationContext context, @Nullable Class<T> expectedResultType) throws EvaluationException { Object value = getValue(context); return ExpressionUtils.convertTypedValue(context, new TypedValue(value), expectedResultType); }
/** * Attempt to convert a typed value to a long using the supplied type converter. */ public static long toLong(TypeConverter typeConverter, TypedValue typedValue) { return convertValue(typeConverter, typedValue, Long.class); }
@Override @Nullable public <T> T getValue(Object rootObject, @Nullable Class<T> desiredResultType) throws EvaluationException { Object value = getValue(rootObject); return ExpressionUtils.convertTypedValue(null, new TypedValue(value), desiredResultType); }
@Override @Nullable public <T> T getValue(EvaluationContext context, Object rootObject, @Nullable Class<T> desiredResultType) throws EvaluationException { Object value = getValue(context,rootObject); return ExpressionUtils.convertTypedValue(context, new TypedValue(value), desiredResultType); }
/** * Attempt to convert a typed value to a short using the supplied type converter. */ public static short toShort(TypeConverter typeConverter, TypedValue typedValue) { return convertValue(typeConverter, typedValue, Short.class); }
@Override @Nullable public <T> T getValue(EvaluationContext context, @Nullable Class<T> expectedResultType) throws EvaluationException { Object value = getValue(context); return ExpressionUtils.convertTypedValue(context, new TypedValue(value), expectedResultType); }
@Override @Nullable public <T> T getValue(@Nullable Class<T> expectedResultType) throws EvaluationException { Object value = getValue(); return ExpressionUtils.convertTypedValue(null, new TypedValue(value), expectedResultType); }
/** * Attempt to convert a typed value to a byte using the supplied type converter. */ public static byte toByte(TypeConverter typeConverter, TypedValue typedValue) { return convertValue(typeConverter, typedValue, Byte.class); }
/** * Attempt to convert a typed value to an int using the supplied type converter. */ public static int toInt(TypeConverter typeConverter, TypedValue typedValue) { return convertValue(typeConverter, typedValue, Integer.class); }
/** * Attempt to convert a typed value to a double using the supplied type converter. */ public static double toDouble(TypeConverter typeConverter, TypedValue typedValue) { return convertValue(typeConverter, typedValue, Double.class); }
/** * Attempt to convert a typed value to a boolean using the supplied type converter. */ public static boolean toBoolean(TypeConverter typeConverter, TypedValue typedValue) { return convertValue(typeConverter, typedValue, Boolean.class); }
/** * Attempt to convert a typed value to a char using the supplied type converter. */ public static char toChar(TypeConverter typeConverter, TypedValue typedValue) { return convertValue(typeConverter, typedValue, Character.class); }