File Source: MyInfo.java

         /* 
    P/P   *  Method: com.dmdirc.parser.irc.MyInfo__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.parser.irc;
    24  
    25  /**
    26   * Contains User information.
    27   * 
    28   * @author Shane Mc Cormack
    29   * @author Chris Smith
    30   * @see IRCParser
    31   */
    32  public final class MyInfo {
    33  	/** Character to prepend to nickname if in use (Default "_"). */
    34  	private char prependChar = '_';	
    35  	/** Nickname to attempt to use on IRC. */
    36  	private String nickname;
    37  	/**
    38  	 * Alternative nickname to attempt to use on IRC.
    39  	 * If the first nickname is in use, and a NickInUse message is recieved before 001, we
    40  	 * will attempt to use this nickname instead.<br>
    41  	 * If this also fails, we will start prepending the prependChar character (_) to the main nickname
    42  	 */
    43  	private String altNickname;
    44  	/** Realname string to use */
    45  	private String realname;
    46  	/** Username to use, this doesn't matter when an ident server is running*/
    47  	private String username;
    48  	
    49  	/**
    50  	 * Create a new MyInfo object.
    51  	 */
        	 /* 
    P/P 	  *  Method: void com.dmdirc.parser.irc.MyInfo()
        	  * 
        	  *  Postconditions:
        	  *    java.lang.StringBuilder:toString(...)._tainted == 0
        	  *    this.altNickname in Addr_Set{&amp;java.lang.StringBuilder:toString(...),&amp;"IRC-Parser"}
        	  *    this.nickname != null
        	  *    this.prependChar == 95
        	  *    this.realname in Addr_Set{&amp;java.lang.StringBuilder:toString(...),&amp;"DMDIrc IRCParser"}
        	  *    this.username != null
        	  * 
        	  *  Test Vectors:
        	  *    java.lang.String:isEmpty(...)@59: {0}, {1}
        	  */
    52  	public MyInfo() {
    53  		String result;
    54  		try {
    55  			result = System.getProperty("user.name");
    56  		} catch (SecurityException e) {
    57  			result = null;
    58  		}
    59  		if (result == null || result.isEmpty()) {
    60  			nickname = "IRCParser";
    61  			username = "IRCParser";
    62  			realname = "DMDIrc IRCParser";
    63  			altNickname = "IRC-Parser";
    64  		} else {
    65  			nickname = result;
    66  			username = nickname;
    67  			realname = nickname+" - DMDIrc";
    68  			altNickname = nickname+"-";
    69  		}
    70  	}
    71  	
    72  	/**
    73  	 * Set the Nickname.
    74  	 *
    75  	 * @param newValue Value to set to.
    76  	 */
    77  	public void setNickname(final String newValue) {
        		 /* 
    P/P 		  *  Method: void setNickname(String)
        		  * 
        		  *  Postconditions:
        		  *    this.nickname == One-of{old this.nickname, newValue}
        		  * 
        		  *  Test Vectors:
        		  *    newValue: Addr_Set{null}, Inverse{null}
        		  *    java.lang.String:isEmpty(...)@78: {1}, {0}
        		  */
    78  		if (newValue != null && !newValue.isEmpty()) {
    79  			nickname = newValue;
    80  		}
    81  	}
    82  	
    83  	/**
    84  	 * Get the Nickname.
    85  	 *
    86  	 * @return Current Nickname
    87  	 */
        	 /* 
    P/P 	  *  Method: String getNickname()
        	  * 
        	  *  Preconditions:
        	  *    init'ed(this.nickname)
        	  * 
        	  *  Postconditions:
        	  *    return_value == this.nickname
        	  *    init'ed(return_value)
        	  */
    88  	public String getNickname() { return nickname; }
    89  	
    90  	/**
    91  	 * Set the Alternative Nickname.
    92  	 *
    93  	 * @param newValue Value to set to.
    94  	 */
    95  	public void setAltNickname(final String newValue) {
        		 /* 
    P/P 		  *  Method: void setAltNickname(String)
        		  * 
        		  *  Postconditions:
        		  *    this.altNickname == One-of{old this.altNickname, newValue}
        		  * 
        		  *  Test Vectors:
        		  *    newValue: Addr_Set{null}, Inverse{null}
        		  *    java.lang.String:isEmpty(...)@96: {1}, {0}
        		  */
    96  		if (newValue != null && !newValue.isEmpty()) {
    97  			altNickname = newValue;
    98  		}
    99  	}
   100  	
   101  	/**
   102  	 * Get the Alternative Nickname.
   103  	 *
   104  	 * @return Current Nickname
   105  	 */
        	 /* 
    P/P 	  *  Method: String getAltNickname()
        	  * 
        	  *  Preconditions:
        	  *    init'ed(this.altNickname)
        	  * 
        	  *  Postconditions:
        	  *    return_value == this.altNickname
        	  *    init'ed(return_value)
        	  */
   106  	public String getAltNickname() { return altNickname; }
   107  	
   108  	/**
   109  	 * Set the Realname.
   110  	 *
   111  	 * @param newValue Value to set to.
   112  	 */
   113  	public void setRealname(final String newValue) {
        		 /* 
    P/P 		  *  Method: void setRealname(String)
        		  * 
        		  *  Postconditions:
        		  *    this.realname == One-of{old this.realname, newValue}
        		  * 
        		  *  Test Vectors:
        		  *    newValue: Addr_Set{null}, Inverse{null}
        		  *    java.lang.String:isEmpty(...)@114: {1}, {0}
        		  */
   114  		if (newValue != null && !newValue.isEmpty()) {
   115  			realname = newValue;
   116  		}
   117  	}
   118  	
   119  	/**
   120  	 * Get the Realname.
   121  	 *
   122  	 * @return Current Realname
   123  	 */
        	 /* 
    P/P 	  *  Method: String getRealname()
        	  * 
        	  *  Preconditions:
        	  *    init'ed(this.realname)
        	  * 
        	  *  Postconditions:
        	  *    return_value == this.realname
        	  *    init'ed(return_value)
        	  */
   124  	public String getRealname() { return realname; }
   125  	
   126  	/**
   127  	 * Set the Username.
   128  	 *
   129  	 * @param newValue Value to set to.
   130  	 */
   131  	public void setUsername(final String newValue) {
        		 /* 
    P/P 		  *  Method: void setUsername(String)
        		  * 
        		  *  Postconditions:
        		  *    this.username == One-of{old this.username, newValue}
        		  * 
        		  *  Test Vectors:
        		  *    newValue: Addr_Set{null}, Inverse{null}
        		  *    java.lang.String:isEmpty(...)@132: {1}, {0}
        		  */
   132  		if (newValue != null && !newValue.isEmpty()) {
   133  			username = newValue;
   134  		}
   135  	}
   136  	
   137  	/**
   138  	 * Get the Username.
   139  	 *
   140  	 * @return Current Username
   141  	 */
        	 /* 
    P/P 	  *  Method: String getUsername()
        	  * 
        	  *  Preconditions:
        	  *    init'ed(this.username)
        	  * 
        	  *  Postconditions:
        	  *    return_value == this.username
        	  *    init'ed(return_value)
        	  */
   142  	public String getUsername() { return username; }
   143  	
   144  	/**
   145  	 * Set the Prepend Character.
   146  	 *
   147  	 * @param newValue Value to set to.
   148  	 */
        	 /* 
    P/P 	  *  Method: void setPrependChar(char)
        	  * 
        	  *  Postconditions:
        	  *    this.prependChar == newValue
        	  *    init'ed(this.prependChar)
        	  */
   149  	public void setPrependChar(final char newValue) { prependChar = newValue; }
   150  	
   151  	/**
   152  	 * Get the Prepend Character.
   153  	 *
   154  	 * @return Current Prepend Character
   155  	 */
        	 /* 
    P/P 	  *  Method: char getPrependChar()
        	  * 
        	  *  Preconditions:
        	  *    init'ed(this.prependChar)
        	  * 
        	  *  Postconditions:
        	  *    return_value == this.prependChar
        	  *    init'ed(return_value)
        	  */
   156  	public char getPrependChar() { return prependChar; }	
   157  
   158  }








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