Java Code Examples for javax.servlet.jsp.tagext.FunctionInfo#getFunctionSignature()

The following examples show how to use javax.servlet.jsp.tagext.FunctionInfo#getFunctionSignature() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Validator.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
/**
 * Get the method name from the signature.
 */
private String getMethod(ELNode.Function func) throws JasperException {
    FunctionInfo funcInfo = func.getFunctionInfo();
    String signature = funcInfo.getFunctionSignature();

    int start = signature.indexOf(' ');
    if (start < 0) {
        err.jspError("jsp.error.tld.fn.invalid.signature", func
                .getPrefix(), func.getName());
    }
    int end = signature.indexOf('(');
    if (end < 0) {
        err.jspError(
                "jsp.error.tld.fn.invalid.signature.parenexpected",
                func.getPrefix(), func.getName());
    }
    return signature.substring(start + 1, end).trim();
}
 
Example 2
Source File: Validator.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
/**
 * Get the method name from the signature.
 */
private String getMethod(ELNode.Function func) throws JasperException {
    FunctionInfo funcInfo = func.getFunctionInfo();
    String signature = funcInfo.getFunctionSignature();

    int start = signature.indexOf(' ');
    if (start < 0) {
        err.jspError("jsp.error.tld.fn.invalid.signature", func
                .getPrefix(), func.getName());
    }
    int end = signature.indexOf('(');
    if (end < 0) {
        err.jspError(
                "jsp.error.tld.fn.invalid.signature.parenexpected",
                func.getPrefix(), func.getName());
    }
    return signature.substring(start + 1, end).trim();
}
 
Example 3
Source File: Validator.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
/**
 * Get the method name from the signature.
 */
private String getMethod(ELNode.Function func) throws JasperException {
    FunctionInfo funcInfo = func.getFunctionInfo();
    String signature = funcInfo.getFunctionSignature();

    Matcher m = METHOD_NAME_PATTERN.matcher(signature);
    if (!m.matches()) {
        err.jspError("jsp.error.tld.fn.invalid.signature", func
                .getPrefix(), func.getName());
    }

    return m.group(1);
}
 
Example 4
Source File: Validator.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
/**
 * Get the parameters types from the function signature.
 *
 * @return An array of parameter class names
 */
private String[] getParameters(ELNode.Function func)
        throws JasperException {
    FunctionInfo funcInfo = func.getFunctionInfo();
    String signature = funcInfo.getFunctionSignature();
    ArrayList<String> params = new ArrayList<>();
    // Signature is of the form
    // <return-type> S <method-name S? '('
    // < <arg-type> ( ',' <arg-type> )* )? ')'
    int start = signature.indexOf('(') + 1;
    boolean lastArg = false;
    while (true) {
        int p = signature.indexOf(',', start);
        if (p < 0) {
            p = signature.indexOf(')', start);
            if (p < 0) {
                err.jspError("jsp.error.tld.fn.invalid.signature", func
                        .getPrefix(), func.getName());
            }
            lastArg = true;
        }
        String arg = signature.substring(start, p).trim();
        if (!"".equals(arg)) {
            params.add(arg);
        }
        if (lastArg) {
            break;
        }
        start = p + 1;
    }
    return params.toArray(new String[params.size()]);
}
 
Example 5
Source File: Validator.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
/**
 * Get the parameters types from the function signature.
 *
 * @return An array of parameter class names
 */
private String[] getParameters(ELNode.Function func)
        throws JasperException {
    FunctionInfo funcInfo = func.getFunctionInfo();
    String signature = funcInfo.getFunctionSignature();
    ArrayList<String> params = new ArrayList<String>();
    // Signature is of the form
    // <return-type> S <method-name S? '('
    // < <arg-type> ( ',' <arg-type> )* )? ')'
    int start = signature.indexOf('(') + 1;
    boolean lastArg = false;
    while (true) {
        int p = signature.indexOf(',', start);
        if (p < 0) {
            p = signature.indexOf(')', start);
            if (p < 0) {
                err.jspError("jsp.error.tld.fn.invalid.signature", func
                        .getPrefix(), func.getName());
            }
            lastArg = true;
        }
        String arg = signature.substring(start, p).trim();
        if (!"".equals(arg)) {
            params.add(arg);
        }
        if (lastArg) {
            break;
        }
        start = p + 1;
    }
    return params.toArray(new String[params.size()]);
}
 
Example 6
Source File: Validator.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
/**
 * Get the parameters types from the function signature.
 *
 * @return An array of parameter class names
 */
private String[] getParameters(ELNode.Function func)
        throws JasperException {
    FunctionInfo funcInfo = func.getFunctionInfo();
    String signature = funcInfo.getFunctionSignature();
    ArrayList<String> params = new ArrayList<String>();
    // Signature is of the form
    // <return-type> S <method-name S? '('
    // < <arg-type> ( ',' <arg-type> )* )? ')'
    int start = signature.indexOf('(') + 1;
    boolean lastArg = false;
    while (true) {
        int p = signature.indexOf(',', start);
        if (p < 0) {
            p = signature.indexOf(')', start);
            if (p < 0) {
                err.jspError("jsp.error.tld.fn.invalid.signature", func
                        .getPrefix(), func.getName());
            }
            lastArg = true;
        }
        String arg = signature.substring(start, p).trim();
        if (!"".equals(arg)) {
            params.add(arg);
        }
        if (lastArg) {
            break;
        }
        start = p + 1;
    }
    return params.toArray(new String[params.size()]);
}
 
Example 7
Source File: Validator.java    From packagedrone with Eclipse Public License 1.0 5 votes vote down vote up
private void processSignature(ELNode.Function func)
	throws JasperException {
    FunctionInfo funcInfo = func.getFunctionInfo();
    String signature = funcInfo.getFunctionSignature();
    func.setMethodName(getMethod(signature));
    func.setParameters(getParameters(signature));
}