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

com.scudata.expression.fn.convert.IfVariable Maven / Gradle / Ivy

Go to download

SPL(Structured Process Language) A programming language specially for structured data computing.

There is a newer version: 20240823
Show newest version
package com.scudata.expression.fn.convert;

import java.util.List;

import com.scudata.cellset.INormalCell;
import com.scudata.common.MessageManager;
import com.scudata.common.RQException;
import com.scudata.dm.Context;
import com.scudata.dm.ParamList;
import com.scudata.expression.Function;
import com.scudata.expression.Node;
import com.scudata.resources.EngineMessage;
import com.scudata.util.EnvUtil;

/**
 * ifv(name) ?????Ƿ????
 * @author RunQian
 *
 */
public class IfVariable extends Function {
	public Node optimize(Context ctx) {
		param.optimize(ctx);
		return this;
	}
	
	/**
	 * ??????ʽ????Ч?ԣ???Ч???׳??쳣
	 */
	public void checkValidity() {
		if (param == null) {
			MessageManager mm = EngineMessage.get();
			throw new RQException("ifv" + mm.getMessage("function.missingParam"));
		} else if (!param.isLeaf()) {
			MessageManager mm = EngineMessage.get();
			throw new RQException("ifv" + mm.getMessage("function.invalidParam"));
		}
	}

	public Object calculate(Context ctx) {
		String name = param.getLeafExpression().getIdentifierName();
		if (EnvUtil.getParam(name, ctx) == null) {
			return Boolean.FALSE;
		} else {
			return Boolean.TRUE;
		}
	}

	protected boolean containParam(String name) {
		return false;
	}

	protected void getUsedParams(Context ctx, ParamList resultList) {
	}
	
	public void getUsedFields(Context ctx, List resultList) {
	}
	
	protected void getUsedCells(List resultList) {
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy