//# 1 errors, 204 messages
//#
/*
    //#contentspamlistener.java:1:1: class: net.sourceforge.pebble.event.response.ContentSpamListener
 * Copyright (c) 2003-2006, Simon Brown
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 *   - Redistributions of source code must retain the above copyright
 *     notice, this list of conditions and the following disclaimer.
 *
 *   - Redistributions in binary form must reproduce the above copyright
 *     notice, this list of conditions and the following disclaimer in
 *     the documentation and/or other materials provided with the
 *     distribution.
 *
 *   - Neither the name of Pebble nor the names of its contributors may
 *     be used to endorse or promote products derived from this software
 *     without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */
package net.sourceforge.pebble.event.response;

import net.sourceforge.pebble.PluginProperties;
import net.sourceforge.pebble.domain.Response;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Checks comment and TrackBack content for specified regexs and sets
 * the state of such responses to pending. This includes all user-definable
 * fields of the response : title, content, source name and source link. The
 * spam score is incremented for each field that exceeds the threshold. 
 *
 * @author Simon Brown
 */
public class ContentSpamListener extends BlogEntryResponseListenerSupport {
    //#contentspamlistener.java:50: method: void net.sourceforge.pebble.event.response.ContentSpamListener.net.sourceforge.pebble.event.response.ContentSpamListener()
    //#input(void net.sourceforge.pebble.event.response.ContentSpamListener()): this
    //#contentspamlistener.java:50: end of method: void net.sourceforge.pebble.event.response.ContentSpamListener.net.sourceforge.pebble.event.response.ContentSpamListener()

