Search in sources :

Example 1 with VariableInfo

use of javax.servlet.jsp.tagext.VariableInfo in project sonarqube by SonarSource.

the class IterateTei method getVariableInfo.

/**
     * Return information about the scripting variables to be created.
     */
public VariableInfo[] getVariableInfo(TagData data) {
    // prime this array with the maximum potential variables.
    // will be arraycopy'd out to the final array based on results.
    VariableInfo[] variables = new VariableInfo[2];
    // counter for matched results.
    int counter = 0;
    /* id : object of the current iteration */
    String id = data.getAttributeString("id");
    String type = data.getAttributeString("type");
    if (id != null) {
        if (type == null) {
            type = "java.lang.Object";
        }
        variables[counter++] = new VariableInfo(data.getAttributeString("id"), type, true, VariableInfo.NESTED);
    }
    /* indexId : number value of the current iteration */
    String indexId = data.getAttributeString("indexId");
    if (indexId != null) {
        variables[counter++] = new VariableInfo(indexId, "java.lang.Integer", true, VariableInfo.NESTED);
    }
    /* create returning array, and copy results */
    VariableInfo[] result;
    if (counter > 0) {
        result = new VariableInfo[counter];
        System.arraycopy(variables, 0, result, 0, counter);
    } else {
        result = new VariableInfo[0];
    }
    return result;
}
Also used : VariableInfo(javax.servlet.jsp.tagext.VariableInfo)

Example 2 with VariableInfo

use of javax.servlet.jsp.tagext.VariableInfo in project sonarqube by SonarSource.

the class NestedDefineTei method getVariableInfo.

/**
     * Return information about the scripting variables to be created.
     */
public VariableInfo[] getVariableInfo(TagData data) {
    // get the type
    String type = (String) data.getAttribute("type");
    // make it an object if none supplied
    if (type == null) {
        type = "java.lang.Object";
    }
    // return the infor about the deined object
    VariableInfo[] vinfo = new VariableInfo[1];
    vinfo[0] = new VariableInfo(data.getAttributeString("id"), type, true, VariableInfo.AT_END);
    /* return the results */
    return vinfo;
}
Also used : VariableInfo(javax.servlet.jsp.tagext.VariableInfo)

Example 3 with VariableInfo

use of javax.servlet.jsp.tagext.VariableInfo in project sling by apache.

the class Generator method declareTemporaryScriptingVars.

private void declareTemporaryScriptingVars(Node.Nodes page) throws JasperException {
    class ScriptingVarVisitor extends Node.Visitor {

        private Vector vars;

        ScriptingVarVisitor() {
            vars = new Vector();
        }

        @Override
        public void visit(Node.CustomTag n) throws JasperException {
            if (n.getCustomNestingLevel() > 0) {
                TagVariableInfo[] tagVarInfos = n.getTagVariableInfos();
                VariableInfo[] varInfos = n.getVariableInfos();
                if (varInfos.length > 0) {
                    for (int i = 0; i < varInfos.length; i++) {
                        String varName = varInfos[i].getVarName();
                        String tmpVarName = "_jspx_" + varName + "_" + n.getCustomNestingLevel();
                        if (!vars.contains(tmpVarName)) {
                            vars.add(tmpVarName);
                            out.printin(varInfos[i].getClassName());
                            out.print(" ");
                            out.print(tmpVarName);
                            out.print(" = ");
                            out.print(null);
                            out.println(";");
                        }
                    }
                } else {
                    for (int i = 0; i < tagVarInfos.length; i++) {
                        String varName = tagVarInfos[i].getNameGiven();
                        if (varName == null) {
                            varName = n.getTagData().getAttributeString(tagVarInfos[i].getNameFromAttribute());
                        } else if (tagVarInfos[i].getNameFromAttribute() != null) {
                            // alias
                            continue;
                        }
                        String tmpVarName = "_jspx_" + varName + "_" + n.getCustomNestingLevel();
                        if (!vars.contains(tmpVarName)) {
                            vars.add(tmpVarName);
                            out.printin(tagVarInfos[i].getClassName());
                            out.print(" ");
                            out.print(tmpVarName);
                            out.print(" = ");
                            out.print(null);
                            out.println(";");
                        }
                    }
                }
            }
            visitBody(n);
        }
    }
    page.visit(new ScriptingVarVisitor());
}
Also used : VariableInfo(javax.servlet.jsp.tagext.VariableInfo) TagVariableInfo(javax.servlet.jsp.tagext.TagVariableInfo) TagVariableInfo(javax.servlet.jsp.tagext.TagVariableInfo) Vector(java.util.Vector)

Example 4 with VariableInfo

use of javax.servlet.jsp.tagext.VariableInfo in project sonarqube by SonarSource.

the class NestedWriteNestingTei method getVariableInfo.

/**
     * Return information about the scripting variables to be created.
     */
public VariableInfo[] getVariableInfo(TagData data) {
    /* the id parameter */
    String id = data.getAttributeString("id");
    VariableInfo[] vi = null;
    if (id != null) {
        vi = new VariableInfo[1];
        vi[0] = new VariableInfo(id, "java.lang.String", true, VariableInfo.AT_END);
    } else {
        vi = new VariableInfo[0];
    }
    // job done
    return vi;
}
Also used : VariableInfo(javax.servlet.jsp.tagext.VariableInfo)

Aggregations

VariableInfo (javax.servlet.jsp.tagext.VariableInfo)4 Vector (java.util.Vector)1 TagVariableInfo (javax.servlet.jsp.tagext.TagVariableInfo)1