com.scudata.expression.ConstParam 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;
import com.scudata.array.BoolArray;
import com.scudata.array.ConstArray;
import com.scudata.array.IArray;
import com.scudata.dm.Context;
import com.scudata.dm.ParamList;
import com.scudata.dm.Sequence;
import com.scudata.util.Variant;
/**
* ?????????ڵ㣬ֵ???ɱ???
* @author RunQian
*
*/
public class ConstParam extends Node {
private String name;
private Object value;
public ConstParam(String name, Object value) {
this.name = name;
this.value = value;
}
protected boolean containParam(String name) {
return name.equals(this.name);
}
protected void getUsedParams(Context ctx, ParamList resultList) {
if (resultList.get(name) == null) {
resultList.addVariable(name, value);
}
}
public Object calculate(Context ctx) {
return value;
}
/**
* ??????????еĽ??
* @param ctx ??????????
* @return IArray
*/
public IArray calculateAll(Context ctx) {
Sequence sequence = ctx.getComputeStack().getTopSequence();
return new ConstArray(value, sequence.length());
}
/**
* ????signArray??ȡֵΪsign????
* @param ctx
* @param signArray ?б?ʶ????
* @param sign ??ʶ
* @return IArray
*/
public IArray calculateAll(Context ctx, IArray signArray, boolean sign) {
return calculateAll(ctx);
}
/**
* ?????????????&&???Ҳ????ʽ
* @param ctx ??????????
* @param leftResult &&??????ʽ?ļ?????
* @return BoolArray
*/
public BoolArray calculateAnd(Context ctx, IArray leftResult) {
BoolArray result = leftResult.isTrue();
if (Variant.isFalse(value)) {
int size = result.size();
for (int i = 1; i <= size; ++i) {
result.set(i, false);
}
}
return result;
}
/**
* ???ؽڵ??Ƿ???????
* @return true???ǵ????????ģ?false??????
*/
public boolean isMonotone() {
return true;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy