File Source: ProcessAway.java
/*
P/P * Method: com.dmdirc.parser.irc.ProcessAway__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 an Away/Back message.
27 */
28 public class ProcessAway extends IRCProcessor {
29 /**
30 * Process an Away/Back message.
31 *
32 * @param sParam Type of line to process ("305", "306")
33 * @param token IRCTokenised line to process
34 */
35 @Override
36 public void process(String sParam, String[] token) {
/*
P/P * Method: void process(String, String[])
*
* Preconditions:
* sParam != null
* this.myParser != null
* (soft) init'ed(this.myParser.cMyself.myAwayReason)
* (soft) init'ed(this.myParser.stringConverter)
* (soft) this.myParser.cMyself != null
* (soft) this.myParser.hClientList != null
* (soft) this.myParser.myCallbackManager != null
* (soft) this.myParser.myCallbackManager.callbackHash != null
* (soft) this.myParser.stringConverter.lowercase != null
* (soft) init'ed(this.myParser.stringConverter.lowercase[...])
* ...
*
* Postconditions:
* possibly_updated(this.myParser.cMyself.bIsAway)
* this.myParser.cMyself.myAwayReason == One-of{old this.myParser.cMyself.myAwayReason, token[3], token[...], &""}
* init'ed(this.myParser.cMyself.myAwayReason)
* this.myParser.stringConverter == One-of{old this.myParser.stringConverter, &new IRCStringConverter(getIRCStringConverter#1)}
* init'ed(this.myParser.stringConverter)
* new IRCStringConverter(getIRCStringConverter#1) num objects <= 1
* init'ed(new IRCStringConverter(getIRCStringConverter#1).limit)
* init'ed(new IRCStringConverter(getIRCStringConverter#1).lowercase)
* init'ed(new IRCStringConverter(getIRCStringConverter#1).uppercase)
* new char[](IRCStringConverter#1) num objects <= 1
* ...
*
* Test Vectors:
* java.lang.String:equals(...)@37: {0}, {1}
*/
37 if (sParam.equals("301")) {
38 ClientInfo iClient = myParser.getClientInfo(token[3]);
39 if (iClient != null) { iClient.setAwayReason(token[token.length-1]); }
40 } else {
41 myParser.getMyself().setAwayState(sParam.equals("306"));
42 callAwayState(myParser.getMyself().getAwayState(), myParser.getMyself().getAwayReason());
43 }
44 }
45
46 /**
47 * Callback to all objects implementing the onAwayState Callback.
48 *
49 * @see IAwayState
50 * @param currentState Set to true if we are now away, else false.
51 * @param reason Best guess at away reason
52 * @return true if a method was called, false otherwise
53 */
54 protected boolean callAwayState(boolean currentState, String reason) {
/*
P/P * Method: bool callAwayState(bool, String)
*
* Preconditions:
* this.myParser != null
* this.myParser.myCallbackManager != null
* this.myParser.myCallbackManager.callbackHash != null
*
* Postconditions:
* init'ed(return_value)
*/
55 return myParser.getCallbackManager().getCallbackType("OnAwayState").call(currentState, reason);
56 }
57
58 /**
59 * What does this IRCProcessor handle.
60 *
61 * @return String[] with the names of the tokens we handle.
62 */
63 @Override
64 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 == 3
* return_value[0] == &"301"
* return_value[1] == &"305"
* return_value[2] == &"306"
*/
65 return new String[]{"301", "305", "306"};
66 }
67
68 /**
69 * Create a new instance of the IRCProcessor Object.
70 *
71 * @param parser IRCParser That owns this IRCProcessor
72 * @param manager ProcessingManager that is in charge of this IRCProcessor
73 */
/*
P/P * Method: void com.dmdirc.parser.irc.ProcessAway(IRCParser, ProcessingManager)
*
* Postconditions:
* this.myManager == manager
* init'ed(this.myManager)
* this.myParser == parser
* init'ed(this.myParser)
*/
74 protected ProcessAway (IRCParser parser, ProcessingManager manager) { super(parser, manager); }
75
76 }
SofCheck Inspector Build Version : 2.17854
| ProcessAway.java |
2009-Jun-25 01:54:24 |
| ProcessAway.class |
2009-Sep-02 17:04:16 |