File Source: WeblogEntryCommentWrapper.java

         /* 
    P/P   *  Method: org.apache.roller.weblogger.pojos.wrapper.WeblogEntryCommentWrapper__static_init
          */
     1  /*
     2   * Licensed to the Apache Software Foundation (ASF) under one or more
     3   * contributor license agreements.  The ASF licenses this file to You
     4   * under the Apache License, Version 2.0 (the "License"); you may not
     5   * use this file except in compliance with the License.
     6   * You may obtain a copy of the License at
     7   *
     8   *   http://www.apache.org/licenses/LICENSE-2.0
     9   *
    10   * Unless required by applicable law or agreed to in writing, software
    11   * distributed under the License is distributed on an "AS IS" BASIS,
    12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13   * See the License for the specific language governing permissions and
    14   * limitations under the License.  For additional information regarding
    15   * copyright in this work, please see the NOTICE file in the top level
    16   * directory of this distribution.
    17   */
    18  
    19  package org.apache.roller.weblogger.pojos.wrapper;
    20  
    21  import java.sql.Timestamp;
    22  import org.apache.commons.lang.StringEscapeUtils;
    23  import org.apache.roller.weblogger.business.URLStrategy;
    24  import org.apache.roller.weblogger.business.WebloggerFactory;
    25  import org.apache.roller.weblogger.business.plugins.PluginManager;
    26  import org.apache.roller.weblogger.pojos.WeblogEntryComment;
    27  import org.apache.roller.weblogger.util.Utilities;
    28  
    29  
    30  /**
    31   * Pojo safety wrapper for WeblogEntryComment object.
    32   */
    33  public class WeblogEntryCommentWrapper {
    34      
    35      // keep a reference to the wrapped pojo
    36      private final WeblogEntryComment pojo;
    37      
    38      // url strategy to use for any url building
    39      private final URLStrategy urlStrategy;
    40      
    41      
    42      // this is private so that we can force the use of the .wrap(pojo) method
             /* 
    P/P       *  Method: void org.apache.roller.weblogger.pojos.wrapper.WeblogEntryCommentWrapper(WeblogEntryComment, URLStrategy)
              * 
              *  Postconditions:
              *    this.pojo == toWrap
              *    init'ed(this.pojo)
              *    this.urlStrategy == strat
              *    init'ed(this.urlStrategy)
              */
    43      private WeblogEntryCommentWrapper(WeblogEntryComment toWrap, URLStrategy strat) {
    44          this.pojo = toWrap;
    45          this.urlStrategy = strat;
    46      }
    47      
    48      
    49      // wrap the given pojo if it is not null
    50      public static WeblogEntryCommentWrapper wrap(WeblogEntryComment toWrap, URLStrategy strat) {
                 /* 
    P/P           *  Method: WeblogEntryCommentWrapper wrap(WeblogEntryComment, URLStrategy)
                  * 
                  *  Postconditions:
                  *    return_value == One-of{&new WeblogEntryCommentWrapper(wrap#1), null}
                  *    return_value in Addr_Set{null,&new WeblogEntryCommentWrapper(wrap#1)}
                  *    new WeblogEntryCommentWrapper(wrap#1) num objects <= 1
                  *    new WeblogEntryCommentWrapper(wrap#1).pojo == toWrap
                  *    new WeblogEntryCommentWrapper(wrap#1).pojo != null
                  *    new WeblogEntryCommentWrapper(wrap#1).urlStrategy == strat
                  *    init'ed(new WeblogEntryCommentWrapper(wrap#1).urlStrategy)
                  * 
                  *  Test Vectors:
                  *    toWrap: Addr_Set{null}, Inverse{null}
                  */
    51          if(toWrap != null)
    52              return new WeblogEntryCommentWrapper(toWrap, strat);
    53          
    54          return null;
    55      }
    56      
    57      
    58      public String getId() {
                 /* 
    P/P           *  Method: String getId()
                  * 
                  *  Preconditions:
                  *    this.pojo != null
                  * 
                  *  Postconditions:
                  *    init'ed(return_value)
                  */
    59          return this.pojo.getId();
    60      }
    61      
    62      
    63      public WeblogEntryWrapper getWeblogEntry() {
                 /* 
    P/P           *  Method: WeblogEntryWrapper getWeblogEntry()
                  * 
                  *  Preconditions:
                  *    this.pojo != null
                  * 
                  *  Presumptions:
                  *    org.apache.roller.weblogger.pojos.WeblogEntryComment:getWeblogEntry(...)@64 != null
                  * 
                  *  Postconditions:
                  *    return_value == &new WeblogEntryWrapper(wrap#1)
                  *    new WeblogEntryWrapper(wrap#1) num objects == 1
                  *    new WeblogEntryWrapper(wrap#1).pojo != null
                  *    new WeblogEntryWrapper(wrap#1).urlStrategy == this.urlStrategy
                  *    init'ed(new WeblogEntryWrapper(wrap#1).urlStrategy)
                  */
    64          return WeblogEntryWrapper.wrap(this.pojo.getWeblogEntry(), urlStrategy);
    65      }
    66      
    67      
    68      /**
    69       * Get the name of the comment writer.
    70       *
    71       * Value is always html escaped.
    72       */
    73      public String getName() {
                 /* 
    P/P           *  Method: String getName()
                  * 
                  *  Preconditions:
                  *    this.pojo != null
                  * 
                  *  Postconditions:
                  *    init'ed(return_value)
                  */
    74          return StringEscapeUtils.escapeHtml(this.pojo.getName());
    75      }
    76      
    77      
    78      /**
    79       * Get the email address of the comment writer, if specified.
    80       *
    81       * Value is always html escaped.
    82       */
    83      public String getEmail() {
                 /* 
    P/P           *  Method: String getEmail()
                  * 
                  *  Preconditions:
                  *    this.pojo != null
                  * 
                  *  Postconditions:
                  *    init'ed(return_value)
                  */
    84          return StringEscapeUtils.escapeHtml(this.pojo.getEmail());
    85      }
    86      
    87      
    88      /**
    89       * Get the url of the comment writer, if specified.
    90       *
    91       * Value is always html escaped.
    92       */
    93      public String getUrl() {
                 /* 
    P/P           *  Method: String getUrl()
                  * 
                  *  Preconditions:
                  *    this.pojo != null
                  * 
                  *  Postconditions:
                  *    init'ed(return_value)
                  */
    94          return StringEscapeUtils.escapeHtml(this.pojo.getUrl());
    95      }
    96      
    97      
    98      /**
    99       * Get the comment contents.
   100       *
   101       * Any configured comment plugins are applied first, then the value is 
   102       * always html escaped.
   103       */
   104      public String getContent() {
   105          
                 /* 
    P/P           *  Method: String getContent()
                  * 
                  *  Preconditions:
                  *    this.pojo != null
                  *    (soft) org/apache/roller/weblogger/util/Utilities.mLinkPattern != null
                  * 
                  *  Presumptions:
                  *    org.apache.roller.weblogger.business.Weblogger:getPluginManager(...)@114 != null
                  *    org.apache.roller.weblogger.business.WebloggerFactory:getWeblogger(...)@114 != null
                  * 
                  *  Postconditions:
                  *    init'ed(java.lang.StringBuffer:toString(...)._tainted)
                  *    init'ed(return_value)
                  * 
                  *  Test Vectors:
                  *    java.lang.String:equals(...)@109: {0}, {1}
                  */
   106          String content = this.pojo.getContent();
   107          
   108          // escape content if content-type is text/plain
   109          if("text/plain".equals(this.pojo.getContentType())) {
   110              content = StringEscapeUtils.escapeHtml(content);
   111          }
   112          
   113          // apply plugins
   114          PluginManager pmgr = WebloggerFactory.getWeblogger().getPluginManager();
   115          content = pmgr.applyCommentPlugins(this.pojo, content);
   116          
   117          // always add rel=nofollow for links
   118          content = Utilities.addNofollow(content);
   119          
   120          return content;
   121      }
   122      
   123      
   124      /**
   125       * Get the time the comment was posted.
   126       */
   127      public Timestamp getPostTime() {
                 /* 
    P/P           *  Method: Timestamp getPostTime()
                  * 
                  *  Preconditions:
                  *    this.pojo != null
                  * 
                  *  Postconditions:
                  *    init'ed(return_value)
                  */
   128          return this.pojo.getPostTime();
   129      }
   130      
   131      
   132      public String getStatus() {
                 /* 
    P/P           *  Method: String getStatus()
                  * 
                  *  Preconditions:
                  *    this.pojo != null
                  * 
                  *  Postconditions:
                  *    init'ed(return_value)
                  */
   133          return this.pojo.getStatus();
   134      }
   135      
   136      
   137      public Boolean getNotify() {
                 /* 
    P/P           *  Method: Boolean getNotify()
                  * 
                  *  Preconditions:
                  *    this.pojo != null
                  * 
                  *  Postconditions:
                  *    init'ed(return_value)
                  */
   138          return this.pojo.getNotify();
   139      }
   140      
   141      
   142      public String getRemoteHost() {
                 /* 
    P/P           *  Method: String getRemoteHost()
                  * 
                  *  Preconditions:
                  *    this.pojo != null
                  * 
                  *  Postconditions:
                  *    init'ed(return_value)
                  */
   143          return this.pojo.getRemoteHost();
   144      }
   145      
   146      
   147      /**
   148       * Get the http referrer of the comment poster, used for trackbacks.
   149       *
   150       * Value is always html escaped.
   151       */
   152      public String getReferrer() {
                 /* 
    P/P           *  Method: String getReferrer()
                  * 
                  *  Preconditions:
                  *    this.pojo != null
                  * 
                  *  Postconditions:
                  *    init'ed(return_value)
                  */
   153          return StringEscapeUtils.escapeHtml(this.pojo.getReferrer());
   154      }
   155      
   156      
   157      public String getUserAgent() {
                 /* 
    P/P           *  Method: String getUserAgent()
                  * 
                  *  Preconditions:
                  *    this.pojo != null
                  * 
                  *  Postconditions:
                  *    init'ed(return_value)
                  */
   158          return this.pojo.getUserAgent();
   159      }
   160      
   161      
   162      public Boolean getSpam() {
                 /* 
    P/P           *  Method: Boolean getSpam()
                  * 
                  *  Preconditions:
                  *    this.pojo != null
                  * 
                  *  Postconditions:
                  *    init'ed(return_value)
                  */
   163          return this.pojo.getSpam();
   164      }
   165      
   166      
   167      public Boolean getPending() {
                 /* 
    P/P           *  Method: Boolean getPending()
                  * 
                  *  Preconditions:
                  *    this.pojo != null
                  * 
                  *  Postconditions:
                  *    init'ed(return_value)
                  */
   168          return this.pojo.getPending();
   169      }
   170      
   171      
   172      public Boolean getApproved() {
                 /* 
    P/P           *  Method: Boolean getApproved()
                  * 
                  *  Preconditions:
                  *    this.pojo != null
                  * 
                  *  Postconditions:
                  *    init'ed(return_value)
                  */
   173          return this.pojo.getApproved();
   174      }
   175      
   176      
   177      public String getTimestamp() {
                 /* 
    P/P           *  Method: String getTimestamp()
                  * 
                  *  Preconditions:
                  *    this.pojo != null
                  * 
                  *  Postconditions:
                  *    init'ed(return_value)
                  */
   178          return this.pojo.getTimestamp();
   179      }
   180      
   181  }








SofCheck Inspector Build Version : 2.18479
WeblogEntryCommentWrapper.java 2009-Jan-02 14:25:14
WeblogEntryCommentWrapper.class 2009-Sep-04 03:12:32