File Source: ProcessWallops.java
/*
P/P * Method: com.dmdirc.parser.irc.ProcessWallops__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 WALLOPS Message.
27 */
28 public class ProcessWallops extends IRCProcessor {
29 /**
30 * Process a Wallops Message.
31 *
32 * @param sParam Type of line to process ("WALLOPS")
33 * @param token IRCTokenised line to process
34 */
35 @Override
36 public void process(final String sParam, final String[] token) {
/*
P/P * Method: void process(String, String[])
*
* Preconditions:
* token != null
* token.length <= 232
* (soft) this.myParser != null
* (soft) this.myParser.myCallbackManager != null
* (soft) this.myParser.myCallbackManager.callbackHash != null
* (soft) token[0] != null
* (soft) token[...] != null
*
* Test Vectors:
* token.length: {3..232}, {0..2}
* java.lang.String:charAt(...)@41: {0..57, 59..216-1}, {58}
* java.lang.String:length(...)@41: {0,1}, {2..232-1}
*/
37 if (token.length < 3) { return; }
38
39 String user = token[0];
40 String message = token[token.length-1];
41 if (user.charAt(0) == ':' && user.length() > 1) { user = user.substring(1); }
42 String[] bits = message.split(" ", 2);
43
44 if (bits.length > 1) {
45 if (message.charAt(0) == '*') {
46 callWallop(bits[1], user);
47 return;
48 } else if (message.charAt(0) == '$') {
49 callWalluser(bits[1], user);
50 return;
51 }
52 }
53 callWallDesync(message, user);
54 }
55
56 /**
57 * Callback to all objects implementing the Wallop Callback.
58 *
59 * @see IWallop
60 * @param host Host of the user who sent the wallop
61 * @param message The message
62 * @return true if a method was called, false otherwise
63 */
64 protected boolean callWallop(final String message, final String host) {
/*
P/P * Method: bool callWallop(String, String)
*
* Preconditions:
* this.myParser != null
* this.myParser.myCallbackManager != null
* this.myParser.myCallbackManager.callbackHash != null
*
* Presumptions:
* getCallbackManager(...)@65 init'ed
*
* Postconditions:
* init'ed(return_value)
*/
65 return getCallbackManager().getCallbackType("OnWallop").call(message, host);
66 }
67
68 /**
69 * Callback to all objects implementing the Walluser Callback.
70 *
71 * @see IWalluser
72 * @param host Host of the user who sent the walluser
73 * @param message The message
74 * @return true if a method was called, false otherwise
75 */
76 protected boolean callWalluser(final String message, final String host) {
/*
P/P * Method: bool callWalluser(String, String)
*
* Preconditions:
* this.myParser != null
* this.myParser.myCallbackManager != null
* this.myParser.myCallbackManager.callbackHash != null
*
* Presumptions:
* getCallbackManager(...)@77 init'ed
*
* Postconditions:
* init'ed(return_value)
*/
77 return getCallbackManager().getCallbackType("OnWalluser").call(message, host);
78 }
79
80 /**
81 * Callback to all objects implementing the WallDesync Callback.
82 *
83 * @see IWallDesync
84 * @param host Host of the user who sent the WallDesync
85 * @param message The message
86 * @return true if a method was called, false otherwise
87 */
88 protected boolean callWallDesync(final String message, final String host) {
/*
P/P * Method: bool callWallDesync(String, String)
*
* Preconditions:
* this.myParser != null
* this.myParser.myCallbackManager != null
* this.myParser.myCallbackManager.callbackHash != null
*
* Presumptions:
* getCallbackManager(...)@89 init'ed
*
* Postconditions:
* init'ed(return_value)
*/
89 return getCallbackManager().getCallbackType("OnWallDesync").call(message, host);
90 }
91
92
93 /**
94 * What does this IRCProcessor handle.
95 *
96 * @return String[] with the names of the tokens we handle.
97 */
98 @Override
99 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 == 1
* return_value[0] == &"WALLOPS"
*/
100 return new String[]{"WALLOPS"};
101 }
102
103 /**
104 * Create a new instance of the IRCProcessor Object.
105 *
106 * @param parser IRCParser That owns this IRCProcessor
107 * @param manager ProcessingManager that is in charge of this IRCProcessor
108 */
/*
P/P * Method: void com.dmdirc.parser.irc.ProcessWallops(IRCParser, ProcessingManager)
*
* Postconditions:
* this.myManager == manager
* init'ed(this.myManager)
* this.myParser == parser
* init'ed(this.myParser)
*/
109 protected ProcessWallops (IRCParser parser, ProcessingManager manager) { super(parser, manager); }
110
111 }
SofCheck Inspector Build Version : 2.17854
| ProcessWallops.java |
2009-Jun-25 01:54:24 |
| ProcessWallops.class |
2009-Sep-02 17:04:16 |