File Source: AbstractPager.java

         /* 
    P/P   *  Method: org.apache.roller.weblogger.ui.rendering.pagers.AbstractPager__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.ui.rendering.pagers;
    20  
    21  import java.util.HashMap;
    22  import java.util.Map;
    23  import org.apache.roller.weblogger.business.URLStrategy;
    24  import org.apache.roller.weblogger.util.URLUtilities;
    25  
    26  
    27  /**
    28   * Abstract base for simple pagers.
    29   */
    30  public abstract class AbstractPager implements Pager {
    31      
    32      final URLStrategy urlStrategy;
    33      private String url = null;
    34      private int page = 0;
    35      
    36      
             /* 
    P/P       *  Method: void org.apache.roller.weblogger.ui.rendering.pagers.AbstractPager(URLStrategy, String, int)
              * 
              *  Postconditions:
              *    this.page == One-of{0, pageNum}
              *    this.page >= 0
              *    this.url == baseUrl
              *    init'ed(this.url)
              *    this.urlStrategy == strat
              *    init'ed(this.urlStrategy)
              * 
              *  Test Vectors:
              *    pageNum: {-231..0}, {1..232-1}
              */
    37      public AbstractPager(URLStrategy strat, String baseUrl, int pageNum) {
    38          
    39          this.urlStrategy = strat;
    40          this.url = baseUrl;
    41          if(pageNum > 0) {
    42              this.page = pageNum;
    43          }
    44      }
    45      
    46      
    47      public String getHomeLink() {
                 /* 
    P/P           *  Method: String getHomeLink()
                  * 
                  *  Preconditions:
                  *    init'ed(this.url)
                  * 
                  *  Postconditions:
                  *    return_value == this.url
                  *    init'ed(return_value)
                  */
    48          return url;
    49      }
    50      
    51      
    52      public String getHomeName() {
                 /* 
    P/P           *  Method: String getHomeName()
                  * 
                  *  Postconditions:
                  *    return_value == &"Home"
                  */
    53          return "Home";
    54      }
    55      
    56      
    57      public String getNextLink() {
                 /* 
    P/P           *  Method: String getNextLink()
                  * 
                  *  Preconditions:
                  *    (soft) this.page <= 232-2
                  *    (soft) init'ed(this.url)
                  * 
                  *  Postconditions:
                  *    init'ed(java.lang.StringBuilder:toString(...)._tainted)
                  *    return_value in Addr_Set{null,&java.lang.StringBuilder:toString(...),&java.lang.StringBuilder:toString(...),&java.lang.StringBuilder:toString(...),&java.lang.StringBuilder:toString(...)}
                  * 
                  *  Test Vectors:
                  *    hasMoreItems(...)@58: {0}, {1}
                  */
    58          if(hasMoreItems()) {
    59              int nextPage = page + 1;
    60              Map params = new HashMap();
    61              params.put("page", ""+nextPage);
    62              return createURL(url, params);
    63          }
    64          return null;
    65      }
    66      
    67      
    68      public String getNextName() {
                 /* 
    P/P           *  Method: String getNextName()
                  * 
                  *  Postconditions:
                  *    return_value in Addr_Set{null,&"Next"}
                  * 
                  *  Test Vectors:
                  *    hasMoreItems(...)@69: {0}, {1}
                  */
    69          if(hasMoreItems()) {
    70              return "Next";
    71          }
    72          return null;
    73      }
    74      
    75      
    76      public String getPrevLink() {
                 /* 
    P/P           *  Method: String getPrevLink()
                  * 
                  *  Preconditions:
                  *    init'ed(this.page)
                  *    (soft) init'ed(this.url)
                  * 
                  *  Postconditions:
                  *    init'ed(java.lang.StringBuilder:toString(...)._tainted)
                  *    return_value in Addr_Set{null,&java.lang.StringBuilder:toString(...),&java.lang.StringBuilder:toString(...),&java.lang.StringBuilder:toString(...),&java.lang.StringBuilder:toString(...)}
                  * 
                  *  Test Vectors:
                  *    this.page: {-231..0}, {1..232-1}
                  */
    77          if (page > 0) {
    78              int prevPage = page - 1;
    79              Map params = new HashMap();
    80              params.put("page", ""+prevPage);
    81              return createURL(url, params);
    82          }
    83          return null;
    84      }
    85      
    86      
    87      public String getPrevName() {
                 /* 
    P/P           *  Method: String getPrevName()
                  * 
                  *  Preconditions:
                  *    init'ed(this.page)
                  * 
                  *  Postconditions:
                  *    return_value in Addr_Set{null,&"Previous"}
                  * 
                  *  Test Vectors:
                  *    this.page: {-231..0}, {1..232-1}
                  */
    88          if (page > 0) {
    89              return "Previous";
    90          }
    91          return null;
    92      }
    93      
    94      
    95      public boolean hasMoreItems() {
                 /* 
    P/P           *  Method: bool hasMoreItems()
                  * 
                  *  Postconditions:
                  *    return_value == 0
                  */
    96          return false;
    97      }
    98      
    99      
   100      protected String createURL(String url, Map params) {
   101          
                 /* 
    P/P           *  Method: String createURL(String, Map)
                  * 
                  *  Postconditions:
                  *    init'ed(java.lang.StringBuilder:toString(...)._tainted)
                  *    return_value == &java.lang.StringBuilder:toString(...)
                  */
   102          return url + URLUtilities.getQueryString(params);
   103      }
   104  
   105      
   106      public String getUrl() {
                 /* 
    P/P           *  Method: String getUrl()
                  * 
                  *  Preconditions:
                  *    init'ed(this.url)
                  * 
                  *  Postconditions:
                  *    return_value == this.url
                  *    init'ed(return_value)
                  */
   107          return url;
   108      }
   109  
   110      public void setUrl(String url) {
                 /* 
    P/P           *  Method: void setUrl(String)
                  * 
                  *  Postconditions:
                  *    this.url == url
                  *    init'ed(this.url)
                  */
   111          this.url = url;
   112      }
   113  
   114      public int getPage() {
                 /* 
    P/P           *  Method: int getPage()
                  * 
                  *  Preconditions:
                  *    init'ed(this.page)
                  * 
                  *  Postconditions:
                  *    return_value == this.page
                  *    init'ed(return_value)
                  */
   115          return page;
   116      }
   117  
   118      public void setPage(int page) {
                 /* 
    P/P           *  Method: void setPage(int)
                  * 
                  *  Postconditions:
                  *    this.page == page
                  *    init'ed(this.page)
                  */
   119          this.page = page;
   120      }
   121      
   122  }








SofCheck Inspector Build Version : 2.18479
AbstractPager.java 2009-Jan-02 14:25:08
AbstractPager.class 2009-Sep-04 03:12:44