Package ognl.enhance

Examples of ognl.enhance.UnsupportedCompilationException


        } catch (NullPointerException e) {
           
            // expected to happen in some instances
            e.printStackTrace();
           
            throw new UnsupportedCompilationException("evaluation resulted in null expression.");
        } catch (Throwable t)
        {
            throw OgnlOps.castToRuntime(t);
        }
    }
View Full Code Here


       
        context.setCurrentObject(value);
        //context.setRoot(context.get(_name));
       
        if (context.getCurrentObject() == null)
            throw new UnsupportedCompilationException("Current context object is null, can't compile var reference.");

        String pre = "";
        String post = "";
        if (context.getCurrentType() != null) {
            pre = "((" + OgnlRuntime.getCompiler().getInterfaceClass(context.getCurrentType()).getName() + ")";
View Full Code Here

        return "#this";
    }
   
    public String toGetSourceString(OgnlContext context, Object target)
    {
        throw new UnsupportedCompilationException("Unable to compile this references.");
    }
View Full Code Here

        throw new UnsupportedCompilationException("Unable to compile this references.");
    }
   
    public String toSetSourceString(OgnlContext context, Object target)
    {
        throw new UnsupportedCompilationException("Unable to compile this references.");
    }
View Full Code Here

    public abstract String getComparisonFunction();
   
    public String toGetSourceString(OgnlContext context, Object target)
    {
        if (target == null)
            throw new UnsupportedCompilationException("Current target is null, can't compile.");
       
        try {
           
            Object value = getValueBody(context, target);
           
            if (value != null && Boolean.class.isAssignableFrom(value.getClass()))
                _getterClass = Boolean.TYPE;
            else if (value != null)
                _getterClass = value.getClass();
            else
                _getterClass = Boolean.TYPE;
           
            // iterate over children to make numeric type detection work properly
           
            OgnlRuntime.getChildSource(context, target, _children[0]);
            OgnlRuntime.getChildSource(context, target, _children[1]);
           
//            System.out.println("comparison expression currentType: " + context.getCurrentType() + " previousType: " + context.getPreviousType());

            boolean conversion = OgnlRuntime.shouldConvertNumericTypes(context);

            String result = conversion ? "(" + getComparisonFunction() + "( ($w) (" : "(";
           
            result += OgnlRuntime.getChildSource(context, target, _children[0], conversion)
            + " "
            + (conversion ? "), ($w) " : getExpressionOperator(0)) + " "
            + OgnlRuntime.getChildSource(context, target, _children[1], conversion);
           
            result += conversion ? ")" : "";

            context.setCurrentType(Boolean.TYPE);

            result += ")";

            return result;
        } catch (NullPointerException e) {
           
            // expected to happen in some instances
           
            throw new UnsupportedCompilationException("evaluation resulted in null expression.");
        } catch (Throwable t)
        {
            throw OgnlOps.castToRuntime(t);
        }
    }
