use of com.dexels.navajo.document.Operand in project navajo by Dexels.
the class ToMoney method main.
public static void main(String[] args) throws Exception {
java.util.Locale.setDefault(new java.util.Locale("nl", "NL"));
// Tests.
ToMoney tm = new ToMoney();
tm.reset();
tm.insertFloatOperand(Double.valueOf(1024.4990));
System.out.println("result = " + ((Money) tm.evaluate()).formattedString());
// Using expressions.
String expression = "ToMoney(1024.50) + 500 - 5.7 + ToMoney(1)/2";
Operand o = Expression.evaluate(expression, null);
System.out.println("o = " + o.value);
System.out.println("type = " + o.type);
System.err.println("ToMoney('') = " + Expression.evaluate("ToMoney('')", null).value);
}
use of com.dexels.navajo.document.Operand in project navajo by Dexels.
the class TestCompiledExpression method testFunctionEvaluation.
@Test
public void testFunctionEvaluation() {
List<String> problems = new ArrayList<>();
ExpressionCache ce = ExpressionCache.getInstance();
String embeddedExpression = "StringFunction('matches','aaa', '.*[-]+7[0-9][A-z]*$' ))";
ContextExpression cemb = ce.parse(problems, embeddedExpression, name -> FunctionClassification.DEFAULT);
System.err.println("Problems: " + problems);
Assert.assertEquals(0, problems.size());
Operand result = cemb.apply(input, Optional.empty(), Optional.empty());
System.err.println("Result: " + result.type + " value: " + result.value);
}
use of com.dexels.navajo.document.Operand in project navajo by Dexels.
the class Switch method testUnicodeExpressionFunction.
@Test
public void testUnicodeExpressionFunction() throws Exception {
Operand result = Expression.evaluate("Unicode('0x20AC')", null, null, null);
System.err.println("Result:" + result.value);
}
use of com.dexels.navajo.document.Operand in project navajo by Dexels.
the class StandardFunctionsTest method testCheckUniquenessExtended.
@Test
public void testCheckUniquenessExtended() throws SystemException {
String expression = "Hallo \n Hoe is het nou?";
CreateExpression ce = new CreateExpression();
ce.reset();
ce.insertStringOperand(expression);
String result = (String) ce.evaluate();
System.err.println("result:");
System.err.println(result);
Operand o = Expression.evaluate(result, null);
System.err.println("Evaluated to: ");
System.err.println(o.value);
assertEquals(2, ((String) o.value).split("\n").length);
}
use of com.dexels.navajo.document.Operand in project navajo by Dexels.
the class TestCompiledExpression method testForall.
@Test
public void testForall() throws TMLExpressionException {
List<String> problems = new ArrayList<>();
ExpressionCache ce = ExpressionCache.getInstance();
// String extBackup ="FORALL( '/TestArrayMessageMessage', `! ?[Delete] OR ! [Delete] OR [/__globals__/ApplicationInstance] != 'TENANT' OR ! StringFunction( 'matches', [ChargeCodeId], '.*[-]+7[0-9][A-z]*$' )` )";
String ext = "FORALL( '/Msg', `!StringFunction( 'matches', [ChargeCodeId], '.*[-]+7[0-9][A-z]*$' )` )";
// String expression = "FORALL( '/Charges' , `! ?[Delete] OR ! [Delete] OR [/__globals__/ApplicationInstance] != 'SOMETENANT' OR [SomeProperty] == 'SOMESTRING' `)";
// ce.parse(problems, expression, mode, allowLiteralResolve)
ContextExpression cx = ce.parse(problems, ext, name -> FunctionClassification.DEFAULT);
System.err.println("Problems: " + problems);
Assert.assertEquals(0, problems.size());
Operand result = cx.apply(input, Optional.empty(), Optional.empty());
System.err.println("Result: " + result.type + " value: " + result.value);
// Operand result = Expression.evaluate(expression, testDoc,null,topMessage);
}
Aggregations