|
|
@ -654,14 +654,19 @@ public class EntityRule {
|
|
|
|
Expression expression, Token functionToken, EvaluationValue... parameterValues) {
|
|
|
|
Expression expression, Token functionToken, EvaluationValue... parameterValues) {
|
|
|
|
List<String> result = new ArrayList<>();
|
|
|
|
List<String> result = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
|
|
String name = parameterValues[0].getStringValue();
|
|
|
|
try {
|
|
|
|
if (name != null && headers != null) {
|
|
|
|
if (parameterValues.length == 1) {
|
|
|
|
for (Header header : headers)
|
|
|
|
String name = parameterValues[0].getStringValue();
|
|
|
|
if (name.equalsIgnoreCase(header.getName()))
|
|
|
|
if (name != null && headers != null)
|
|
|
|
result.add(header.getValue());
|
|
|
|
for (Header header : headers)
|
|
|
|
Log.i("EXPR " + name + "=" + TextUtils.join(", ", result));
|
|
|
|
if (name.equalsIgnoreCase(header.getName()))
|
|
|
|
|
|
|
|
result.add(header.getValue());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (Throwable ex) {
|
|
|
|
|
|
|
|
Log.e("EXPR", ex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Log.i("EXPR header(" + parameterValues[0] + ")=" + TextUtils.join(", ", result));
|
|
|
|
return new EvaluationValue(result, ExpressionConfiguration.defaultConfiguration());
|
|
|
|
return new EvaluationValue(result, ExpressionConfiguration.defaultConfiguration());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -678,21 +683,23 @@ public class EntityRule {
|
|
|
|
public EvaluationValue evaluate(
|
|
|
|
public EvaluationValue evaluate(
|
|
|
|
Expression expression, Token functionToken, EvaluationValue... parameterValues) {
|
|
|
|
Expression expression, Token functionToken, EvaluationValue... parameterValues) {
|
|
|
|
List<Object> result = new ArrayList<>();
|
|
|
|
List<Object> result = new ArrayList<>();
|
|
|
|
String name = parameterValues[0].getStringValue();
|
|
|
|
|
|
|
|
if (name != null && message != null)
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
if (parameterValues.length == 1) {
|
|
|
|
Field field = message.getClass().getField(name);
|
|
|
|
String name = parameterValues[0].getStringValue();
|
|
|
|
if (field != null) {
|
|
|
|
if (name != null && message != null) {
|
|
|
|
|
|
|
|
Field field = message.getClass().getField(name);
|
|
|
|
field.setAccessible(true);
|
|
|
|
field.setAccessible(true);
|
|
|
|
Object value = field.get(message);
|
|
|
|
Object value = field.get(message);
|
|
|
|
Log.i("EXPR message " + name + "=" + value);
|
|
|
|
|
|
|
|
if (value != null)
|
|
|
|
if (value != null)
|
|
|
|
result.add(value);
|
|
|
|
result.add(value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (Throwable ex) {
|
|
|
|
|
|
|
|
Log.e(ex);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (Throwable ex) {
|
|
|
|
|
|
|
|
Log.e("EXPR", ex);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Log.i("EXPR message(" + parameterValues[0] + ")=" + TextUtils.join(", ", result));
|
|
|
|
return new EvaluationValue(result, ExpressionConfiguration.defaultConfiguration());
|
|
|
|
return new EvaluationValue(result, ExpressionConfiguration.defaultConfiguration());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -708,27 +715,38 @@ public class EntityRule {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public EvaluationValue evaluate(
|
|
|
|
public EvaluationValue evaluate(
|
|
|
|
Expression expression, Token operatorToken, EvaluationValue... operands) {
|
|
|
|
Expression expression, Token operatorToken, EvaluationValue... operands) {
|
|
|
|
Log.i("EXPR " + operands[0] + (regex ? " MATCHES " : " CONTAINS ") + operands[1] + " regex=" + regex);
|
|
|
|
boolean result = false;
|
|
|
|
|
|
|
|
|
|
|
|
String condition = operands[1].getStringValue();
|
|
|
|
try {
|
|
|
|
List<EvaluationValue> array = operands[0].getArrayValue();
|
|
|
|
if (operands.length == 2) {
|
|
|
|
if (TextUtils.isEmpty(condition) || array == null || array.isEmpty())
|
|
|
|
List<EvaluationValue> array;
|
|
|
|
return expression.convertValue(false);
|
|
|
|
if (operands[1].getDataType() == EvaluationValue.DataType.ARRAY)
|
|
|
|
|
|
|
|
array = operands[0].getArrayValue();
|
|
|
|
Pattern p = (regex ? Pattern.compile(condition, Pattern.DOTALL) : null);
|
|
|
|
else
|
|
|
|
for (EvaluationValue item : array) {
|
|
|
|
array = Arrays.asList(operands[0]);
|
|
|
|
String value = item.getStringValue();
|
|
|
|
|
|
|
|
if (!TextUtils.isEmpty(value))
|
|
|
|
String condition = operands[1].getStringValue();
|
|
|
|
if (p == null) {
|
|
|
|
|
|
|
|
if (value.toLowerCase().contains(condition.toLowerCase()))
|
|
|
|
if (array != null && !array.isEmpty() && !TextUtils.isEmpty(condition))
|
|
|
|
return expression.convertValue(true);
|
|
|
|
for (EvaluationValue item : array) {
|
|
|
|
} else {
|
|
|
|
String value = item.getStringValue();
|
|
|
|
if (p.matcher(value).matches())
|
|
|
|
if (!TextUtils.isEmpty(value))
|
|
|
|
return expression.convertValue(true);
|
|
|
|
if (regex
|
|
|
|
}
|
|
|
|
? Pattern.compile(condition, Pattern.DOTALL).matcher(value).matches()
|
|
|
|
|
|
|
|
: value.toLowerCase().contains(condition.toLowerCase())) {
|
|
|
|
|
|
|
|
result = true;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (Throwable ex) {
|
|
|
|
|
|
|
|
Log.e("EXPR", ex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return expression.convertValue(false);
|
|
|
|
Log.i("EXPR " + operands[0] + (regex ? " MATCHES " : " CONTAINS ") + operands[1] +
|
|
|
|
|
|
|
|
" regex=" + regex + " result=" + result);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return expression.convertValue(result);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -806,7 +824,7 @@ public class EntityRule {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (Throwable ex) {
|
|
|
|
} catch (Throwable ex) {
|
|
|
|
Log.e(ex);
|
|
|
|
Log.e("EXPR", ex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -817,7 +835,7 @@ public class EntityRule {
|
|
|
|
if ("text".equalsIgnoreCase(variable))
|
|
|
|
if ("text".equalsIgnoreCase(variable))
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
} catch (Throwable ex) {
|
|
|
|
} catch (Throwable ex) {
|
|
|
|
Log.e(ex);
|
|
|
|
Log.e("EXPR", ex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|