@@ -0,0 +1,1659 @@
+/*%0A * JaamSim Discrete Event Simulation%0A * Copyright (C) 2014 Ausenco Engineering Canada Inc.%0A *%0A * This program is free software: you can redistribute it and/or modify%0A * it under the terms of the GNU General Public License as published by%0A * the Free Software Foundation, either version 3 of the License, or%0A * (at your option) any later version.%0A *%0A * This program is distributed in the hope that it will be useful,%0A * but WITHOUT ANY WARRANTY; without even the implied warranty of%0A * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the%0A * GNU General Public License for more details.%0A */%0Apackage com.jaamsim.input;%0A%0Aimport com.jaamsim.input.ExpParser.Expression;%0Aimport com.sandwell.JavaSimulation.Entity;%0Aimport com.sandwell.JavaSimulation.InputErrorException;%0Aimport com.sandwell.JavaSimulation.StringVector;%0A%0Apublic class ExpressionInput extends Input%3CExpParser.Expression%3E %7B%0A%09private Entity thisEnt;%0A%0A%09public ExpressionInput(String key, String cat, ExpParser.Expression def) %7B%0A%09%09super(key, cat, def);%0A%09%7D%0A%0A%09public void setEntity(Entity ent) %7B%0A%09%09thisEnt = ent;%0A%09%7D%0A%0A%09@Override%0A%09public void parse(StringVector input)%0A%09throws InputErrorException %7B%0A%0A%09%09try %7B%0A%09%09%09Input.assertCount(input, 1);%0A%09%09%09Expression exp = ExpParser.parseExpression(input.get(0));%0A%0A%09%09%09// Test whether the expression can be evaluated%0A%09%09%09try %7B%0A%09%09%09%09@SuppressWarnings(%22unused%22)%0A%09%09%09%09double x = ExpEvaluator.evaluateExpression(exp, 0.0, thisEnt, null).value;%0A%09%09%09%7D catch (ExpEvaluator.Error e) %7B%0A%09%09%09%09throw new InputErrorException(e.toString());%0A%09%09%09%7D%0A%0A%09%09%09// Save the expression%0A%09%09%09value = exp;%0A%0A%09%09%7D catch (ExpParser.Error e) %7B%0A%09%09%09throw new InputErrorException(e.toString());%0A%09%09%7D%0A%09%7D%0A%0A%7D%0A

Add input object "ExpressionInput"