public static String interpreterCall()

in src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/JspUtil.java [492:580]


    public static String interpreterCall(boolean isTagFile,
                     String expression,
                                         Class expectedType,
                                         String fnmapvar,
                                         boolean XmlEscape )
    {
        /*
         * Determine which context object to use.
         */
    String jspCtxt = null;
    if (isTagFile)
        jspCtxt = "this.getJspContext()";
    else
        jspCtxt = "_jspx_page_context";

    /*
         * Determine whether to use the expected type's textual name
     * or, if it's a primitive, the name of its correspondent boxed
     * type.
         */
    String targetType = expectedType.getName();
    String primitiveConverterMethod = null;
    if (expectedType.isPrimitive()) {
        if (expectedType.equals(Boolean.TYPE)) {
        targetType = Boolean.class.getName();
        primitiveConverterMethod = "booleanValue";
        } else if (expectedType.equals(Byte.TYPE)) {
        targetType = Byte.class.getName();
        primitiveConverterMethod = "byteValue";
        } else if (expectedType.equals(Character.TYPE)) {
        targetType = Character.class.getName();
        primitiveConverterMethod = "charValue";
        } else if (expectedType.equals(Short.TYPE)) {
        targetType = Short.class.getName();
        primitiveConverterMethod = "shortValue";
        } else if (expectedType.equals(Integer.TYPE)) {
        targetType = Integer.class.getName();
        primitiveConverterMethod = "intValue";
        } else if (expectedType.equals(Long.TYPE)) {
        targetType = Long.class.getName();
        primitiveConverterMethod = "longValue";
        } else if (expectedType.equals(Float.TYPE)) {
        targetType = Float.class.getName();
        primitiveConverterMethod = "floatValue";
        } else if (expectedType.equals(Double.TYPE)) {
        targetType = Double.class.getName();
        primitiveConverterMethod = "doubleValue";
        }
    }

    if (primitiveConverterMethod != null) {
        XmlEscape = false;
    }

    /*
         * Build up the base call to the interpreter.
         */
        // XXX - We use a proprietary call to the interpreter for now
        // as the current standard machinery is inefficient and requires
        // lots of wrappers and adapters.  This should all clear up once
        // the EL interpreter moves out of JSTL and into its own project.
        // In the future, this should be replaced by code that calls
        // ExpressionEvaluator.parseExpression() and then cache the resulting
        // expression objects.  The interpreterCall would simply select
        // one of the pre-cached expressions and evaluate it.
        // Note that PageContextImpl implements VariableResolver and
        // the generated Servlet/SimpleTag implements FunctionMapper, so
        // that machinery is already in place (mroth).
    targetType = toJavaSourceType(targetType);
    StringBuffer call = new StringBuffer(
             "(" + targetType + ") "
               + "org.apache.sling.scripting.jsp.jasper.runtime.PageContextImpl.proprietaryEvaluate"
               + "(" + Generator.quote(expression) + ", "
               +       targetType + ".class, "
           +       "(PageContext)" + jspCtxt
               +       ", " + fnmapvar
           + ", " + XmlEscape
               + ")");

    /*
         * Add the primitive converter method if we need to.
         */
    if (primitiveConverterMethod != null) {
        call.insert(0, "(");
        call.append(")." + primitiveConverterMethod + "()");
    }

    return call.toString();
    }