All Downloads are FREE. Search and download functionalities are using the official Maven repository.

leap.lang.el.spel.ast.AstInvocable Maven / Gradle / Ivy

The newest version!
/*
 * Copyright 2014 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package leap.lang.el.spel.ast;

import leap.lang.Arrays2;
import leap.lang.el.ElEvalContext;

public abstract class AstInvocable extends AstExpr {

	protected String 	name;
	protected AstExpr[] parameters;
	
	public AstInvocable() {
	    super();
    }
	
	public AstInvocable(String name,AstExpr[] parameters) {
		this.name       = name;
		this.parameters = parameters;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public AstExpr[] getParameters() {
		return parameters;
	}

	@Override
    public void toString(StringBuilder buf) {
        buf.append(this.name);
        buf.append("(");
        for (int i = 0, size = this.parameters.length; i < size; ++i) {
            if (i != 0) {
                buf.append(", ");
            }

            this.parameters[i].toString(buf);
        }
        buf.append(")");
    }
	
    protected Object[] evalParameters(ElEvalContext context){
    	if(parameters.length == 0){
    		return Arrays2.EMPTY_OBJECT_ARRAY;
    	}else{
    		Object[] args = new Object[parameters.length];
    		for(int i=0;i




© 2015 - 2025 Weber Informatics LLC | Privacy Policy