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;
}
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);
}
}
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;
}
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;
}
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));
}
Aggregations