(List<EntityRule> rules, String what)
| 180 | } |
| 181 | |
| 182 | private static boolean needs(List<EntityRule> rules, String what) { |
| 183 | for (EntityRule rule : rules) |
| 184 | try { |
| 185 | JSONObject jaction = new JSONObject(rule.action); |
| 186 | int type = jaction.getInt("type"); |
| 187 | if (type == TYPE_SUMMARIZE || type == TYPE_AUTOMATION) |
| 188 | return true; |
| 189 | |
| 190 | JSONObject jcondition = new JSONObject(rule.condition); |
| 191 | |
| 192 | if (jcondition.has(what)) { |
| 193 | if ("header".equals(what)) { |
| 194 | JSONObject jheader = jcondition.getJSONObject("header"); |
| 195 | String value = jheader.getString("value"); |
| 196 | boolean regex = jheader.getBoolean("regex"); |
| 197 | if (!regex && value.startsWith("$$") && value.endsWith("$")) |
| 198 | continue; |
| 199 | } |
| 200 | return true; |
| 201 | } |
| 202 | |
| 203 | if (jcondition.has("expression")) { |
| 204 | Expression expression = ExpressionHelper.getExpression(rule, null, null, null, null); |
| 205 | if (expression != null) { |
| 206 | if ("header".equals(what) && ExpressionHelper.needsHeaders(expression)) |
| 207 | return true; |
| 208 | if ("body".equals(what) && ExpressionHelper.needsBody(expression)) |
| 209 | return true; |
| 210 | } |
| 211 | } |
| 212 | } catch (Throwable ex) { |
| 213 | Log.e(ex); |
| 214 | } |
| 215 | |
| 216 | return false; |
| 217 | } |
| 218 | |
| 219 | static int run(Context context, List<EntityRule> rules, |
| 220 | EntityMessage message, boolean browsed, List<Header> headers, String html) |
no test coverage detected