+
+ public void setComments(String aComments) {
+ comments = aComments;
+ }
+
+ public String getComments() {
+ return comments;
+ }
+
+ public String getArticleAction() {
+ return articleAction;
+ }
+
+ public void setArticleAction(String anArticleAction) {
+ articleAction = anArticleAction;
+ }
+
+ public String getCommentAction() {
+ return commentAction;
+ }
+
+ public void setCommentAction(String aCommentAction) {
+ commentAction = aCommentAction;
+ }
+
+ public boolean test(Entity anEntity, Request aRequest) {
+ MirAntiAbuseFilterType filterType = (MirAntiAbuseFilterType) filterTypes.get(type);
+ try {
+ if (filterType != null)
+ return filterType.test(expression, anEntity, aRequest);
+ }
+ catch (Throwable t) {
+ logger.error("error while testing " + type + "-filter '" + expression + "'");
+ }
+
+ return false;
+ };
+
+ public Object clone() {
+ FilterRule result = new FilterRule();
+ result.setComments(getComments());
+ result.setExpression(getExpression());
+ result.setId(getId());
+ result.setType(getType());
+ result.setArticleAction(getArticleAction());
+ result.setCommentAction(getCommentAction());
+ result.setLastHit(getLastHit());
+
+ return result;
+ }
+ }
+
+ private String escapeFilterPart(String aFilterPart) {
+ return StringRoutines.replaceStringCharacters(aFilterPart,
+ new char[] {'\\', ':', '\n', '\r', '\t', ' '},
+ new String[] {"\\\\", "\\:", "\\n", "\\r", "\\t", "\\ "});
+ }
+
+ private String deescapeFilterPart(String aFilterPart) {
+ return StringRoutines.replaceEscapedStringCharacters(aFilterPart,
+ '\\',
+ new char[] {'\\', ':', 'n', 'r', 't', ' '},
+ new String[] {"\\", ":", "\n", "\r", "\t", " "});