  /** the log used by this class */
  private static final Log log = LogFactory.getLog(ContentSpamListener.class);
    //#contentspamlistener.java:53: method: net.sourceforge.pebble.event.response.ContentSpamListener.net.sourceforge.pebble.event.response.ContentSpamListener__static_init
    //#contentspamlistener.java:53: Warning: method not available
    //#    -- call on Log org.apache.commons.logging.LogFactory:getLog(Class)
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.event.response.ContentSpamListener
    //#    method: net.sourceforge.pebble.event.response.ContentSpamListener__static_init
    //#    unanalyzed callee: Log org.apache.commons.logging.LogFactory:getLog(Class)
    //#output(net.sourceforge.pebble.event.response.ContentSpamListener__static_init): __Descendant_Table[net/sourceforge/pebble/event/response/ContentSpamListener]
    //#output(net.sourceforge.pebble.event.response.ContentSpamListener__static_init): __Dispatch_Table.blogEntryResponseAdded(Lnet/sourceforge/pebble/domain/Response;)V
    //#output(net.sourceforge.pebble.event.response.ContentSpamListener__static_init): __Dispatch_Table.blogEntryResponseApproved(Lnet/sourceforge/pebble/domain/Response;)V
    //#output(net.sourceforge.pebble.event.response.ContentSpamListener__static_init): __Dispatch_Table.blogEntryResponseRejected(Lnet/sourceforge/pebble/domain/Response;)V
    //#output(net.sourceforge.pebble.event.response.ContentSpamListener__static_init): __Dispatch_Table.blogEntryResponseRemoved(Lnet/sourceforge/pebble/domain/Response;)V
    //#output(net.sourceforge.pebble.event.response.ContentSpamListener__static_init): __Dispatch_Table.commentAdded(Lnet/sourceforge/pebble/api/event/comment/CommentEvent;)V
    //#output(net.sourceforge.pebble.event.response.ContentSpamListener__static_init): __Dispatch_Table.commentApproved(Lnet/sourceforge/pebble/api/event/comment/CommentEvent;)V
    //#output(net.sourceforge.pebble.event.response.ContentSpamListener__static_init): __Dispatch_Table.commentRejected(Lnet/sourceforge/pebble/api/event/comment/CommentEvent;)V
    //#output(net.sourceforge.pebble.event.response.ContentSpamListener__static_init): __Dispatch_Table.commentRemoved(Lnet/sourceforge/pebble/api/event/comment/CommentEvent;)V
    //#output(net.sourceforge.pebble.event.response.ContentSpamListener__static_init): __Dispatch_Table.contentWithinThreshold(Ljava/lang/String;[Ljava/lang/String;I)Z
    //#output(net.sourceforge.pebble.event.response.ContentSpamListener__static_init): __Dispatch_Table.trackBackAdded(Lnet/sourceforge/pebble/api/event/trackback/TrackBackEvent;)V
    //#output(net.sourceforge.pebble.event.response.ContentSpamListener__static_init): __Dispatch_Table.trackBackApproved(Lnet/sourceforge/pebble/api/event/trackback/TrackBackEvent;)V
    //#output(net.sourceforge.pebble.event.response.ContentSpamListener__static_init): __Dispatch_Table.trackBackRejected(Lnet/sourceforge/pebble/api/event/trackback/TrackBackEvent;)V
    //#output(net.sourceforge.pebble.event.response.ContentSpamListener__static_init): __Dispatch_Table.trackBackRemoved(Lnet/sourceforge/pebble/api/event/trackback/TrackBackEvent;)V
    //#output(net.sourceforge.pebble.event.response.ContentSpamListener__static_init): log
    //#output(net.sourceforge.pebble.event.response.ContentSpamListener__static_init): net/sourceforge/pebble/api/event/comment/CommentListener.__Descendant_Table[net/sourceforge/pebble/event/response/ContentSpamListener]
    //#output(net.sourceforge.pebble.event.response.ContentSpamListener__static_init): net/sourceforge/pebble/api/event/trackback/TrackBackListener.__Descendant_Table[net/sourceforge/pebble/event/response/ContentSpamListener]
    //#output(net.sourceforge.pebble.event.response.ContentSpamListener__static_init): net/sourceforge/pebble/event/response/BlogEntryResponseListenerSupport.__Descendant_Table[net/sourceforge/pebble/event/response/ContentSpamListener]
    //#post(net.sourceforge.pebble.event.response.ContentSpamListener__static_init): __Descendant_Table[net/sourceforge/pebble/event/response/ContentSpamListener] == &__Dispatch_Table
    //#post(net.sourceforge.pebble.event.response.ContentSpamListener__static_init): net/sourceforge/pebble/api/event/comment/CommentListener.__Descendant_Table[net/sourceforge/pebble/event/response/ContentSpamListener] == &__Dispatch_Table
    //#post(net.sourceforge.pebble.event.response.ContentSpamListener__static_init): net/sourceforge/pebble/api/event/trackback/TrackBackListener.__Descendant_Table[net/sourceforge/pebble/event/response/ContentSpamListener] == &__Dispatch_Table
    //#post(net.sourceforge.pebble.event.response.ContentSpamListener__static_init): net/sourceforge/pebble/event/response/BlogEntryResponseListenerSupport.__Descendant_Table[net/sourceforge/pebble/event/response/ContentSpamListener] == &__Dispatch_Table
    //#post(net.sourceforge.pebble.event.response.ContentSpamListener__static_init): __Dispatch_Table.blogEntryResponseAdded(Lnet/sourceforge/pebble/domain/Response;)V == &blogEntryResponseAdded
    //#post(net.sourceforge.pebble.event.response.ContentSpamListener__static_init): __Dispatch_Table.blogEntryResponseApproved(Lnet/sourceforge/pebble/domain/Response;)V == &net/sourceforge/pebble/event/response/BlogEntryResponseListenerSupport.blogEntryResponseApproved
    //#post(net.sourceforge.pebble.event.response.ContentSpamListener__static_init): __Dispatch_Table.blogEntryResponseRejected(Lnet/sourceforge/pebble/domain/Response;)V == &net/sourceforge/pebble/event/response/BlogEntryResponseListenerSupport.blogEntryResponseRejected
    //#post(net.sourceforge.pebble.event.response.ContentSpamListener__static_init): __Dispatch_Table.blogEntryResponseRemoved(Lnet/sourceforge/pebble/domain/Response;)V == &net/sourceforge/pebble/event/response/BlogEntryResponseListenerSupport.blogEntryResponseRemoved
    //#post(net.sourceforge.pebble.event.response.ContentSpamListener__static_init): __Dispatch_Table.commentAdded(Lnet/sourceforge/pebble/api/event/comment/CommentEvent;)V == &net/sourceforge/pebble/event/response/BlogEntryResponseListenerSupport.commentAdded
    //#post(net.sourceforge.pebble.event.response.ContentSpamListener__static_init): __Dispatch_Table.commentApproved(Lnet/sourceforge/pebble/api/event/comment/CommentEvent;)V == &net/sourceforge/pebble/event/response/BlogEntryResponseListenerSupport.commentApproved
    //#post(net.sourceforge.pebble.event.response.ContentSpamListener__static_init): __Dispatch_Table.commentRejected(Lnet/sourceforge/pebble/api/event/comment/CommentEvent;)V == &net/sourceforge/pebble/event/response/BlogEntryResponseListenerSupport.commentRejected
    //#post(net.sourceforge.pebble.event.response.ContentSpamListener__static_init): __Dispatch_Table.commentRemoved(Lnet/sourceforge/pebble/api/event/comment/CommentEvent;)V == &net/sourceforge/pebble/event/response/BlogEntryResponseListenerSupport.commentRemoved
    //#post(net.sourceforge.pebble.event.response.ContentSpamListener__static_init): __Dispatch_Table.contentWithinThreshold(Ljava/lang/String;[Ljava/lang/String;I)Z == &contentWithinThreshold
    //#post(net.sourceforge.pebble.event.response.ContentSpamListener__static_init): __Dispatch_Table.trackBackAdded(Lnet/sourceforge/pebble/api/event/trackback/TrackBackEvent;)V == &net/sourceforge/pebble/event/response/BlogEntryResponseListenerSupport.trackBackAdded
    //#post(net.sourceforge.pebble.event.response.ContentSpamListener__static_init): __Dispatch_Table.trackBackApproved(Lnet/sourceforge/pebble/api/event/trackback/TrackBackEvent;)V == &net/sourceforge/pebble/event/response/BlogEntryResponseListenerSupport.trackBackApproved
    //#post(net.sourceforge.pebble.event.response.ContentSpamListener__static_init): __Dispatch_Table.trackBackRejected(Lnet/sourceforge/pebble/api/event/trackback/TrackBackEvent;)V == &net/sourceforge/pebble/event/response/BlogEntryResponseListenerSupport.trackBackRejected
    //#post(net.sourceforge.pebble.event.response.ContentSpamListener__static_init): __Dispatch_Table.trackBackRemoved(Lnet/sourceforge/pebble/api/event/trackback/TrackBackEvent;)V == &net/sourceforge/pebble/event/response/BlogEntryResponseListenerSupport.trackBackRemoved
    //#post(net.sourceforge.pebble.event.response.ContentSpamListener__static_init): init'ed(log)
    //#contentspamlistener.java:53: end of method: net.sourceforge.pebble.event.response.ContentSpamListener.net.sourceforge.pebble.event.response.ContentSpamListener__static_init

