protected void evaluateNode(OOEEEvaluationContext context) throws EvaluationException { try { getValueClass(); } catch (ParsingException e) { throw new EvaluationException(ExceptionConstants.EBOS_000, e); } ExpressionNode expr = getChild(1); expr.evaluate(context); Object valueObject = context.stackPop(); if (ExpressionUtil.isNumeric(valueClass)) { try { valueObject = ExpressionUtil.getNumericReturnObject(valueObject, valueClass); } catch (ParsingException e) { throw new EvaluationException(ExceptionConstants.EBOS_000, e); } } else if (ExpressionUtil.isReferenceType(valueClass)) { if (valueObject != null && !valueClass.isAssignableFrom(valueObject.getClass())) { throw new EvaluationException( ExceptionConstants.EBOS_OOEE_006, new Object[] {valueObject.getClass(), valueClass}); } } context.stackPush(valueObject); }
/** * rebuild input expression string replace all short class name with full class name that contain * package name Warning: if variable name is equal to a class name which in class cache the * variable name also replaced by class name */ public String rebuildExpression() throws ParsingException { String expression = expressString; Map classMap = Collections.unmodifiableMap(this.classMap); if (classMap != null && !classMap.isEmpty()) { expression = ExpressionUtil.trimExpression(expression, classMap); } return expression; }
public Class checkType(OOEEParsingContext context) throws ParsingException { ExpressionNode expr = getChild(0); Class exprClass = expr.checkType(context); ExpressionNode type = getChild(1); Class instanceClass = type.checkType(context); if (!ExpressionUtil.isReferenceType(exprClass) || !ExpressionUtil.isReferenceType(instanceClass) || !ExpressionUtil.isCastableFrom(instanceClass, exprClass)) { throw new ParsingException( ExceptionConstants.EBOS_OOEE_037, new Object[] {exprClass, instanceClass}); } instanceClassName = instanceClass.getName(); setValueClass(boolean.class); return valueClass; }
public Class checkType(OOEEParsingContext context) throws ParsingException { ExpressionNode type = getChild(0); setValueClass(type.checkType(context)); ExpressionNode expr = getChild(1); Class fromClass = expr.checkType(context); if (!ExpressionUtil.isCastableFrom(valueClass, fromClass)) { throw new ParsingException( ExceptionConstants.EBOS_OOEE_070, new Object[] {fromClass, valueClass}); // throw new ParsingException("inconvertable cast from class " + fromClass + " to " + // valueClass); } // optimization code if (valueClass.isPrimitive() && expr.isConstant()) { super.isConstant = true; Object constantValue = expr.getConstantValue(); if (ExpressionUtil.isNumeric(valueClass)) { constantValue = ExpressionUtil.getNumericReturnObject(constantValue, valueClass); } super.setConstantValue(constantValue); } else { super.isConstant = false; } // fix bug if (expr instanceof FieldExpression && parent instanceof FieldExpression) { boolean isClass = ((FieldExpression) expr).isClass(); ((FieldExpression) parent).setIsClass(isClass); } return valueClass; }
protected void evaluateNode(OOEEEvaluationContext context) throws EvaluationException { try { getValueClass(); } catch (ParsingException e) { throw new EvaluationException(ExceptionConstants.EBOS_000, e); } Class instanceClass = null; try { instanceClass = ExpressionUtil.findClass(instanceClassName); } catch (ParsingException e) { throw new EvaluationException(ExceptionConstants.EBOS_000, e); } ExpressionNode expr = getChild(0); expr.evaluate(context); Object exprObject = context.stackPop(); Object valueObject = instanceClass.isInstance(exprObject) ? Boolean.TRUE : Boolean.FALSE; context.stackPush(valueObject); }