Search in sources :

Example 21 with TMLExpressionException

use of com.dexels.navajo.expression.api.TMLExpressionException in project navajo by Dexels.

the class KeyValueMap method evaluate.

@Override
public Object evaluate() throws TMLExpressionException {
    if (getOperands().size() != 3) {
        throw new TMLExpressionException("KeyValueMap(): invalid number of operands. Usage: " + usage());
    }
    Object a = this.getOperands().get(0);
    Object b = this.getOperands().get(1);
    Object c = this.getOperands().get(2);
    if (!((a instanceof String) && (b instanceof String) && (c instanceof String))) {
        throw new TMLExpressionException("KeyValueMap(): invalid operand. Usage: " + usage());
    }
    String map = (String) a;
    String sep = (String) b;
    String key = (String) c;
    StringTokenizer tokens = new StringTokenizer(map, sep);
    while (tokens.hasMoreElements()) {
        String keyValue = tokens.nextToken();
        if (keyValue.indexOf("=") != -1) {
            String k = keyValue.split("=")[0];
            if (k.equals(key)) {
                return keyValue.split("=")[1];
            }
        }
    }
    return null;
}
Also used : StringTokenizer(java.util.StringTokenizer) TMLExpressionException(com.dexels.navajo.expression.api.TMLExpressionException)

Example 22 with TMLExpressionException

use of com.dexels.navajo.expression.api.TMLExpressionException in project navajo by Dexels.

the class MergeNavajo method evaluate.

@Override
public final Object evaluate() throws com.dexels.navajo.expression.api.TMLExpressionException {
    Object a = this.getOperands().get(0);
    Object b = this.getOperands().get(1);
    try {
        Navajo slave = (Navajo) a;
        Navajo result = slave.copy();
        Navajo master = (Navajo) b;
        return result.merge(master);
    } catch (Exception e) {
        throw new TMLExpressionException(this, "Illegal type specified in MergeNavajo() function: " + e.getMessage(), e);
    }
}
Also used : Navajo(com.dexels.navajo.document.Navajo) TMLExpressionException(com.dexels.navajo.expression.api.TMLExpressionException) TMLExpressionException(com.dexels.navajo.expression.api.TMLExpressionException)

Example 23 with TMLExpressionException

use of com.dexels.navajo.expression.api.TMLExpressionException in project navajo by Dexels.

the class DecryptBinary method evaluate.

@Override
public Object evaluate() throws TMLExpressionException {
    Binary result = null;
    String key = (String) getOperand(0);
    String message = (String) getOperand(1);
    try {
        Security s = new Security(key);
        result = s.decryptBinary(message);
    } catch (Exception e) {
        throw new TMLExpressionException(e.getMessage());
    }
    return result;
}
Also used : Binary(com.dexels.navajo.document.types.Binary) Security(com.dexels.navajo.functions.security.Security) TMLExpressionException(com.dexels.navajo.expression.api.TMLExpressionException) TMLExpressionException(com.dexels.navajo.expression.api.TMLExpressionException)

Example 24 with TMLExpressionException

use of com.dexels.navajo.expression.api.TMLExpressionException in project navajo by Dexels.

the class EncryptString method evaluate.

@Override
public Object evaluate() throws TMLExpressionException {
    String result = null;
    String key = (String) getOperand(0);
    String message = (String) getOperand(1);
    try {
        Security s = new Security(key);
        result = s.encrypt(message).replace("\n", "");
    } catch (Exception e) {
        throw new TMLExpressionException(e.getMessage());
    }
    return result;
}
Also used : Security(com.dexels.navajo.functions.security.Security) TMLExpressionException(com.dexels.navajo.expression.api.TMLExpressionException) TMLExpressionException(com.dexels.navajo.expression.api.TMLExpressionException)

Example 25 with TMLExpressionException

use of com.dexels.navajo.expression.api.TMLExpressionException in project navajo by Dexels.

the class EqualsIgnoreCase method evaluate.

@Override
public final Object evaluate() throws TMLExpressionException {
    List<?> operands = this.getOperands();
    if (operands.size() != 2)
        throw new TMLExpressionException("Invalid number of arguments for EqualsIgnoreCase()");
    String a = (String) operands.get(0);
    String b = (String) operands.get(1);
    return (a.equalsIgnoreCase(b));
}
Also used : TMLExpressionException(com.dexels.navajo.expression.api.TMLExpressionException)

Aggregations

TMLExpressionException (com.dexels.navajo.expression.api.TMLExpressionException)129 Message (com.dexels.navajo.document.Message)26 Navajo (com.dexels.navajo.document.Navajo)26 Binary (com.dexels.navajo.document.types.Binary)23 Property (com.dexels.navajo.document.Property)17 ArrayList (java.util.ArrayList)16 Operand (com.dexels.navajo.document.Operand)15 List (java.util.List)13 NavajoException (com.dexels.navajo.document.NavajoException)12 IOException (java.io.IOException)12 Selection (com.dexels.navajo.document.Selection)11 Access (com.dexels.navajo.script.api.Access)10 Calendar (java.util.Calendar)10 ContextExpression (com.dexels.navajo.expression.api.ContextExpression)9 Test (org.junit.Test)9 Money (com.dexels.navajo.document.types.Money)8 SystemException (com.dexels.navajo.script.api.SystemException)8 StringTokenizer (java.util.StringTokenizer)8 ImmutableMessage (com.dexels.immutable.api.ImmutableMessage)7 ClockTime (com.dexels.navajo.document.types.ClockTime)7