use of org.btrplace.btrpsl.element.BtrpString in project scheduler by btrplace.
the class ScriptBuilderTest method testStringSupport.
public void testStringSupport() throws ScriptBuilderException {
ScriptBuilder b = new ScriptBuilder(new DefaultModel());
Script v = b.build("namespace foo; VM[1..10] : tiny;\n$arr = {\"foo\",\"bar\", \"baz\"};$arr2 = $arr + {\"git\"}; $out = \"come \" + \"out \" + 5 + \" \" + VM1; export $arr2,$out to *;");
BtrpString out = (BtrpString) v.getImportable("$out");
BtrpSet arr2 = (BtrpSet) v.getImportable("$arr2");
Assert.assertEquals(out.toString(), "come out 5 foo.VM1");
Assert.assertEquals(arr2.size(), 4);
}
use of org.btrplace.btrpsl.element.BtrpString in project scheduler by btrplace.
the class EnumVar method expand.
/**
* Expand the enumeration.
* Variables are not evaluated nor checked
*
* @return a set of string or an error
*/
public BtrpOperand expand() {
String head = getChild(0).getText().substring(0, getChild(0).getText().length() - 1);
String tail = getChild(getChildCount() - 1).getText().substring(1);
BtrpSet res = new BtrpSet(1, BtrpOperand.Type.STRING);
for (int i = 1; i < getChildCount() - 1; i++) {
BtrpOperand op = getChild(i).go(this);
if (op == IgnorableOperand.getInstance()) {
return op;
}
BtrpSet s = (BtrpSet) op;
for (BtrpOperand o : s.getValues()) {
// Compose
res.getValues().add(new BtrpString(head + o.toString() + tail));
}
}
return res;
}
Aggregations