File Source: PreviousCommand.java

         /* 
    P/P   *  Method: com.dmdirc.commandparser.commands.PreviousCommand__static_init
          */
     1  /*
     2   * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
     3   *
     4   * Permission is hereby granted, free of charge, to any person obtaining a copy
     5   * of this software and associated documentation files (the "Software"), to deal
     6   * in the Software without restriction, including without limitation the rights
     7   * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
     8   * copies of the Software, and to permit persons to whom the Software is
     9   * furnished to do so, subject to the following conditions:
    10   *
    11   * The above copyright notice and this permission notice shall be included in
    12   * all copies or substantial portions of the Software.
    13   *
    14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
    20   * SOFTWARE.
    21   */
    22  
    23  package com.dmdirc.commandparser.commands;
    24  
    25  import java.util.Date;
    26  
    27  /**
    28   * Stores information about a previously executed command.
    29   * 
    30   * @author chris
    31   */
    32  public final class PreviousCommand {
    33     
    34      /** The full command that was executed. */
    35      private final String line;
    36      
    37      /** The timestamp of its execution. */
    38      private final long time;
    39      
    40      /**
    41       * Creates a new record of the specified command.
    42       * 
    43       * @param line The full command that was executed
    44       */
             /* 
    P/P       *  Method: void com.dmdirc.commandparser.commands.PreviousCommand(String)
              * 
              *  Postconditions:
              *    this.line == line
              *    init'ed(this.line)
              *    init'ed(this.time)
              */
    45      public PreviousCommand(final String line) {
    46          this.line = line;
    47          this.time = new Date().getTime();
    48      }
    49      
    50      /**
    51       * Retrieves the time that the command was executed at.
    52       * 
    53       * @return The timestamp that the command was executed at
    54       */
    55      public long getTime() {
                 /* 
    P/P           *  Method: long getTime()
                  * 
                  *  Postconditions:
                  *    return_value == this.time
                  *    init'ed(return_value)
                  */
    56          return time;
    57      }
    58      
    59      /**
    60       * Retrieves the command that was executed.
    61       * 
    62       * @return The command that was executed.
    63       */
    64      public String getLine() {
                 /* 
    P/P           *  Method: String getLine()
                  * 
                  *  Postconditions:
                  *    return_value == this.line
                  *    init'ed(return_value)
                  */
    65          return line;
    66      }
    67  
    68      /** {@inheritDoc} */
    69      @Override
    70      public boolean equals(final Object obj) {
                 /* 
    P/P           *  Method: bool equals(Object)
                  * 
                  *  Postconditions:
                  *    init'ed(return_value)
                  * 
                  *  Test Vectors:
                  *    obj: Inverse{null}, Addr_Set{null}
                  *    this.line: Addr_Set{null}, Inverse{null}
                  *    this.line == obj.line: {1}, {0}
                  *    java.lang.String:equals(...)@80: {1}, {0}
                  */
    71          if (obj == null) {
    72              return false;
    73          }
    74          
    75          if (getClass() != obj.getClass()) {
    76              return false;
    77          }
    78          
    79          final PreviousCommand other = (PreviousCommand) obj;
    80          if (this.line != other.line
    81                  && (this.line == null || !this.line.equals(other.line))) {
    82              return false;
    83          }
    84          
    85          return true;
    86      }
    87  
    88      /** {@inheritDoc} */
    89      @Override
    90      public int hashCode() {
                 /* 
    P/P           *  Method: int hashCode()
                  * 
                  *  Presumptions:
                  *    java.lang.String:hashCode(...)@92 <= 4_294_966_810
                  * 
                  *  Postconditions:
                  *    return_value >= -2_147_483_163
                  */
    91          int hash = 5;
    92          hash = 97 * hash + (this.line == null ? 0 : this.line.hashCode());
    93          return hash;
    94      }
    95      
    96  }








SofCheck Inspector Build Version : 2.17854
PreviousCommand.java 2009-Jun-25 01:54:24
PreviousCommand.class 2009-Sep-02 17:04:12