//# 0 errors, 87 messages
//#
/*
    //#Invite.java:1:1: class: com.dmdirc.Invite
    //#Invite.java:1:1: method: com.dmdirc.Invite.com.dmdirc.Invite__static_init
 * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

package com.dmdirc;

import com.dmdirc.parser.irc.ClientInfo;

import java.util.Date;

/**
 * Model for a channel invitation.
 *
 * @author Chris
 */
public class Invite {
    
    /** The server this invite was on. */
    private final Server server;
    
    /** The channel this invite is for. */
    private final String channel;
    
    /** The time this invite was created. */
    private final long timestamp;
    
    /** The source of this invite. */
    private final String source;
    
    /**
     * Creates a new instance of Invite.
     * 
     * @param server The server that this invite was received for
     * @param channel The channel that this invite is for
     * @param source The source of this invite
     */
    public Invite(final Server server, final String channel, final String source) {
    //#Invite.java:55: method: void com.dmdirc.Invite.com.dmdirc.Invite(Server, String, String)
    //#input(void com.dmdirc.Invite(Server, String, String)): channel
    //#input(void com.dmdirc.Invite(Server, String, String)): server
    //#input(void com.dmdirc.Invite(Server, String, String)): source
    //#input(void com.dmdirc.Invite(Server, String, String)): this
    //#output(void com.dmdirc.Invite(Server, String, String)): this.channel
    //#output(void com.dmdirc.Invite(Server, String, String)): this.server
    //#output(void com.dmdirc.Invite(Server, String, String)): this.source
    //#output(void com.dmdirc.Invite(Server, String, String)): this.timestamp
    //#post(void com.dmdirc.Invite(Server, String, String)): this.channel == channel
    //#post(void com.dmdirc.Invite(Server, String, String)): init'ed(this.channel)
    //#post(void com.dmdirc.Invite(Server, String, String)): this.server == server
    //#post(void com.dmdirc.Invite(Server, String, String)): init'ed(this.server)
    //#post(void com.dmdirc.Invite(Server, String, String)): this.source == source
    //#post(void com.dmdirc.Invite(Server, String, String)): init'ed(this.source)
    //#post(void com.dmdirc.Invite(Server, String, String)): init'ed(this.timestamp)
        this.server = server;
        this.channel = channel;
        this.source = source;
        this.timestamp = new Date().getTime();
    }
    //#Invite.java:60: end of method: void com.dmdirc.Invite.com.dmdirc.Invite(Server, String, String)

    /**
     * Retrieves the server that this invite is associated with.
     * 
     * @return This invite's server
     */
    public Server getServer() {
        return server;
    //#Invite.java:68: method: Server com.dmdirc.Invite.getServer()
    //#input(Server getServer()): this
    //#input(Server getServer()): this.server
    //#output(Server getServer()): return_value
    //#post(Server getServer()): return_value == this.server
    //#post(Server getServer()): init'ed(return_value)
    //#Invite.java:68: end of method: Server com.dmdirc.Invite.getServer()
    }

    /**
     * Retrieves the name of the channel that this invite is for.
     * 
     * @return This invite's channel
     */
    public String getChannel() {
        return channel;
    //#Invite.java:77: method: String com.dmdirc.Invite.getChannel()
    //#input(String getChannel()): this
    //#input(String getChannel()): this.channel
    //#output(String getChannel()): return_value
    //#post(String getChannel()): return_value == this.channel
    //#post(String getChannel()): init'ed(return_value)
    //#Invite.java:77: end of method: String com.dmdirc.Invite.getChannel()
    }

    /**
     * Retrieves the timestamp that this invite was received at.
     * 
     * @return This invite's timestamp
     */
    public long getTimestamp() {
        return timestamp;
    //#Invite.java:86: method: long com.dmdirc.Invite.getTimestamp()
    //#input(long getTimestamp()): this
    //#input(long getTimestamp()): this.timestamp
    //#output(long getTimestamp()): return_value
    //#post(long getTimestamp()): return_value == this.timestamp
    //#post(long getTimestamp()): init'ed(return_value)
    //#Invite.java:86: end of method: long com.dmdirc.Invite.getTimestamp()
    }

