4 import mir.generator.*;
6 public class GeneratorIntegerFunctions {
8 private GeneratorIntegerFunctions() {}
10 public static class incrementFunction implements Generator.GeneratorFunction {
11 public Object perform(List aParameters) throws GeneratorExc, GeneratorFailure {
12 int incrementValue = 1;
15 if (aParameters.size()>2 || aParameters.size()<1)
16 throw new GeneratorExc("incrementFunction: 1 or 2 parameters expected: value [increment value]");
18 if (aParameters.size()>1)
19 incrementValue = StringRoutines.interpretAsInteger(aParameters.get(1));
21 return new Integer(StringRoutines.interpretAsInteger(aParameters.get(0)) + incrementValue);
23 catch (GeneratorExc e) {
27 throw new GeneratorFailure("incrementFunction: " + t.getMessage(), t);
32 public static class isOddFunction implements Generator.GeneratorFunction {
33 public Object perform(List aParameters) throws GeneratorExc, GeneratorFailure {
35 if (aParameters.size()!=1)
36 throw new GeneratorExc("isOddFunction: 1 parameters expected: value");
38 return new Boolean((StringRoutines.interpretAsInteger(aParameters.get(0)) & 1) == 1);
40 catch (GeneratorExc e) {
44 throw new GeneratorFailure("isOddFunction: " + t.getMessage(), t);