Java Code Examples for javax.el.FunctionMapper#resolveFunction()

The following examples show how to use javax.el.FunctionMapper#resolveFunction() . 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: AstFunction.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
@Override
public Class<?> getType(EvaluationContext ctx)
        throws ELException {

    FunctionMapper fnMapper = ctx.getFunctionMapper();

    // quickly validate again for this request
    if (fnMapper == null) {
        throw new ELException(MessageFactory.get("error.fnMapper.null"));
    }
    Method m = fnMapper.resolveFunction(this.prefix, this.localName);
    if (m == null) {
        throw new ELException(MessageFactory.get("error.fnMapper.method",
                this.getOutputName()));
    }
    return m.getReturnType();
}
 
Example 2
Source File: AstFunction.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
@Override
public Class<?> getType(EvaluationContext ctx)
        throws ELException {
    
    FunctionMapper fnMapper = ctx.getFunctionMapper();
    
    // quickly validate again for this request
    if (fnMapper == null) {
        throw new ELException(MessageFactory.get("error.fnMapper.null"));
    }
    Method m = fnMapper.resolveFunction(this.prefix, this.localName);
    if (m == null) {
        throw new ELException(MessageFactory.get("error.fnMapper.method",
                this.getOutputName()));
    }
    return m.getReturnType();
}
 
Example 3
Source File: AstFunction.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
@Override
public Class<?> getType(EvaluationContext ctx)
        throws ELException {
    
    FunctionMapper fnMapper = ctx.getFunctionMapper();
    
    // quickly validate again for this request
    if (fnMapper == null) {
        throw new ELException(MessageFactory.get("error.fnMapper.null"));
    }
    Method m = fnMapper.resolveFunction(this.prefix, this.localName);
    if (m == null) {
        throw new ELException(MessageFactory.get("error.fnMapper.method",
                this.getOutputName()));
    }
    return m.getReturnType();
}
 
Example 4
Source File: CompositeFunctionMapper.java    From camunda-engine-dmn with Apache License 2.0 5 votes vote down vote up
public Method resolveFunction(String prefix, String localName) {
  for (FunctionMapper functionMapper : functionMappers) {
    Method method = functionMapper.resolveFunction(prefix, localName);
    if (method != null) {
      return method;
    }
  }
  throw LOG.unknownFunction(prefix, localName);
}
 
Example 5
Source File: CompositeFunctionMapper.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public Method resolveFunction(String prefix, String localName) {
  for (FunctionMapper functionMapper : functionMappers) {
    Method method = functionMapper.resolveFunction(prefix, localName);
    if (method != null) {
      return method;
    }
  }
  throw LOG.unknownFunction(prefix, localName);
}
 
Example 6
Source File: AstFunction.java    From Tomcat7.0.67 with Apache License 2.0 4 votes vote down vote up
@Override
public Object getValue(EvaluationContext ctx)
        throws ELException {
    
    FunctionMapper fnMapper = ctx.getFunctionMapper();
    
    // quickly validate again for this request
    if (fnMapper == null) {
        throw new ELException(MessageFactory.get("error.fnMapper.null"));
    }
    Method m = fnMapper.resolveFunction(this.prefix, this.localName);
    if (m == null) {
        throw new ELException(MessageFactory.get("error.fnMapper.method",
                this.getOutputName()));
    }

    Class<?>[] paramTypes = m.getParameterTypes();
    Object[] params = null;
    Object result = null;
    int numParams = this.jjtGetNumChildren();
    if (numParams > 0) {
        params = new Object[numParams];
        try {
            for (int i = 0; i < numParams; i++) {
                params[i] = this.children[i].getValue(ctx);
                params[i] = coerceToType(params[i], paramTypes[i]);
            }
        } catch (ELException ele) {
            throw new ELException(MessageFactory.get("error.function", this
                    .getOutputName()), ele);
        }
    }
    try {
        result = m.invoke(null, params);
    } catch (IllegalAccessException iae) {
        throw new ELException(MessageFactory.get("error.function", this
                .getOutputName()), iae);
    } catch (InvocationTargetException ite) {
        Throwable cause = ite.getCause();
        if (cause instanceof ThreadDeath) {
            throw (ThreadDeath) cause;
        }
        if (cause instanceof VirtualMachineError) {
            throw (VirtualMachineError) cause;
        }
        throw new ELException(MessageFactory.get("error.function", this
                .getOutputName()), cause);
    }
    return result;
}
 
Example 7
Source File: AstFunction.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
@Override
public Object getValue(EvaluationContext ctx)
        throws ELException {
    
    FunctionMapper fnMapper = ctx.getFunctionMapper();
    
    // quickly validate again for this request
    if (fnMapper == null) {
        throw new ELException(MessageFactory.get("error.fnMapper.null"));
    }
    Method m = fnMapper.resolveFunction(this.prefix, this.localName);
    if (m == null) {
        throw new ELException(MessageFactory.get("error.fnMapper.method",
                this.getOutputName()));
    }

    Class<?>[] paramTypes = m.getParameterTypes();
    Object[] params = null;
    Object result = null;
    int numParams = this.jjtGetNumChildren();
    if (numParams > 0) {
        params = new Object[numParams];
        try {
            for (int i = 0; i < numParams; i++) {
                params[i] = this.children[i].getValue(ctx);
                params[i] = coerceToType(params[i], paramTypes[i]);
            }
        } catch (ELException ele) {
            throw new ELException(MessageFactory.get("error.function", this
                    .getOutputName()), ele);
        }
    }
    try {
        result = m.invoke(null, params);
    } catch (IllegalAccessException iae) {
        throw new ELException(MessageFactory.get("error.function", this
                .getOutputName()), iae);
    } catch (InvocationTargetException ite) {
        Throwable cause = ite.getCause();
        if (cause instanceof ThreadDeath) {
            throw (ThreadDeath) cause;
        }
        if (cause instanceof VirtualMachineError) {
            throw (VirtualMachineError) cause;
        }
        throw new ELException(MessageFactory.get("error.function", this
                .getOutputName()), cause);
    }
    return result;
}