    /**
     * Retrieves the nickname, ident and hostname of this invite's source.
     * 
     * @return This invite's source
     */
    public String[] getSource() {
        return ClientInfo.parseHostFull(source);
    //#Invite.java:95: method: String[] com.dmdirc.Invite.getSource()
    //#Invite.java:95: Warning: method not available - call not analyzed
    //#    call on String[] com.dmdirc.parser.irc.ClientInfo:parseHostFull(String)
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.Invite
    //#    method: String[] getSource()
    //#    unanalyzed callee: String[] com.dmdirc.parser.irc.ClientInfo:parseHostFull(String)
    //#input(String[] getSource()): this
    //#input(String[] getSource()): this.source
    //#output(String[] getSource()): return_value
    //#post(String[] getSource()): init'ed(return_value)
    //#Invite.java:95: end of method: String[] com.dmdirc.Invite.getSource()
    }
    
    /**
     * Join the channel that belongs to this invite.
     */
    public void accept() {
        server.getParser().joinChannel(channel);
    //#Invite.java:102: method: void com.dmdirc.Invite.accept()
    //#Invite.java:102: Warning: method not available - call not analyzed
    //#    call on void com.dmdirc.parser.irc.IRCParser:joinChannel(String)
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.Invite
    //#    method: void accept()
    //#    unanalyzed callee: void com.dmdirc.parser.irc.IRCParser:joinChannel(String)
    //#input(void accept()): com/dmdirc/Server.__Descendant_Table[com/dmdirc/Server]
    //#input(void accept()): com/dmdirc/Server.__Descendant_Table[others]
    //#input(void accept()): com/dmdirc/Server.__Dispatch_Table.getParser()Lcom/dmdirc/parser/irc/IRCParser;
    //#input(void accept()): com/dmdirc/Server.__Dispatch_Table.removeInvite(Lcom/dmdirc/Invite;)V
    //#input(void accept()): this
    //#input(void accept()): this.channel
    //#input(void accept()): this.server
    //#input(void accept()): this.server.__Tag
    //#input(void accept()): this.server.invites
    //#input(void accept()): this.server.listeners
    //#input(void accept()): this.server.parser
    //#pre[3] (void accept()): this.server != null
    //#pre[4] (void accept()): this.server.__Tag == com/dmdirc/Server
    //#pre[5] (void accept()): this.server.invites != null
    //#pre[7] (void accept()): this.server.listeners != null
    //#pre[9] (void accept()): this.server.parser != null
    //#unanalyzed(void accept()): Effects-of-calling:com.dmdirc.util.ListenerList:get
    //#unanalyzed(void accept()): Effects-of-calling:java.util.List:iterator
    //#unanalyzed(void accept()): Effects-of-calling:java.util.Iterator:hasNext
    //#unanalyzed(void accept()): Effects-of-calling:java.util.Iterator:next
    //#unanalyzed(void accept()): Effects-of-calling:java.lang.Throwable:__curr_excep_obj
    //#unanalyzed(void accept()): Effects-of-calling:java.util.List:remove
    //#unanalyzed(void accept()): Effects-of-calling:com.dmdirc.interfaces.InviteListener:inviteExpired
        
        server.removeInvite(this);
    }
    //#Invite.java:105: end of method: void com.dmdirc.Invite.accept()
    
}
    //#output(com.dmdirc.Invite__static_init): __Descendant_Table[com/dmdirc/Invite]
    //#output(com.dmdirc.Invite__static_init): __Dispatch_Table.accept()V
    //#output(com.dmdirc.Invite__static_init): __Dispatch_Table.getChannel()Ljava/lang/String;
    //#output(com.dmdirc.Invite__static_init): __Dispatch_Table.getServer()Lcom/dmdirc/Server;
    //#output(com.dmdirc.Invite__static_init): __Dispatch_Table.getSource()[Ljava/lang/String;
    //#output(com.dmdirc.Invite__static_init): __Dispatch_Table.getTimestamp()J
    //#post(com.dmdirc.Invite__static_init): __Descendant_Table[com/dmdirc/Invite] == &__Dispatch_Table
    //#post(com.dmdirc.Invite__static_init): __Dispatch_Table.accept()V == &accept
    //#post(com.dmdirc.Invite__static_init): __Dispatch_Table.getChannel()Ljava/lang/String; == &getChannel
    //#post(com.dmdirc.Invite__static_init): __Dispatch_Table.getServer()Lcom/dmdirc/Server; == &getServer
    //#post(com.dmdirc.Invite__static_init): __Dispatch_Table.getSource()[Ljava/lang/String; == &getSource
    //#post(com.dmdirc.Invite__static_init): __Dispatch_Table.getTimestamp()J == &getTimestamp
    //#Invite.java:: end of method: com.dmdirc.Invite.com.dmdirc.Invite__static_init
    //#Invite.java:: end of class: com.dmdirc.Invite