  /** the default regex list */
  public static final String DEFAULT_REGEX_LIST = "cialis, viagra, poker, casino, xanax, holdem, hold-em, hold em, sex, craps, fuck, shit, teenage, phentermine, blackjack, roulette, gambling, pharmacy, carisoprodol, pills, penis, penis enlargement, anal, hentai, anime, vicodin, massage, nude, ejaculation, porn, gay, naked, girl, teens, babe, masturbating, squirt, incest, fetish, discount, cheap, interesdting, levitra, government, grants, loan, &\\#.*;, kasino, slots, play, bingo, mortgage, baccarat";
  
  /** the default threshold for the number of content matches */
  public static final int DEFAULT_THRESHOLD = 0;

  /** the name of the regex list property */
  public static final String REGEX_LIST_KEY = "ContentSpamListener.regexList";

  /** the name of the threshold property */
  public static final String THRESHOLD_KEY = "ContentSpamListener.threshold";

  /**
   * Called when a comment or TrackBack has been added.
   *
   * @param response a Response
   */
  protected void blogEntryResponseAdded(Response response) {
    PluginProperties props = response.getBlogEntry().getBlog().getPluginProperties();
    //#contentspamlistener.java:73: method: void net.sourceforge.pebble.event.response.ContentSpamListener.blogEntryResponseAdded(Response)
    //#contentspamlistener.java:73: Warning: suspicious precondition
    //#    the precondition for response.__Tag is not a contiguous range of values
    //#    severity: SUPPRESSED
    //#    class: net.sourceforge.pebble.event.response.ContentSpamListener
    //#    method: void blogEntryResponseAdded(Response)
    //#    suspicious precondition index: [7]
    //#    Attribs:  Soft
    //#input(void blogEntryResponseAdded(Response)): log
    //#input(void blogEntryResponseAdded(Response)): net.sourceforge.pebble.domain.State__static_init.new State(State__static_init#1).__Tag
    //#input(void blogEntryResponseAdded(Response)): net.sourceforge.pebble.domain.State__static_init.new State(State__static_init#2).__Tag
    //#input(void blogEntryResponseAdded(Response)): net.sourceforge.pebble.domain.State__static_init.new State(State__static_init#3).__Tag
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/Blog.__Descendant_Table[net/sourceforge/pebble/domain/Blog]
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/Blog.__Descendant_Table[others]
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/Blog.__Dispatch_Table.getPluginProperties()Lnet/sourceforge/pebble/PluginProperties;
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/BlogEntry.__Descendant_Table[net/sourceforge/pebble/domain/BlogEntry]
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/BlogEntry.__Descendant_Table[others]
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/BlogEntry.__Dispatch_Table.getBlog()Lnet/sourceforge/pebble/domain/Blog;
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/Comment.__Descendant_Table[net/sourceforge/pebble/domain/Comment]
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/Comment.__Descendant_Table[others]
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/Comment.__Dispatch_Table.areEventsEnabled()Z
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/Comment.__Dispatch_Table.getAuthor()Ljava/lang/String;
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/Comment.__Dispatch_Table.getBlogEntry()Lnet/sourceforge/pebble/domain/BlogEntry;
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/Comment.__Dispatch_Table.getBody()Ljava/lang/String;
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/Comment.__Dispatch_Table.getContent()Ljava/lang/String;
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/Comment.__Dispatch_Table.getSourceLink()Ljava/lang/String;
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/Comment.__Dispatch_Table.getSourceName()Ljava/lang/String;
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/Comment.__Dispatch_Table.getState()Lnet/sourceforge/pebble/domain/State;
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/Comment.__Dispatch_Table.getTitle()Ljava/lang/String;
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/Comment.__Dispatch_Table.getWebsite()Ljava/lang/String;
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/Comment.__Dispatch_Table.incrementSpamScore()V
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/Comment.__Dispatch_Table.isApproved()Z
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/Comment.__Dispatch_Table.isRejected()Z
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/Comment.__Dispatch_Table.setPending()V
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/Comment.__Dispatch_Table.setState(Lnet/sourceforge/pebble/domain/State;)V
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/Response.__Descendant_Table[net/sourceforge/pebble/domain/Comment]
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/Response.__Descendant_Table[net/sourceforge/pebble/domain/Response]
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/Response.__Descendant_Table[net/sourceforge/pebble/domain/TrackBack]
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/Response.__Descendant_Table[others]
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/Response.__Dispatch_Table.getBlogEntry()Lnet/sourceforge/pebble/domain/BlogEntry;
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/Response.__Dispatch_Table.getContent()Ljava/lang/String;
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/Response.__Dispatch_Table.getSourceLink()Ljava/lang/String;
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/Response.__Dispatch_Table.getSourceName()Ljava/lang/String;
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/Response.__Dispatch_Table.getState()Lnet/sourceforge/pebble/domain/State;
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/Response.__Dispatch_Table.getTitle()Ljava/lang/String;
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/Response.__Dispatch_Table.incrementSpamScore()V
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/Response.__Dispatch_Table.setPending()V
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/Response.__Dispatch_Table.setState(Lnet/sourceforge/pebble/domain/State;)V
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/State.APPROVED
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/State.PENDING
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/State.REJECTED
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/State.__Descendant_Table[net/sourceforge/pebble/domain/State]
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/State.__Descendant_Table[others]
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/State.__Dispatch_Table.equals(Ljava/lang/Object;)Z
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/State.__Dispatch_Table.getName()Ljava/lang/String;
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/TrackBack.__Descendant_Table[net/sourceforge/pebble/domain/TrackBack]
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/TrackBack.__Descendant_Table[others]
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/TrackBack.__Dispatch_Table.areEventsEnabled()Z
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/TrackBack.__Dispatch_Table.getBlogEntry()Lnet/sourceforge/pebble/domain/BlogEntry;
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/TrackBack.__Dispatch_Table.getBlogName()Ljava/lang/String;
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/TrackBack.__Dispatch_Table.getContent()Ljava/lang/String;
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/TrackBack.__Dispatch_Table.getExcerpt()Ljava/lang/String;
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/TrackBack.__Dispatch_Table.getSourceLink()Ljava/lang/String;
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/TrackBack.__Dispatch_Table.getSourceName()Ljava/lang/String;
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/TrackBack.__Dispatch_Table.getState()Lnet/sourceforge/pebble/domain/State;
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/TrackBack.__Dispatch_Table.getTitle()Ljava/lang/String;
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/TrackBack.__Dispatch_Table.getUrl()Ljava/lang/String;
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/TrackBack.__Dispatch_Table.incrementSpamScore()V
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/TrackBack.__Dispatch_Table.isApproved()Z
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/TrackBack.__Dispatch_Table.isRejected()Z
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/TrackBack.__Dispatch_Table.setPending()V
    //#input(void blogEntryResponseAdded(Response)): net/sourceforge/pebble/domain/TrackBack.__Dispatch_Table.setState(Lnet/sourceforge/pebble/domain/State;)V
    //#input(void blogEntryResponseAdded(Response)): response
    //#input(void blogEntryResponseAdded(Response)): response.__Tag
    //#input(void blogEntryResponseAdded(Response)): response.author
    //#input(void blogEntryResponseAdded(Response)): response.blogEntry
    //#input(void blogEntryResponseAdded(Response)): response.blogEntry.__Tag
    //#input(void blogEntryResponseAdded(Response)): response.blogEntry.blog
    //#input(void blogEntryResponseAdded(Response)): response.blogEntry.blog.__Tag
    //#input(void blogEntryResponseAdded(Response)): response.blogEntry.blog.pluginProperties
    //#input(void blogEntryResponseAdded(Response)): response.blogName
    //#input(void blogEntryResponseAdded(Response)): response.body
    //#input(void blogEntryResponseAdded(Response)): response.excerpt
    //#input(void blogEntryResponseAdded(Response)): response.spamScore
    //#input(void blogEntryResponseAdded(Response)): response.state.__Tag
    //#input(void blogEntryResponseAdded(Response)): response.title
    //#input(void blogEntryResponseAdded(Response)): response.url
    //#input(void blogEntryResponseAdded(Response)): response.website
    //#input(void blogEntryResponseAdded(Response)): this
    //#output(void blogEntryResponseAdded(Response)): response.spamScore
    //#output(void blogEntryResponseAdded(Response)): response.state
    //#pre[6] (void blogEntryResponseAdded(Response)): response != null
    //#pre[9] (void blogEntryResponseAdded(Response)): response.blogEntry != null
    //#pre[10] (void blogEntryResponseAdded(Response)): response.blogEntry.__Tag == net/sourceforge/pebble/domain/BlogEntry
    //#pre[11] (void blogEntryResponseAdded(Response)): response.blogEntry.blog != null
    //#pre[12] (void blogEntryResponseAdded(Response)): response.blogEntry.blog.__Tag == net/sourceforge/pebble/domain/Blog
    //#pre[13] (void blogEntryResponseAdded(Response)): response.blogEntry.blog.pluginProperties != null
    //#pre[20] (void blogEntryResponseAdded(Response)): init'ed(response.title)
    //#pre[4] (void blogEntryResponseAdded(Response)): (soft) response.spamScore <= 4_294_967_291
    //#pre[7] (void blogEntryResponseAdded(Response)): (soft) response.__Tag in {net/sourceforge/pebble/domain/Comment, net/sourceforge/pebble/domain/TrackBack}
    //#pre[8] (void blogEntryResponseAdded(Response)): (soft) init'ed(response.author)
    //#pre[14] (void blogEntryResponseAdded(Response)): (soft) init'ed(response.blogName)
    //#pre[15] (void blogEntryResponseAdded(Response)): (soft) init'ed(response.body)
    //#pre[17] (void blogEntryResponseAdded(Response)): (soft) init'ed(response.excerpt)
    //#pre[21] (void blogEntryResponseAdded(Response)): (soft) init'ed(response.url)
    //#pre[22] (void blogEntryResponseAdded(Response)): (soft) init'ed(response.website)
    //#presumption(void blogEntryResponseAdded(Response)): java.lang.Integer:parseInt(...)@85 <= 4_294_967_294
    //#presumption(void blogEntryResponseAdded(Response)): org.apache.commons.logging.LogFactory:getLog(...)@53 != null
    //#presumption(void blogEntryResponseAdded(Response)): regexes.length@77 <= 4_294_967_295
    //#presumption(void blogEntryResponseAdded(Response)): regexes[0..4_294_967_295] != null
    //#presumption(void blogEntryResponseAdded(Response)): regexes[0..4_294_967_295] != null
    //#presumption(void blogEntryResponseAdded(Response)): regexes[0..4_294_967_295] != null
    //#presumption(void blogEntryResponseAdded(Response)): regexes[0..4_294_967_295]@77 != null
    //#post(void blogEntryResponseAdded(Response)): response.spamScore == One-of{old response.spamScore, old response.spamScore + 1, One-of{old response.spamScore, old response.spamScore + 1} + 1, One-of{old response.spamScore, old response.spamScore + 1, One-of{old response.spamScore, old response.spamScore + 1} + 1} + 1, One-o...
    //#post(void blogEntryResponseAdded(Response)): (soft) init'ed(response.spamScore)
    //#post(void blogEntryResponseAdded(Response)): response.state == One-of{old response.state, &net.sourceforge.pebble.domain.State__static_init.new State(State__static_init#3)}
    //#unanalyzed(void blogEntryResponseAdded(Response)): Effects-of-calling:java.lang.String:trim
    //#unanalyzed(void blogEntryResponseAdded(Response)): Effects-of-calling:java.lang.String:length
    //#unanalyzed(void blogEntryResponseAdded(Response)): Effects-of-calling:java.util.regex.Pattern:compile
    //#unanalyzed(void blogEntryResponseAdded(Response)): Effects-of-calling:java.util.regex.Pattern:matcher
    //#unanalyzed(void blogEntryResponseAdded(Response)): Effects-of-calling:java.util.regex.Matcher:find
    //#unanalyzed(void blogEntryResponseAdded(Response)): Effects-of-calling:getBlogEntry
    //#unanalyzed(void blogEntryResponseAdded(Response)): Effects-of-calling:setState
    //#unanalyzed(void blogEntryResponseAdded(Response)): Effects-of-calling:areEventsEnabled
    //#unanalyzed(void blogEntryResponseAdded(Response)): Effects-of-calling:java.util.EventObject
    //#unanalyzed(void blogEntryResponseAdded(Response)): Effects-of-calling:net.sourceforge.pebble.api.event.PebbleEvent
    //#unanalyzed(void blogEntryResponseAdded(Response)): Effects-of-calling:net.sourceforge.pebble.domain.BlogEntry:addEvent
    //#unanalyzed(void blogEntryResponseAdded(Response)): Effects-of-calling:getState
    //#unanalyzed(void blogEntryResponseAdded(Response)): Effects-of-calling:isApproved
    //#unanalyzed(void blogEntryResponseAdded(Response)): Effects-of-calling:isRejected
    //#unanalyzed(void blogEntryResponseAdded(Response)): Effects-of-calling:java.lang.String:equals
    //#unanalyzed(void blogEntryResponseAdded(Response)): Effects-of-calling:net.sourceforge.pebble.domain.Response:setState
    //#test_vector(void blogEntryResponseAdded(Response)): net.sourceforge.pebble.PluginProperties:getProperty(...)@74: Addr_Set{null}, Inverse{null}
    //#test_vector(void blogEntryResponseAdded(Response)): net.sourceforge.pebble.PluginProperties:hasProperty(...)@83: {0}, {1}
    String regexList = props.getProperty(REGEX_LIST_KEY);
    //#contentspamlistener.java:74: Warning: method not available
    //#    -- call on String net.sourceforge.pebble.PluginProperties:getProperty(String)
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.event.response.ContentSpamListener
    //#    method: void blogEntryResponseAdded(Response)
    //#    unanalyzed callee: String net.sourceforge.pebble.PluginProperties:getProperty(String)
    String regexes[] = null;
    //#contentspamlistener.java:75: Warning: unused assignment
    //#    unused assignment into regexes
    //#    severity: LOW
    //#    class: net.sourceforge.pebble.event.response.ContentSpamListener
    //#    method: void blogEntryResponseAdded(Response)
    if (regexList != null) {
      regexes = regexList.split(",");
    } else {
      regexes = new String[0];
    }

    int threshold = DEFAULT_THRESHOLD;
    if (props.hasProperty(THRESHOLD_KEY)) {
    //#contentspamlistener.java:83: Warning: method not available
    //#    -- call on bool net.sourceforge.pebble.PluginProperties:hasProperty(String)
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.event.response.ContentSpamListener
    //#    method: void blogEntryResponseAdded(Response)
    //#    unanalyzed callee: bool net.sourceforge.pebble.PluginProperties:hasProperty(String)
      try {
        threshold = Integer.parseInt(props.getProperty(THRESHOLD_KEY));
    //#contentspamlistener.java:85: Warning: method not available
    //#    -- call on String net.sourceforge.pebble.PluginProperties:getProperty(String)
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.event.response.ContentSpamListener
    //#    method: void blogEntryResponseAdded(Response)
    //#    unanalyzed callee: String net.sourceforge.pebble.PluginProperties:getProperty(String)
      } catch (NumberFormatException nfe) {
        log.error(nfe.getMessage());
    //#contentspamlistener.java:87: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:error(Object)
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.event.response.ContentSpamListener
    //#    method: void blogEntryResponseAdded(Response)
    //#    unanalyzed callee: void org.apache.commons.logging.Log:error(Object)
        // do nothing, the value has already been defaulted
      }
    }

    // check each of the fields in turn
    if (!contentWithinThreshold(response.getTitle(), regexes, threshold)) {
    //#contentspamlistener.java:93: ?precondition failure
    //#    net/sourceforge/pebble/event/response/ContentSpamListener.contentWithinThreshold: (soft) regexes[0..4_294_967_295] != null
    //#    severity: SUPPRESSED
    //#    class: net.sourceforge.pebble.event.response.ContentSpamListener
    //#    method: void blogEntryResponseAdded(Response)
    //#    basic block: bb_8
    //#    assertion: (soft) regexes[0..4_294_967_295] != null
    //#    callee: bool net/sourceforge/pebble/event/response/ContentSpamListener.contentWithinThreshold(String, String[], int)
    //#    callee assertion: (soft) regexes[0..4_294_967_295] != null
    //#    callee file: contentspamlistener.java
    //#    callee precondition index: [4]
    //#    callee srcpos: 116
    //#    VN: regexes[0..4_294_967_295]
    //#    Expected: Inverse{null}
    //#    Bad: Addr_Set{null, Invalid}
    //#    Attribs:  Ptr  null in Bad  Soft  Uncertain
      log.info(response.getTitle() + " marked as pending : threshold for title exceeded");
    //#contentspamlistener.java:94: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:info(Object)
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.event.response.ContentSpamListener
    //#    method: void blogEntryResponseAdded(Response)
    //#    unanalyzed callee: void org.apache.commons.logging.Log:info(Object)
      response.setPending();
      response.incrementSpamScore();
    }
    if (!contentWithinThreshold(response.getSourceName(), regexes, threshold)) {
    //#contentspamlistener.java:98: Warning: method not available
    //#    -- call on String getSourceName()
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.event.response.ContentSpamListener
    //#    method: void blogEntryResponseAdded(Response)
    //#    unanalyzed callee: String getSourceName()
      log.info(response.getTitle() + " marked as pending : threshold for source name exceeded");
    //#contentspamlistener.java:99: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:info(Object)
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.event.response.ContentSpamListener
    //#    method: void blogEntryResponseAdded(Response)
    //#    unanalyzed callee: void org.apache.commons.logging.Log:info(Object)
      response.setPending();
      response.incrementSpamScore();
    }
    if (!contentWithinThreshold(response.getSourceLink(), regexes, threshold)) {
    //#contentspamlistener.java:103: Warning: method not available
    //#    -- call on String getSourceLink()
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.event.response.ContentSpamListener
    //#    method: void blogEntryResponseAdded(Response)
    //#    unanalyzed callee: String getSourceLink()
      log.info(response.getTitle() + " marked as pending : threshold for source link exceeded");
    //#contentspamlistener.java:104: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:info(Object)
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.event.response.ContentSpamListener
    //#    method: void blogEntryResponseAdded(Response)
    //#    unanalyzed callee: void org.apache.commons.logging.Log:info(Object)
      response.setPending();
      response.incrementSpamScore();
    }
    if (!contentWithinThreshold(response.getContent(), regexes, threshold)) {
    //#contentspamlistener.java:108: Warning: method not available
    //#    -- call on String getContent()
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.event.response.ContentSpamListener
    //#    method: void blogEntryResponseAdded(Response)
    //#    unanalyzed callee: String getContent()
      log.info(response.getTitle() + " marked as pending : threshold for content exceeded");
    //#contentspamlistener.java:109: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:info(Object)
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.event.response.ContentSpamListener
    //#    method: void blogEntryResponseAdded(Response)
    //#    unanalyzed callee: void org.apache.commons.logging.Log:info(Object)
      response.setPending();
      response.incrementSpamScore();
    }
  }
    //#contentspamlistener.java:113: end of method: void net.sourceforge.pebble.event.response.ContentSpamListener.blogEntryResponseAdded(Response)

