File Source: ProcessMOTD.java

         /* 
    P/P   *  Method: com.dmdirc.parser.irc.ProcessMOTD__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   * Process a MOTD Related Line.
    27   */
    28  public class ProcessMOTD extends IRCProcessor {
    29  
    30  	/**
    31  	 * Process a MOTD Related Line.
    32  	 *
    33  	 * @param sParam Type of line to process ("375", "372", "376", "422")
    34  	 * @param token IRCTokenised line to process
    35  	 */
    36  	@Override
    37  	public void process(String sParam, String[] token) {
        		 /* 
    P/P 		  *  Method: void process(String, String[])
        		  * 
        		  *  Preconditions:
        		  *    sParam != null
        		  *    token != null
        		  *    token.length in {1..232}
        		  *    (soft) this.myParser != null
        		  *    (soft) this.myParser.h005Info != null
        		  *    (soft) this.myParser.hChanModesBool != null
        		  *    (soft) this.myParser.hChanModesOther != null
        		  *    (soft) this.myParser.hChanPrefix != null
        		  *    (soft) this.myParser.hPrefixMap != null
        		  *    (soft) this.myParser.hPrefixModes != null
        		  *    ...
        		  * 
        		  *  Postconditions:
        		  *    possibly_updated(this.myParser.nNextKeyCMBool)
        		  *    possibly_updated(this.myParser.nNextKeyPrefix)
        		  *    possibly_updated(this.myParser.nNextKeyUser)
        		  * 
        		  *  Test Vectors:
        		  *    java.lang.String:equals(...)@38: {0}, {1}
        		  *    java.lang.String:equals(...)@40: {0}, {1}
        		  *    java.util.Map:containsKey(...)@43: {1}, {0}
        		  *    java.util.Map:containsKey(...)@44: {1}, {0}
        		  *    java.util.Map:containsKey(...)@45: {1}, {0}
        		  *    java.util.Map:containsKey(...)@46: {1}, {0}
        		  */
    38  		if (sParam.equals("375")) {
    39  			callMOTDStart(token[token.length-1]);
    40  		} else if (sParam.equals("372")) {
    41  			callMOTDLine(token[token.length-1]);
    42  		} else {
    43  			if (!myParser.h005Info.containsKey("CHANTYPES")) { myParser.parseChanPrefix(); }
    44  			if (!myParser.h005Info.containsKey("PREFIX")) { myParser.parsePrefixModes(); }
    45  			if (!myParser.h005Info.containsKey("USERMODES")) { myParser.parseUserModes(); }
    46  			if (!myParser.h005Info.containsKey("CHANMODES")) { myParser.parseChanModes(); }
    47  			callMOTDEnd(sParam.equals("422"), token[token.length-1]);
    48  		}
    49  	}
    50  	
    51  	/**
    52  	 * Callback to all objects implementing the MOTDEnd Callback.
    53  	 *
    54  	 * @param noMOTD Was this an MOTDEnd or NoMOTD
    55  	 * @param data The contents of the line (incase of language changes or so)
    56  	 * @see IMOTDEnd
    57  	 * @return true if a method was called, false otherwise
    58  	 */
    59  	protected boolean callMOTDEnd(final boolean noMOTD, final String data) {
        		 /* 
    P/P 		  *  Method: bool callMOTDEnd(bool, String)
        		  * 
        		  *  Preconditions:
        		  *    this.myParser != null
        		  *    this.myParser.myCallbackManager != null
        		  *    this.myParser.myCallbackManager.callbackHash != null
        		  * 
        		  *  Presumptions:
        		  *    getCallbackManager(...)@60 init'ed
        		  * 
        		  *  Postconditions:
        		  *    init'ed(return_value)
        		  */
    60  		return getCallbackManager().getCallbackType("OnMOTDEnd").call(noMOTD, data);
    61  	}
    62  	
    63  	/**
    64  	 * Callback to all objects implementing the MOTDLine Callback.
    65  	 *
    66  	 * @see IMOTDLine
    67  	 * @param data Incomming Line.
    68  	 * @return true if a method was called, false otherwise
    69  	 */
    70  	protected boolean callMOTDLine(final String data) {
        		 /* 
    P/P 		  *  Method: bool callMOTDLine(String)
        		  * 
        		  *  Preconditions:
        		  *    this.myParser != null
        		  *    this.myParser.myCallbackManager != null
        		  *    this.myParser.myCallbackManager.callbackHash != null
        		  * 
        		  *  Presumptions:
        		  *    getCallbackManager(...)@71 init'ed
        		  * 
        		  *  Postconditions:
        		  *    init'ed(return_value)
        		  */
    71  		return getCallbackManager().getCallbackType("OnMOTDLine").call(data);
    72  	}
    73  	
    74  	/**
    75  	 * Callback to all objects implementing the MOTDStart Callback.
    76  	 *
    77  	 * @see IMOTDStart
    78  	 * @param data Incomming Line.
    79  	 * @return true if a method was called, false otherwise
    80  	 */
    81  	protected boolean callMOTDStart(String data) {
        		 /* 
    P/P 		  *  Method: bool callMOTDStart(String)
        		  * 
        		  *  Preconditions:
        		  *    this.myParser != null
        		  *    this.myParser.myCallbackManager != null
        		  *    this.myParser.myCallbackManager.callbackHash != null
        		  * 
        		  *  Presumptions:
        		  *    getCallbackManager(...)@82 init'ed
        		  * 
        		  *  Postconditions:
        		  *    init'ed(return_value)
        		  */
    82  		return getCallbackManager().getCallbackType("OnMOTDStart").call(data);
    83  	}
    84  	
    85  	/**
    86  	 * What does this IRCProcessor handle.
    87  	 *
    88  	 * @return String[] with the names of the tokens we handle.
    89  	 */
    90  	@Override
    91  	public String[] handles() {
        		 /* 
    P/P 		  *  Method: String[] handles()
        		  * 
        		  *  Postconditions:
        		  *    return_value == &new String[](handles#1)
        		  *    new String[](handles#1) num objects == 1
        		  *    return_value.length == 4
        		  *    return_value[0] == &"372"
        		  *    return_value[1] == &"375"
        		  *    return_value[2] == &"376"
        		  *    return_value[3] == &"422"
        		  */
    92  		return new String[]{"372", "375", "376", "422"};
    93  	} 
    94  	
    95  	/**
    96  	 * Create a new instance of the IRCProcessor Object.
    97  	 *
    98  	 * @param parser IRCParser That owns this IRCProcessor
    99  	 * @param manager ProcessingManager that is in charge of this IRCProcessor
   100  	 */
        	 /* 
    P/P 	  *  Method: void com.dmdirc.parser.irc.ProcessMOTD(IRCParser, ProcessingManager)
        	  * 
        	  *  Postconditions:
        	  *    this.myManager == manager
        	  *    init'ed(this.myManager)
        	  *    this.myParser == parser
        	  *    init'ed(this.myParser)
        	  */
   101  	protected ProcessMOTD (IRCParser parser, ProcessingManager manager) { super(parser, manager); }
   102  
   103  }








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