//# 0 errors, 50 messages
//#
/*
    //#ExcessSizeCommentValidator.java:1:1: class: org.apache.roller.weblogger.ui.rendering.plugins.comments.ExcessSizeCommentValidator
    //#ExcessSizeCommentValidator.java:1:1: method: org.apache.roller.weblogger.ui.rendering.plugins.comments.ExcessSizeCommentValidator.org.apache.roller.weblogger.ui.rendering.plugins.comments.ExcessSizeCommentValidator__static_init
 * Licensed to the Apache Software Foundation (ASF) under one or more
 *  contributor license agreements.  The ASF licenses this file to You
 * under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.  For additional information regarding
 * copyright in this work, please see the NOTICE file in the top level
 * directory of this distribution.
 */

package org.apache.roller.weblogger.ui.rendering.plugins.comments;

import java.util.ResourceBundle;
import org.apache.roller.weblogger.config.WebloggerConfig;
import org.apache.roller.weblogger.pojos.WeblogEntryComment;
import org.apache.roller.weblogger.util.RollerMessages;

/**
 * Validates comment only if it has less than comment.validator.excessSize.threshold characters
 */
public class ExcessSizeCommentValidator implements CommentValidator {
    private ResourceBundle bundle = ResourceBundle.getBundle("ApplicationResources");  
    private int threshold;
    
    public ExcessSizeCommentValidator() {
    //#ExcessSizeCommentValidator.java:33: method: void org.apache.roller.weblogger.ui.rendering.plugins.comments.ExcessSizeCommentValidator.org.apache.roller.weblogger.ui.rendering.plugins.comments.ExcessSizeCommentValidator()
    //#input(void org.apache.roller.weblogger.ui.rendering.plugins.comments.ExcessSizeCommentValidator()): this
    //#output(void org.apache.roller.weblogger.ui.rendering.plugins.comments.ExcessSizeCommentValidator()): this.bundle
    //#output(void org.apache.roller.weblogger.ui.rendering.plugins.comments.ExcessSizeCommentValidator()): this.threshold
    //#post(void org.apache.roller.weblogger.ui.rendering.plugins.comments.ExcessSizeCommentValidator()): init'ed(this.bundle)
    //#post(void org.apache.roller.weblogger.ui.rendering.plugins.comments.ExcessSizeCommentValidator()): init'ed(this.threshold)
        threshold = WebloggerConfig.getIntProperty("comment.validator.excessSize.threshold");
    //#ExcessSizeCommentValidator.java:34: Warning: method not available
    //#    -- call on int org.apache.roller.weblogger.config.WebloggerConfig:getIntProperty(String)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.plugins.comments.ExcessSizeCommentValidator
    //#    method: void org.apache.roller.weblogger.ui.rendering.plugins.comments.ExcessSizeCommentValidator()
    //#    unanalyzed callee: int org.apache.roller.weblogger.config.WebloggerConfig:getIntProperty(String)
    }
    //#ExcessSizeCommentValidator.java:35: end of method: void org.apache.roller.weblogger.ui.rendering.plugins.comments.ExcessSizeCommentValidator.org.apache.roller.weblogger.ui.rendering.plugins.comments.ExcessSizeCommentValidator()
    
    public String getName() {
        return bundle.getString("comment.validator.excessSizeName");
    //#ExcessSizeCommentValidator.java:38: method: String org.apache.roller.weblogger.ui.rendering.plugins.comments.ExcessSizeCommentValidator.getName()
    //#input(String getName()): this
    //#input(String getName()): this.bundle
    //#output(String getName()): return_value
    //#pre[2] (String getName()): this.bundle != null
    //#post(String getName()): init'ed(return_value)
    //#ExcessSizeCommentValidator.java:38: end of method: String org.apache.roller.weblogger.ui.rendering.plugins.comments.ExcessSizeCommentValidator.getName()
    }

