Add eq expression
This commit is contained in:
parent
927415e860
commit
6124fcd942
2 changed files with 11 additions and 1 deletions
|
@ -574,6 +574,7 @@ public class GeneralRouter implements VehicleRouter {
|
|||
public class RouteAttributeExpression {
|
||||
public static final int LESS_EXPRESSION = 1;
|
||||
public static final int GREAT_EXPRESSION = 2;
|
||||
public static final int EQUAL_EXPRESSION = 3;
|
||||
|
||||
public RouteAttributeExpression(String[] vs, String valueType, int expressionId) {
|
||||
this.expressionType = expressionId;
|
||||
|
@ -609,6 +610,8 @@ public class GeneralRouter implements VehicleRouter {
|
|||
return f1 <= f2;
|
||||
} else if (expressionType == GREAT_EXPRESSION) {
|
||||
return f1 >= f2;
|
||||
} else if (expressionType == EQUAL_EXPRESSION) {
|
||||
return f1 == f2;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -762,6 +765,11 @@ public class GeneralRouter implements VehicleRouter {
|
|||
RouteAttributeExpression.GREAT_EXPRESSION));
|
||||
}
|
||||
|
||||
public void registerEqualCondition(String value1, String value2, String valueType) {
|
||||
expressions.add(new RouteAttributeExpression(new String[] { value1, value2 }, valueType,
|
||||
RouteAttributeExpression.EQUAL_EXPRESSION));
|
||||
}
|
||||
|
||||
public void registerAndParamCondition(String param, boolean not) {
|
||||
param = not ? "-" + param : param;
|
||||
parameters.add(param);
|
||||
|
|
|
@ -283,7 +283,7 @@ public class RoutingConfiguration {
|
|||
|
||||
private static boolean checkTag(String pname) {
|
||||
return "select".equals(pname) || "if".equals(pname) || "ifnot".equals(pname)
|
||||
|| "gt".equals(pname) || "le".equals(pname);
|
||||
|| "gt".equals(pname) || "le".equals(pname) || "eq".equals(pname);
|
||||
}
|
||||
|
||||
private static void addSubclause(RoutingRule rr, RouteAttributeContext ctx) {
|
||||
|
@ -298,6 +298,8 @@ public class RoutingConfiguration {
|
|||
ctx.getLastRule().registerGreatCondition(rr.value1, rr.value2, rr.type);
|
||||
} else if (rr.tagName.equals("le")) {
|
||||
ctx.getLastRule().registerLessCondition(rr.value1, rr.value2, rr.type);
|
||||
} else if (rr.tagName.equals("eq")) {
|
||||
ctx.getLastRule().registerEqualCondition(rr.value1, rr.value2, rr.type);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue