com.scudata.expression.mfn.sequence.Iterate Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of esproc Show documentation
Show all versions of esproc Show documentation
SPL(Structured Process Language) A programming language specially for structured data computing.
package com.scudata.expression.mfn.sequence;
import com.scudata.common.MessageManager;
import com.scudata.common.RQException;
import com.scudata.dm.Context;
import com.scudata.expression.Expression;
import com.scudata.expression.IParam;
import com.scudata.expression.SequenceFunction;
import com.scudata.resources.EngineMessage;
/**
* ??????ִ?е???????
* A.iterate(x,a,c)
* @author WangXiaoJun
*
*/
public class Iterate extends SequenceFunction {
/**
* ??????ʽ????Ч?ԣ???Ч???׳??쳣
*/
public void checkValidity() {
if (param == null) {
MessageManager mm = EngineMessage.get();
throw new RQException("iterate" + mm.getMessage("function.missingParam"));
}
}
public Object calculate(Context ctx) {
if (param.isLeaf()) {
Expression exp = param.getLeafExpression();
return srcSequence.iterate(exp, null, null, option, ctx);
} else {
int size = param.getSubSize();
if (size > 3) {
MessageManager mm = EngineMessage.get();
throw new RQException("iterate" + mm.getMessage("function.invalidParam"));
}
IParam sub0 = param.getSub(0);
if (sub0 == null || !sub0.isLeaf()) {
MessageManager mm = EngineMessage.get();
throw new RQException("iterate" + mm.getMessage("function.invalidParam"));
}
Expression exp = sub0.getLeafExpression();
Object initVal = null;
IParam sub1 = param.getSub(1);
if (sub1 != null) {
if (!sub1.isLeaf()) {
MessageManager mm = EngineMessage.get();
throw new RQException("iterate" + mm.getMessage("function.invalidParam"));
}
initVal = sub1.getLeafExpression().calculate(ctx);
}
Expression c = null;
if (size > 2) {
IParam sub2 = param.getSub(2);
if (!sub2.isLeaf()) {
MessageManager mm = EngineMessage.get();
throw new RQException("iterate" + mm.getMessage("function.invalidParam"));
}
c = sub2.getLeafExpression();
}
return srcSequence.iterate(exp, initVal, c, option, ctx);
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy