本文整理汇总了Java中net.objecthunter.exp4j.Expression.setVariable方法的典型用法代码示例。如果您正苦于以下问题:Java Expression.setVariable方法的具体用法?Java Expression.setVariable怎么用?Java Expression.setVariable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.objecthunter.exp4j.Expression
的用法示例。
在下文中一共展示了Expression.setVariable方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processCondition
import net.objecthunter.exp4j.Expression; //导入方法依赖的package包/类
public int processCondition( int depth, Random ran, boolean isBoss )
{
if ( Global.isNumber( spawnEquation ) )
{
return Integer.parseInt( spawnEquation );
}
else
{
ExpressionBuilder expB = EquationHelper.createEquationBuilder( spawnEquation, ran );
expB.variable( "depth" );
expB.variable( "boss" );
Expression exp = EquationHelper.tryBuild( expB );
if ( exp == null ) { return 0; }
exp.setVariable( "depth", depth );
exp.setVariable( "boss", isBoss ? 1 : 0 );
int val = (int) exp.evaluate();
return val;
}
}
示例2: height
import net.objecthunter.exp4j.Expression; //导入方法依赖的package包/类
int height(Expression e, int x, int z) {
try {
e.setVariable("x", x);
e.setVariable("z", z);
int evaluate = (int) e.evaluate();
return evaluate < 0 ? -1 : evaluate;
} catch (Exception exception) {
return -1;
}
}
示例3: value
import net.objecthunter.exp4j.Expression; //导入方法依赖的package包/类
@Override
public void value(StringBuilder buff, long millisElapsed, int ticks) {
Expression expr = expressionTemplate.build();
int adjustedTicks = ticks + tickOffset;
double scaledTick = adjustedTicks / (double) scaleFactorTick;
expr.setVariable("tick", scaledTick);
long adjustedElapsed = millisElapsed + elapsedOffset;
double scaledElapsed = adjustedElapsed / (double) scaleFactorElapsed;
expr.setVariable("elapsed", scaledElapsed);
buff.append(expr.evaluate());
}
示例4: load
import net.objecthunter.exp4j.Expression; //导入方法依赖的package包/类
public static FastEnumMap<Statistic, Integer> load( Element xml, FastEnumMap<Statistic, Integer> values )
{
for ( int i = 0; i < xml.getChildCount(); i++ )
{
Element el = xml.getChild( i );
Statistic stat = Statistic.valueOf( el.getName().toUpperCase() );
String eqn = el.getText().toLowerCase();
int newVal = values.get( stat );
if ( Global.isNumber( eqn ) )
{
newVal = Integer.parseInt( eqn );
}
else
{
ExpressionBuilder expB = EquationHelper.createEquationBuilder( eqn );
expB.variable( "value" );
expB.variable( "val" );
Expression exp = EquationHelper.tryBuild( expB );
if ( exp != null )
{
exp.setVariable( "value", newVal );
exp.setVariable( "val", newVal );
newVal = (int) exp.evaluate();
}
}
values.put( stat, newVal );
}
return values;
}
示例5: setVariableValues
import net.objecthunter.exp4j.Expression; //导入方法依赖的package包/类
public static void setVariableValues( Expression exp, HashMap<String, Integer> variableMap, String prefix )
{
for ( String key : variableMap.keySet() )
{
exp.setVariable( prefix + key, variableMap.get( key ) );
}
}
示例6: map
import net.objecthunter.exp4j.Expression; //导入方法依赖的package包/类
@Override
protected Double map(final Traverser.Admin<S> traverser) {
final Expression localExpression = new Expression(this.expression);
for (final String var : this.variables) {
localExpression.setVariable(var,
var.equals(CURRENT) ?
TraversalUtil.applyNullable(traverser, this.traversalRing.next()).doubleValue() :
TraversalUtil.applyNullable((S) this.getNullableScopeValue(Pop.last, var, traverser), this.traversalRing.next()).doubleValue());
}
this.traversalRing.reset();
return localExpression.evaluate();
}
示例7: test
import net.objecthunter.exp4j.Expression; //导入方法依赖的package包/类
@Test
public void test() {
Expression expression = new TALibExpressionBuilder(set,"C>SMA(c,20)").build();
set.begin();
while (set.next()){
expression.setVariable("C", set.getRow().getClose());
double expressionResult = expression.evaluate();
System.out.println(expressionResult);
assertNotEquals(expressionResult, 0);
}
set.reset();
}