Package ariba.util.fieldtype

Examples of ariba.util.fieldtype.TypeInfo


    protected Object getValueBody( ExprContext context, Object source ) throws ExprException
    {
        Object v1 = children[0].getValue( context, source );
        Object v2 = children[1].getValue( context, source );
        TypeInfo v1Info = children[0].getTypeInfo();
        if (v1Info == null || v1Info instanceof NullTypeInfo) {
            v1Info = getTypeInfo();
        }
        return ExprOps.divide(
            v1,
            v2,
            v1Info != null? v1Info.getName(): null);
    }
View Full Code Here


            Node exprRootNode = expr.getRootNode();
            if (exprRootNode != null &&
                (exprRootNode.getTypeInfo() == null ||
                    exprRootNode.getTypeInfo() instanceof NullTypeInfo)) {
                TypeRetriever retriever = env.getTypeRetriever();
                TypeInfo typeInfo = (!StringUtil.nullOrEmptyOrBlankString(expectedType) ?
                                 retriever.getTypeInfo(expectedType) :
                                 null);
                exprRootNode.setTypeInfo(typeInfo);

            }
View Full Code Here

                                     Node tree,
                                     Map semanticRecordMap,
                                     List errorCollector)
    {
        TypeRetriever retriever = env.getTypeRetriever();
        TypeInfo type = (!StringUtil.nullOrEmptyOrBlankString(rootType) ?
                         retriever.getTypeInfo(rootType) :
                         null);
        TypeChecker checker = new TypeChecker(env, type, thisField,
                                     semanticRecordMap, errorCollector);
        checker.check(tree);
View Full Code Here

    {
         boolean verifyReturnType = env.getBooleanEnvVariable(
                                             Environment.CheckReturnType, true);
         if (!StringUtil.nullOrEmptyOrBlankString(expectedType) && verifyReturnType) {
             TypeRetriever retriever = env.getTypeRetriever();
             TypeInfo convertedTo = retriever.getTypeInfo(expectedType);
             if (convertedTo != null) {
                 TypeInfo convertedFrom = tree.getTypeInfo();

                 // The return type is expected to be a container type.
                 if (!StringUtil.nullOrEmptyOrBlankString(containerType)) {

                     // Get the expected container type
                     TypeInfo toContainerType = retriever.getTypeInfo(containerType);
                     if (toContainerType == null) {
                         errors.add (Fmt.S(
                             "Cannot find type '%s' when evaluating the return value of the expression.",
                             toContainerType));
                         return;
View Full Code Here

    protected void handleArithmeticExpr (ExpressionNode node)
    {
        // If it is an addition, then do not return error.  The Add operator
        // is overloaded as concatenation.
        TypeInfo operandTypeInfo = checkNumericOperands(node, true,
                                                       !(node instanceof ASTAdd));
        if (operandTypeInfo != null) {
            addSemanticRecordToNode(node, operandTypeInfo);
        }
        else if (node instanceof ASTAdd) {
View Full Code Here

        addSemanticRecordToNode(node, getTypeInfo(node, Boolean.class.getName()));
    }

    protected void handleBitwiseExpr (ExpressionNode node)
    {
        TypeInfo operandTypeInfo = checkNumericOperands(node, false, true);
        if (operandTypeInfo != null) {
            addSemanticRecordToNode(node, operandTypeInfo);
        }
        else if (hasRootType()) {
            addError(node,
View Full Code Here

        }
    }

    protected void handleShiftExpr (ExpressionNode node)
    {
        TypeInfo operandTypeInfo = checkNumericOperands(node, false, true);
        if (operandTypeInfo != null) {
            addSemanticRecordToNode(node, operandTypeInfo);
        }
        else if (hasRootType()) {
            addError(node,
View Full Code Here

        checkOperandsType(ListUtil.list(testNode), node,
                          getTypeInfo(node, Boolean.class.getName()));

        // branches must be compatible
        List operands = ListUtil.list(trueNode, falseNode);
        TypeInfo operandTypeInfo = checkCompatibleOperands(node, operands, true);
        if (operandTypeInfo != null) {
            addSemanticRecordToNode(node, operandTypeInfo);
        }
        else if (hasRootType()) {
            addError(node,
View Full Code Here

        return checkCompatibleOperands(node, operands, addError);
    }

    private TypeInfo checkCompatibleOperands (Node node, List operands, boolean addError)
    {
        TypeInfo operandTypeInfo = null;

        for (int i=0; i < operands.size(); i++) {
            Node child = (Node)operands.get(i);
            TypeInfo info = getTypeInfoForNode(child);
            if (info != null) {
                if (operandTypeInfo == null ||
                    operandTypeInfo instanceof NullTypeInfo) {
                        operandTypeInfo = info;
                }
                else if (!operandTypeInfo.isCompatible(info) &&
                         !info.isCompatible(operandTypeInfo)) {
                    if (addError) {
                        addError(node, Fmt.S(
                            "Types of operands in expression '%s' are not compatible.",
                            node));
                    }
View Full Code Here

                                           boolean addError)
    {
        int numOfChild = node.jjtGetNumChildren();

        if (numOfChild > 0) {
            TypeInfo operandTypeInfo = null;

            for (int i=0; i < numOfChild; i++) {
                Node child = node.jjtGetChild(i);
                TypeInfo info = getTypeInfoForNode(child);
                if (info != null) {

                    // Is this a known numeric type or does it support
                    // arithmetic operations.
                    if (!PrimitiveTypeProvider.isNumericType(info) &&
                        !(info instanceof NullTypeInfo) &&
                        ArithmeticOperations.getByName(info.getName()) == null) {
                        if (addError) {
                            addError(node, Fmt.S(
                                "Operands in expression '%s' must be numeric.",
                                node));
                        }
                        return null;
                    }

                    // Is this a known floating point numeric?
                    if (PrimitiveTypeProvider.isNumericType(info)) {
                        // Do we allow floating point numeric?
                        if (!allowFloatingPoint &&
                             PrimitiveTypeProvider.isFloatingPointNumericType(info)) {
                             if (addError) {
                                 addError(node, Fmt.S(
                                    "Expression '%s' does not allow floating point operands.",
                                     node));
                             }
                            return null;
                        }
                    }

                    // Let's checkin if this operand is compatible with the others.
                    if (operandTypeInfo == null ||
                        operandTypeInfo instanceof NullTypeInfo) {
                        // first operand, nothing to compare.
                        operandTypeInfo = info;
                    }
                    else if (PrimitiveTypeProvider.isNumericType(operandTypeInfo) &&
                             PrimitiveTypeProvider.isNumericType(info)) {
                        // If the operands are both known numeric type, then
                        // look for a coerced type that can be the resulting
                        // type of containing expression.
                        TypeInfo coercedTypeInfo =
                            PrimitiveTypeProvider.getCoercedType(operandTypeInfo, info);
                        if (coercedTypeInfo != null) {
                            operandTypeInfo = coercedTypeInfo;
                        }
                    }
View Full Code Here

TOP

Related Classes of ariba.util.fieldtype.TypeInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.