File Source: nulllogger.java

         /* 
    P/P   *  Method: net.sourceforge.pebble.logging.NullLogger__static_init
          */
     1  /*
     2   * Copyright (c) 2003-2006, Simon Brown
     3   * All rights reserved.
     4   *
     5   * Redistribution and use in source and binary forms, with or without
     6   * modification, are permitted provided that the following conditions are met:
     7   *
     8   *   - Redistributions of source code must retain the above copyright
     9   *     notice, this list of conditions and the following disclaimer.
    10   *
    11   *   - Redistributions in binary form must reproduce the above copyright
    12   *     notice, this list of conditions and the following disclaimer in
    13   *     the documentation and/or other materials provided with the
    14   *     distribution.
    15   *
    16   *   - Neither the name of Pebble nor the names of its contributors may
    17   *     be used to endorse or promote products derived from this software
    18   *     without specific prior written permission.
    19   *
    20   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
    21   * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    22   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    23   * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
    24   * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    25   * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
    26   * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
    27   * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
    28   * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
    29   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    30   * POSSIBILITY OF SUCH DAMAGE.
    31   */
    32  package net.sourceforge.pebble.logging;
    33  
    34  import net.sourceforge.pebble.domain.Blog;
    35  
         /* 
    P/P   *  Method: void net.sourceforge.pebble.logging.NullLogger(Blog)
          * 
          *  Postconditions:
          *    this.blog == blog
          *    init'ed(this.blog)
          */
    36  import javax.servlet.http.HttpServletRequest;
    37  import java.util.ArrayList;
    38  import java.util.Calendar;
    39  
    40  /**
    41   * A no-op logger that can be used when Pebble logging isn't required, such
    42   * as when something like Apache provides the necessary logging already.
    43   *
    44   * @author    Simon Brown
    45   */
    46  public class NullLogger extends AbstractLogger {
    47  
    48    /**
    49     * Creates a new instance associated with the specified blog.
    50     *                                                 
    51     * @param blog    a Blog instance
    52     */
    53    public NullLogger(Blog blog) {
    54      super(blog);
    55    }
    56  
    57    /**
    58     * Logs a HTTP request.
    59     *
    60     * @param request   a HttpServletRequest
    61     */
    62    public void log(HttpServletRequest request, int status) {
           /* 
    P/P     *  Method: void log(HttpServletRequest, int)
            */
    63    }
    64  
    65    /**
    66     * Called to start this logger.
    67     */
           /* 
    P/P     *  Method: void start()
            */
    68    public void start() {
    69    }
    70  
    71    /**
    72     * Called to stop this logger.
    73     */
           /* 
    P/P     *  Method: void stop()
            */
    74    public void stop() {
    75    }
    76  
    77    /**
    78     * Gets a copy of the log file for a given year, month and day.
    79     *
    80     * @param year    the year to get entries for
    81     * @param month   the month to get entries for
    82     * @param day     the day to get entries for
    83     * @return    a String containing the contents of the requested log file
    84     */
           /* 
    P/P     *  Method: String getLogFile(int, int, int)
            * 
            *  Postconditions:
            *    return_value == &""
            */
    85    public String getLogFile(int year, int month, int day) {
    86      return "";
    87    }
    88  
    89    /**
    90     * Gets the log for a given year, month and day.
    91     *
    92     * @param year    the year to get entries for
    93     * @param month   the month to get entries for
    94     * @param day     the day to get entries for
    95     * @return    a Log object
    96     */
           /* 
    P/P     *  Method: Log getLog(int, int, int)
            * 
            *  Preconditions:
            *    init'ed(this.blog)
            * 
            *  Postconditions:
            *    return_value == &new Log(getLog#1)
            *    new ArrayList(Log#1) num objects == 0
            *    new ArrayList(getLog#2) num objects == 1
            *    new Log(getLog#1) num objects == 1
            *    return_value.blog == this.blog
            *    init'ed(return_value.blog)
            *    return_value.logEntries == &new ArrayList(getLog#2)
            */
    97    public Log getLog(int year, int month, int day) {
    98      return new Log(blog, new ArrayList());
    99    }
   100  
   101    /**
   102     * Gets the log summary information for the given year, month and day.
   103     *
   104     * @param year  the year to get entries for
   105     * @param month the month to get entries for
   106     * @param day   the day to get entries for
   107     * @return a LogSummary object
   108     */
           /* 
    P/P     *  Method: LogSummary getLogSummary(int, int, int)
            * 
            *  Preconditions:
            *    month >= -231+1
            *    this.blog != null
            * 
            *  Presumptions:
            *    net.sourceforge.pebble.domain.Blog:getCalendar(...)@110 != null
            * 
            *  Postconditions:
            *    return_value == &new LogSummaryItem(getLogSummary#1)
            *    new LogSummaryItem(getLogSummary#1) num objects == 1
            *    return_value.blog == this.blog
            *    return_value.blog != null
            *    init'ed(return_value.date)
            *    return_value.totalRequests == 0
            */
   109    public LogSummary getLogSummary(int year, int month, int day) {
   110      Calendar cal = blog.getCalendar();
   111      cal.set(Calendar.YEAR, year);
   112      cal.set(Calendar.MONTH, month-1);
   113      cal.set(Calendar.DAY_OF_MONTH, day);
   114      int totalRequests = 0;
   115  
   116      return new LogSummaryItem(blog, cal.getTime(), totalRequests);
   117    }
   118  
   119  }








SofCheck Inspector Build Version : 2.22510
nulllogger.java 2010-Jun-25 19:40:32
nulllogger.class 2010-Jul-19 20:23:38