FileDocCategorySizeDatePackage
AstFunction.javaAPI DocGlassfish v2 API5423Fri May 04 22:31:20 BST 2007com.sun.el.parser

AstFunction

public final class AstFunction extends SimpleNode
author
Jacob Hookom [jacob@hookom.net]
version
$Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: tcfujii $

Fields Summary
protected String
localName
protected String
prefix
Constructors Summary
public AstFunction(int id)


       
        super(id);
    
Methods Summary
public java.lang.StringgetLocalName()

        return localName;
    
public java.lang.StringgetOutputName()

        if (this.prefix == null) {
            return this.localName;
        } else {
            return this.prefix + ":" + this.localName;
        }
    
public java.lang.StringgetPrefix()

        return prefix;
    
public java.lang.ClassgetType(com.sun.el.lang.EvaluationContext ctx)

        
        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();
    
public java.lang.ObjectgetValue(com.sun.el.lang.EvaluationContext ctx)

        
        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) {
            throw new ELException(MessageFactory.get("error.function", this
                    .getOutputName()), ite.getCause());
        }
        return result;
    
public voidsetLocalName(java.lang.String localName)

        this.localName = localName;
    
public voidsetPrefix(java.lang.String prefix)

        this.prefix = prefix;
    
public java.lang.StringtoString()

        return ELParserTreeConstants.jjtNodeName[id] + "[" + this.getOutputName() + "]";