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

com.scudata.expression.fn.math.Product Maven / Gradle / Ivy

Go to download

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

There is a newer version: 20241126
Show newest version
package com.scudata.expression.fn.math;

import com.scudata.common.MessageManager;
import com.scudata.common.RQException;
import com.scudata.dm.Context;
import com.scudata.dm.Sequence;
import com.scudata.expression.Function;
import com.scudata.expression.IParam;
import com.scudata.resources.EngineMessage;
import com.scudata.util.Variant;


/**
 * ?????г?Ա?ij˻??????????ij˻?,????ֵ??Ա??????
 * @author yanjing
 *
 */
public class Product extends Function {
	/**
	 * ??????ʽ????Ч?ԣ???Ч???׳??쳣
	 */
	public void checkValidity() {
		if (param == null) {
			MessageManager mm = EngineMessage.get();
			throw new RQException("product" + mm.getMessage("function.missingParam"));
		}
	}

	public Object calculate(Context ctx) {
		double result1=1;
		if(param.isLeaf()){
			Object result = param.getLeafExpression().calculate(ctx);
			if (result != null && result instanceof Number) {
				result1*=Variant.doubleValue(result);
			}else if(result != null && result instanceof Sequence){
				int n=((Sequence)result).length();
				for(int i=1;i<=n;i++){
					Object tmp=((Sequence)result).get(i);
					if (tmp!=null && tmp instanceof Number) {
						result1*=Variant.doubleValue(tmp);
					}
				}
			}
		}else{
			int size=param.getSubSize();
			for(int j=0;j




© 2015 - 2024 Weber Informatics LLC | Privacy Policy