File Source: Invite.java
/*
P/P * Method: com.dmdirc.Invite__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;
24
25 import com.dmdirc.parser.irc.ClientInfo;
26
27 import java.util.Date;
28
29 /**
30 * Model for a channel invitation.
31 *
32 * @author Chris
33 */
34 public class Invite {
35
36 /** The server this invite was on. */
37 private final Server server;
38
39 /** The channel this invite is for. */
40 private final String channel;
41
42 /** The time this invite was created. */
43 private final long timestamp;
44
45 /** The source of this invite. */
46 private final String source;
47
48 /**
49 * Creates a new instance of Invite.
50 *
51 * @param server The server that this invite was received for
52 * @param channel The channel that this invite is for
53 * @param source The source of this invite
54 */
/*
P/P * Method: void com.dmdirc.Invite(Server, String, String)
*
* Postconditions:
* this.channel == channel
* init'ed(this.channel)
* this.server == server
* init'ed(this.server)
* this.source == source
* init'ed(this.source)
* init'ed(this.timestamp)
*/
55 public Invite(final Server server, final String channel, final String source) {
56 this.server = server;
57 this.channel = channel;
58 this.source = source;
59 this.timestamp = new Date().getTime();
60 }
61
62 /**
63 * Retrieves the server that this invite is associated with.
64 *
65 * @return This invite's server
66 */
67 public Server getServer() {
/*
P/P * Method: Server getServer()
*
* Postconditions:
* return_value == this.server
* init'ed(return_value)
*/
68 return server;
69 }
70
71 /**
72 * Retrieves the name of the channel that this invite is for.
73 *
74 * @return This invite's channel
75 */
76 public String getChannel() {
/*
P/P * Method: String getChannel()
*
* Postconditions:
* return_value == this.channel
* init'ed(return_value)
*/
77 return channel;
78 }
79
80 /**
81 * Retrieves the timestamp that this invite was received at.
82 *
83 * @return This invite's timestamp
84 */
85 public long getTimestamp() {
/*
P/P * Method: long getTimestamp()
*
* Postconditions:
* return_value == this.timestamp
* init'ed(return_value)
*/
86 return timestamp;
87 }
88
89 /**
90 * Retrieves the nickname, ident and hostname of this invite's source.
91 *
92 * @return This invite's source
93 */
94 public String[] getSource() {
/*
P/P * Method: String[] getSource()
*
* Postconditions:
* init'ed(return_value)
*/
95 return ClientInfo.parseHostFull(source);
96 }
97
98 /**
99 * Join the channel that belongs to this invite.
100 */
101 public void accept() {
/*
P/P * Method: void accept()
*
* Preconditions:
* this.server != null
* this.server.invites != null
* this.server.listeners != null
* this.server.parser != null
*/
102 server.getParser().joinChannel(channel);
103
104 server.removeInvite(this);
105 }
106
107 }
SofCheck Inspector Build Version : 2.17854
| Invite.java |
2009-Jun-25 01:54:24 |
| Invite.class |
2009-Sep-02 17:04:12 |