    public int validate(WeblogEntryComment comment, RollerMessages messages) {
        if (comment.getContent() != null && comment.getContent().length() > threshold) {
    //#ExcessSizeCommentValidator.java:42: method: int org.apache.roller.weblogger.ui.rendering.plugins.comments.ExcessSizeCommentValidator.validate(WeblogEntryComment, RollerMessages)
    //#ExcessSizeCommentValidator.java:42: Warning: method not available
    //#    -- call on String org.apache.roller.weblogger.pojos.WeblogEntryComment:getContent()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.plugins.comments.ExcessSizeCommentValidator
    //#    method: int validate(WeblogEntryComment, RollerMessages)
    //#    unanalyzed callee: String org.apache.roller.weblogger.pojos.WeblogEntryComment:getContent()
    //#input(int validate(WeblogEntryComment, RollerMessages)): comment
    //#input(int validate(WeblogEntryComment, RollerMessages)): messages
    //#input(int validate(WeblogEntryComment, RollerMessages)): messages.__Tag
    //#input(int validate(WeblogEntryComment, RollerMessages)): messages.mErrors
    //#input(int validate(WeblogEntryComment, RollerMessages)): org/apache/roller/weblogger/util/RollerMessages.__Descendant_Table[org/apache/roller/weblogger/util/RollerMessages]
    //#input(int validate(WeblogEntryComment, RollerMessages)): org/apache/roller/weblogger/util/RollerMessages.__Descendant_Table[others]
    //#input(int validate(WeblogEntryComment, RollerMessages)): org/apache/roller/weblogger/util/RollerMessages.__Dispatch_Table.addError(Ljava/lang/String;Ljava/lang/String;)V
    //#input(int validate(WeblogEntryComment, RollerMessages)): this
    //#input(int validate(WeblogEntryComment, RollerMessages)): this.threshold
    //#output(int validate(WeblogEntryComment, RollerMessages)): return_value
    //#pre[1] (int validate(WeblogEntryComment, RollerMessages)): comment != null
    //#pre[2] (int validate(WeblogEntryComment, RollerMessages)): (soft) messages != null
    //#pre[3] (int validate(WeblogEntryComment, RollerMessages)): (soft) messages.__Tag == org/apache/roller/weblogger/util/RollerMessages
    //#pre[4] (int validate(WeblogEntryComment, RollerMessages)): (soft) messages.mErrors != null
    //#pre[6] (int validate(WeblogEntryComment, RollerMessages)): (soft) init'ed(this.threshold)
    //#presumption(int validate(WeblogEntryComment, RollerMessages)): org.apache.roller.weblogger.pojos.WeblogEntryComment:getContent(...)@42 != null
    //#post(int validate(WeblogEntryComment, RollerMessages)): return_value in {0, 100}
    //#unanalyzed(int validate(WeblogEntryComment, RollerMessages)): Effects-of-calling:org.apache.roller.weblogger.util.RollerMessages$RollerMessage
    //#unanalyzed(int validate(WeblogEntryComment, RollerMessages)): Effects-of-calling:java.util.List:add
    //#test_vector(int validate(WeblogEntryComment, RollerMessages)): org.apache.roller.weblogger.pojos.WeblogEntryComment:getContent(...)@42: Addr_Set{null}, Inverse{null}
            messages.addError("comment.validator.excessSizeMessage", Integer.toString(threshold));
            return 0;
        }
        return 100;
    //#ExcessSizeCommentValidator.java:46: end of method: int org.apache.roller.weblogger.ui.rendering.plugins.comments.ExcessSizeCommentValidator.validate(WeblogEntryComment, RollerMessages)
    }
    
}
    //#output(org.apache.roller.weblogger.ui.rendering.plugins.comments.ExcessSizeCommentValidator__static_init): __Descendant_Table[org/apache/roller/weblogger/ui/rendering/plugins/comments/ExcessSizeCommentValidator]
    //#output(org.apache.roller.weblogger.ui.rendering.plugins.comments.ExcessSizeCommentValidator__static_init): __Dispatch_Table.getName()Ljava/lang/String;
    //#output(org.apache.roller.weblogger.ui.rendering.plugins.comments.ExcessSizeCommentValidator__static_init): __Dispatch_Table.validate(Lorg/apache/roller/weblogger/pojos/WeblogEntryComment;Lorg/apache/roller/weblogger/util/RollerMessages;)I
    //#output(org.apache.roller.weblogger.ui.rendering.plugins.comments.ExcessSizeCommentValidator__static_init): org/apache/roller/weblogger/ui/rendering/plugins/comments/CommentValidator.__Descendant_Table[org/apache/roller/weblogger/ui/rendering/plugins/comments/ExcessSizeCommentValidator]
    //#post(org.apache.roller.weblogger.ui.rendering.plugins.comments.ExcessSizeCommentValidator__static_init): __Descendant_Table[org/apache/roller/weblogger/ui/rendering/plugins/comments/ExcessSizeCommentValidator] == &__Dispatch_Table
    //#post(org.apache.roller.weblogger.ui.rendering.plugins.comments.ExcessSizeCommentValidator__static_init): org/apache/roller/weblogger/ui/rendering/plugins/comments/CommentValidator.__Descendant_Table[org/apache/roller/weblogger/ui/rendering/plugins/comments/ExcessSizeCommentValidator] == &__Dispatch_Table
    //#post(org.apache.roller.weblogger.ui.rendering.plugins.comments.ExcessSizeCommentValidator__static_init): __Dispatch_Table.getName()Ljava/lang/String; == &getName
    //#post(org.apache.roller.weblogger.ui.rendering.plugins.comments.ExcessSizeCommentValidator__static_init): __Dispatch_Table.validate(Lorg/apache/roller/weblogger/pojos/WeblogEntryComment;Lorg/apache/roller/weblogger/util/RollerMessages;)I == &validate
    //#ExcessSizeCommentValidator.java:: end of method: org.apache.roller.weblogger.ui.rendering.plugins.comments.ExcessSizeCommentValidator.org.apache.roller.weblogger.ui.rendering.plugins.comments.ExcessSizeCommentValidator__static_init
    //#ExcessSizeCommentValidator.java:: end of class: org.apache.roller.weblogger.ui.rendering.plugins.comments.ExcessSizeCommentValidator
