jerklib
Class Channel

java.lang.Object
  extended by jerklib.Channel

public class Channel
extends Object

A Class to represent a joined IRC channel. This class has methods to interact with IRC Channels like say() , part() , getChannelModes() etc. You will never need to create an instance of this class manually. Instead it will be created for you and stored in the Session when you successfully join a channel.

Author:
mohadib
See Also:
Session, Session.getChannel(String), Session.getChannels(), JoinCompleteEvent

Constructor Summary
Channel(String name, Session session)
          This should only be used internally and for testing
 
Method Summary
 void action(String text)
          Send an action
 void addNick(String nick)
          This method is for internal use only
 void deop(String userName)
          DeOp a user
 void deVoice(String userName)
          Devoice a user
 boolean equals(Object o)
           
 List<ModeAdjustment> getChannelModes()
          Returns a list of modes that apply to the channel but dont apply to users in the channel.
 String getName()
          Gets the Channel name.
 List<String> getNicks()
          Gets a list of nicks for Channel.
 List<String> getNicksForMode(ModeAdjustment.Action action, char mode)
          Gets a list of user in channel with a given mode set.
 Session getSession()
          Return the Session this Channel belongs to
 String getTopic()
          Gets the topic for the channel or an empty string is the topic is not set.
 String getTopicSetter()
          Gets the nick of who set the topic or an empty string if the topic is not set.
 Date getTopicSetTime()
          Returns the Date the topic was set or null if the topic is unset.
 List<ModeAdjustment> getUsersModes(String nick)
          Get a list of user's channel modes Returns an empty list if the nick does not exist.
 int hashCode()
           
 void kick(String userName, String reason)
          Kick a user
 void mode(String mode)
          Sets a mode in the Channel is you have the permissions to do so.
 void names()
          Send a names query to the server
 void notice(String message)
          Send a notice in the Channel
 void op(String userName)
          Op a user
 void part(String partMsg)
          Part the channel
 void say(String message)
          Speak in the Channel.
 void setTopic(String topic)
          Sets the topic of the Channel is you have the permissions to do so.
 void setTopicEvent(TopicEvent topicEvent)
          This method should only be used internally
 String toString()
           
 void voice(String userName)
          Voice a user
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Channel

public Channel(String name,
               Session session)
This should only be used internally and for testing

Parameters:
name - - Name of Channel
session - - Session Channel belongs to
Method Detail

getUsersModes

public List<ModeAdjustment> getUsersModes(String nick)
Get a list of user's channel modes Returns an empty list if the nick does not exist.

Parameters:
nick -
Returns:
list of ModeAdjustments for user

getNicksForMode

public List<String> getNicksForMode(ModeAdjustment.Action action,
                                    char mode)
Gets a list of user in channel with a given mode set. A user will only match if they have the exact mode set. Non existance of +(mode) does not imply that the user is -(mode) So searching for -v would almost always return an empty list.

Parameters:
action -
mode -
Returns:
List of nicks with mode/action set

getChannelModes

public List<ModeAdjustment> getChannelModes()
Returns a list of modes that apply to the channel but dont apply to users in the channel. I.E. +o is not returned as that applies to users in the channel not just the channel.

Returns:
List of ModeAdjustments for the Channel

mode

public void mode(String mode)
Sets a mode in the Channel is you have the permissions to do so. example: +vv00 foo bar baz bob example: -v+i foo

Parameters:
mode - to set.

getTopic

public String getTopic()
Gets the topic for the channel or an empty string is the topic is not set.

Returns:
topic for channel

getTopicSetter

public String getTopicSetter()
Gets the nick of who set the topic or an empty string if the topic is not set.

Returns:
nick of topic setter

getTopicSetTime

public Date getTopicSetTime()
Returns the Date the topic was set or null if the topic is unset.

Returns:
date topic was set or null if not set

setTopic

public void setTopic(String topic)
Sets the topic of the Channel is you have the permissions to do so.

Parameters:
topic - to use.

setTopicEvent

public void setTopicEvent(TopicEvent topicEvent)
This method should only be used internally

Parameters:
topicEvent -

getName

public String getName()
Gets the Channel name.

Returns:
name of Channel

say

public void say(String message)
Speak in the Channel.

Parameters:
message - - what to say

notice

public void notice(String message)
Send a notice in the Channel

Parameters:
message - - notice messgae

addNick

public void addNick(String nick)
This method is for internal use only

Parameters:
nick - to add

getNicks

public List<String> getNicks()
Gets a list of nicks for Channel. The list returned has a case insenstive indexOf() and contains()

Returns:
List of nicks

part

public void part(String partMsg)
Part the channel

Parameters:
partMsg -

action

public void action(String text)
Send an action

Parameters:
text - action text

names

public void names()
Send a names query to the server


deVoice

public void deVoice(String userName)
Devoice a user

Parameters:
userName -

voice

public void voice(String userName)
Voice a user

Parameters:
userName -

op

public void op(String userName)
Op a user

Parameters:
userName -

deop

public void deop(String userName)
DeOp a user

Parameters:
userName -

kick

public void kick(String userName,
                 String reason)
Kick a user

Parameters:
userName -
reason -

getSession

public Session getSession()
Return the Session this Channel belongs to


equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object