View Full Code Here

    }
   
    public String toGetSourceString(OgnlContext context, Object target)
    {
        if (target == null)
            throw new UnsupportedCompilationException("evaluation resulted in null expression.");

        if (_children.length != 3)
            throw new UnsupportedCompilationException("Can only compile test expressions with two children." + _children.length);

        String result = "";
       
        try {

            String first = OgnlRuntime.getChildSource(context, target, _children[0]);           
            if (!OgnlRuntime.isBoolean(first) && !context.getCurrentType().isPrimitive())
                first = OgnlRuntime.getCompiler().createLocalReference(context, first, context.getCurrentType());
           
            if (ExpressionNode.class.isInstance(_children[0]))
            {
                first = "(" + first + ")";
            }
           
            String second = OgnlRuntime.getChildSource(context, target, _children[1]);
            Class secondType = context.getCurrentType();

            if (!OgnlRuntime.isBoolean(second) && !context.getCurrentType().isPrimitive())
                second = OgnlRuntime.getCompiler().createLocalReference(context, second, context.getCurrentType());

            if (ExpressionNode.class.isInstance(_children[1]))
            {
                second = "(" + second + ")";
            }

            String third = OgnlRuntime.getChildSource(context, target, _children[2]);
            Class thirdType = context.getCurrentType();
           
            if (!OgnlRuntime.isBoolean(third) && !context.getCurrentType().isPrimitive())
                third = OgnlRuntime.getCompiler().createLocalReference(context, third, context.getCurrentType());
            if (ExpressionNode.class.isInstance(_children[2]))
            {
                third = "(" + third + ")";
            }

            boolean mismatched = (secondType.isPrimitive() && !thirdType.isPrimitive())
                                || (!secondType.isPrimitive() && thirdType.isPrimitive()) ? true : false;

            result += "ognl.OgnlOps.booleanValue(" + first + ")";

            result += " ? ";

            result += (mismatched ? " ($w) " : "") + second;
            result += " : ";

            result += (mismatched ? " ($w) " : "") + third;

            context.setCurrentObject(target);
            context.setCurrentType(mismatched ? Object.class : secondType);

            return result;
       
        } catch (NullPointerException e) {
           
            // expected to happen in some instances
            throw new UnsupportedCompilationException("evaluation resulted in null expression.");
        } catch (Throwable t)
        {
            throw OgnlOps.castToRuntime(t);
        }
    }
View Full Code Here

            {
                m = OgnlRuntime.getWriteMethod(target.getClass(), context.getCurrentObject().toString().replaceAll("\"", ""));
            }

            if (m == null || m.getParameterTypes() == null || m.getParameterTypes().length <= 0)
                throw new UnsupportedCompilationException("Unable to determine setting expression on " + context.getCurrentObject()
                                                          + " with index of " + index);

            Class parm = m.getParameterTypes()[0];
            String conversion;

            if (m.getParameterTypes().length > 1)
                throw new UnsupportedCompilationException("Object property accessors can only support single parameter setters.");


            if (parm.isPrimitive())
            {
                Class wrapClass = OgnlRuntime.getPrimitiveWrapperClass(parm);
View Full Code Here

        return result + " }";
    }
   
    public String toGetSourceString(OgnlContext context, Object target)
    {
        throw new UnsupportedCompilationException("Map expressions not supported as native java yet.");
    }
View Full Code Here

        throw new UnsupportedCompilationException("Map expressions not supported as native java yet.");
    }
   
    public String toSetSourceString(OgnlContext context, Object target)
    {
        throw new UnsupportedCompilationException("Map expressions not supported as native java yet.");
    }
View Full Code Here

    }

    public String toGetSourceString(OgnlContext context, Object target)
    {
        if (_children.length != 2)
            throw new UnsupportedCompilationException("Can only compile boolean expressions with two children.");
       
        String result = "";
       
        try {

            String first = OgnlRuntime.getChildSource(context, target, _children[0]);
            if (!OgnlOps.booleanValue(context.getCurrentObject()))
            {
                throw new UnsupportedCompilationException("And expression can't be compiled until all conditions are true.");
            }

            if (!OgnlRuntime.isBoolean(first) && !context.getCurrentType().isPrimitive())
                first = OgnlRuntime.getCompiler().createLocalReference(context, first, context.getCurrentType());

            String second = OgnlRuntime.getChildSource(context, target, _children[1]);
            if (!OgnlRuntime.isBoolean(second) && !context.getCurrentType().isPrimitive())
                second = OgnlRuntime.getCompiler().createLocalReference(context, second, context.getCurrentType());

            result += "(ognl.OgnlOps.booleanValue(" + first + ")";
           
            result += " ? ";

            result += " ($w) ("  + second + ")";
            result += " : ";

            result += " ($w) (" + first + ")";

            result += ")";

            context.setCurrentObject(target);
            context.setCurrentType(Object.class);
        } catch (NullPointerException e) {
           
            throw new UnsupportedCompilationException("evaluation resulted in null expression.");
        } catch (Throwable t)
        {
            throw OgnlOps.castToRuntime(t);
        }
       
View Full Code Here

TOP

Related Classes of ognl.enhance.UnsupportedCompilationException

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.