  private boolean contentWithinThreshold(String content, String regexes[], int threshold) {
    if (content == null || content.trim().length() == 0) {
    //#contentspamlistener.java:116: method: bool net.sourceforge.pebble.event.response.ContentSpamListener.contentWithinThreshold(String, String[], int)
    //#input(bool contentWithinThreshold(String, String[], int)): content
    //#input(bool contentWithinThreshold(String, String[], int)): regexes
    //#input(bool contentWithinThreshold(String, String[], int)): regexes.length
    //#input(bool contentWithinThreshold(String, String[], int)): regexes[0..4_294_967_294]
    //#input(bool contentWithinThreshold(String, String[], int)): threshold
    //#output(bool contentWithinThreshold(String, String[], int)): return_value
    //#pre[2] (bool contentWithinThreshold(String, String[], int)): (soft) regexes != null
    //#pre[3] (bool contentWithinThreshold(String, String[], int)): (soft) regexes.length <= 4_294_967_295
    //#pre[4] (bool contentWithinThreshold(String, String[], int)): (soft) regexes[0..4_294_967_294] != null
    //#pre[5] (bool contentWithinThreshold(String, String[], int)): (soft) threshold <= 4_294_967_294
    //#presumption(bool contentWithinThreshold(String, String[], int)): java.util.regex.Pattern:compile(...)@122 != null
    //#presumption(bool contentWithinThreshold(String, String[], int)): java.util.regex.Pattern:matcher(...)@123 != null
    //#post(bool contentWithinThreshold(String, String[], int)): init'ed(return_value)
    //#test_vector(bool contentWithinThreshold(String, String[], int)): content: Addr_Set{null}, Inverse{null}
    //#test_vector(bool contentWithinThreshold(String, String[], int)): java.lang.String:length(...)@116: {1..4_294_967_295}, {0}
    //#test_vector(bool contentWithinThreshold(String, String[], int)): java.util.regex.Matcher:find(...)@124: {1}, {0}
      return true;
    }

    int count = 0;
    for (int i = 0; i < regexes.length; i++) {
      Pattern p = Pattern.compile(regexes[i].trim(), Pattern.CASE_INSENSITIVE | Pattern.DOTALL);
      Matcher m = p.matcher(content);
      while (m.find()) {
        count++;

        if (count > threshold) {
          return false;
        }
      }
    }

    return true;
    //#contentspamlistener.java:133: end of method: bool net.sourceforge.pebble.event.response.ContentSpamListener.contentWithinThreshold(String, String[], int)
  }

}
    //#contentspamlistener.java:: end of class: net.sourceforge.pebble.event.response.ContentSpamListener
