private DSLVariableValue parseValue(String variable) { //if the variable doesn't have a ':', then it is considered as a //simple value if ( !variable.contains( ":" ) ) { return new DSLVariableValue(variable); } //if it does containt a ':', then the part before it is considered //as the real value (used to create the final drl) and the part //after it is considered as an id String value = variable.substring( 0, variable.indexOf( ":" ) ); String id = variable.substring( variable.indexOf( ":" )+1); return new DSLComplexVariableValue(id, value); }
private DSLVariableValue parseValue(String variable) { //if the variable doesn't have a ':', then it is considered as a //simple value if ( !variable.contains( ":" ) ) { return new DSLVariableValue(variable); } //if it does containt a ':', then the part before it is considered //as the real value (used to create the final drl) and the part //after it is considered as an id String value = variable.substring( 0, variable.indexOf( ":" ) ); String id = variable.substring( variable.indexOf( ":" )+1); return new DSLComplexVariableValue(id, value); }
@Test public void testDSLComplexVariableValueInterpolation() { final DSLSentence sen = new DSLSentence(); sen.setDefinition( "a {here} and {here}" ); sen.getValues().set( 0, new DSLComplexVariableValue("123","word")); sen.getValues().set( 1, new DSLComplexVariableValue("some-other-value","word") ); assertEquals( "a word and word", sen.interpolate() ); }