/** * 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(); }
/** * 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()]); }
FunctionInfo createFunctionInfo(TreeNode elem) { String name = null; String klass = null; String signature = null; Iterator<TreeNode> list = elem.findChildren(); while (list.hasNext()) { TreeNode element = list.next(); String tname = element.getName(); if ("name".equals(tname)) { name = element.getBody(); } else if ("function-class".equals(tname)) { klass = element.getBody(); } else if ("function-signature".equals(tname)) { signature = element.getBody(); } else if ("display-name".equals(tname) || // Ignored elements "small-icon".equals(tname) || "large-icon".equals(tname) || "description".equals(tname) || "example".equals(tname)) { } else { if (log.isWarnEnabled()) { log.warn(Localizer.getMessage( "jsp.warning.unknown.element.in.function", tname)); } } } return new FunctionInfo(name, klass, signature); }
/** * 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 (String[]) params.toArray(new String[params.size()]); }
FunctionInfo createFunctionInfo(TreeNode elem) { String name = null; String klass = null; String signature = null; Iterator list = elem.findChildren(); while (list.hasNext()) { TreeNode element = (TreeNode) list.next(); String tname = element.getName(); if ("name".equals(tname)) { name = element.getBody(); } else if ("function-class".equals(tname)) { klass = element.getBody(); } else if ("function-signature".equals(tname)) { signature = element.getBody(); } else if ("display-name".equals(tname) || // Ignored elements "small-icon".equals(tname) || "large-icon".equals(tname) || "description".equals(tname) || "example".equals(tname)) { } else { log.warn(Localizer.getMessage( "jsp.warning.unknown.element.in.function", tname)); } } return new FunctionInfo(name, klass, signature); }
/** * 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(); }
/** * 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()]); }
FunctionInfo createFunctionInfo(TreeNode elem) { String name = null; String klass = null; String signature = null; Iterator<TreeNode> list = elem.findChildren(); while (list.hasNext()) { TreeNode element = list.next(); String tname = element.getName(); if ("name".equals(tname)) { name = element.getBody(); } else if ("function-class".equals(tname)) { klass = element.getBody(); } else if ("function-signature".equals(tname)) { signature = element.getBody(); } else if ("display-name".equals(tname) || // Ignored elements "small-icon".equals(tname) || "large-icon".equals(tname) || "description".equals(tname) || "example".equals(tname)) { } else { if (log.isWarnEnabled()) { log.warn(Localizer.getMessage("jsp.warning.unknown.element.in.function", tname)); } } } return new FunctionInfo(name, klass, signature); }
private void processSignature(ELNode.Function func) throws JasperException { FunctionInfo funcInfo = func.getFunctionInfo(); String signature = funcInfo.getFunctionSignature(); func.setMethodName(getMethod(signature)); func.setParameters(getParameters(signature)); }
private FunctionInfo createFunctionInfo(TreeNode elem) throws JasperException { String name = null; String klass = null; String signature = null; Iterator list = elem.findChildren(); while (list.hasNext()) { TreeNode element = (TreeNode) list.next(); String tname = element.getName(); if ("name".equals(tname)) { name = element.getBody(); } else if ("function-class".equals(tname)) { klass = element.getBody(); } else if ("function-signature".equals(tname)) { signature = element.getBody(); } else if ("display-name".equals(tname) || // Ignored elements "small-icon".equals(tname) || "large-icon".equals(tname) || "description".equals(tname) || "example".equals(tname)) { } else { err.jspError("jsp.error.unknown.element.in.function", tname); } } return new FunctionInfo(name, klass, signature); }
public void setFunctionInfo(FunctionInfo f) { this.functionInfo = f; }
public FunctionInfo getFunctionInfo() { return functionInfo; }
public void addFunction(String name, String klass, String signature) { functions.add(new FunctionInfo(name, klass, signature)); }
public List<FunctionInfo> getFunctions() { return functions; }