com.zerjio.JIRC
Class IRCMessage

java.lang.Object
  extended bycom.zerjio.JIRC.IRCMessage
Direct Known Subclasses:
AutoQUITMessage, ErrorMessage, JOINMessage, MODEMessage, NICKMessage, PARTMessage, PINGMessage, PRIVMSGMessage, QUITMessage, ReplyMessage, TOPICMessage

public class IRCMessage
extends java.lang.Object

This class represents a basic message that is send over an IRC Connection.

It is recommended to take a look to the RFC 1459 to know what kinds of messages do exist and their exact formats. All IRC Messages should be a subclass of this generic one.


Constructor Summary
IRCMessage(java.lang.String prefix, java.lang.String command, java.lang.String params)
          Constructs a general IRC message with a prefix, a command and its parameters.
 
Method Summary
 java.lang.String asString()
          Gives a String representation of the IRC message.
 java.lang.String asStringWithoutPrefix()
          Gives a String representation of the IRC message but ignoring its prefix.
 java.lang.String getCommand()
          Gets the IRC message command.
 java.lang.String getHost()
          Gets the host (part of prefix).
 boolean getMustBeDiscarded()
          Gets if the IRC message must be discarded.
 java.lang.String getNick()
          Gets the nick (part of prefix).
 java.lang.String getParams()
          Gets the IRC message parameters.
 java.lang.String getPrefix()
          Gets the IRC message prefix.
 int getUsedCount()
          Gets how many times have this IRC message been used.
 java.lang.String getUser()
          Gets the user (part of prefix).
 boolean isUsed()
          Returns if the IRC message has been previously used.
 void markAsUsed()
          Marks the IRC message as used.
 void mustBeDiscarded()
          Marks the IRC message to be discarded.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IRCMessage

public IRCMessage(java.lang.String prefix,
                  java.lang.String command,
                  java.lang.String params)
Constructs a general IRC message with a prefix, a command and its parameters.

Parameters:
prefix - The IRC message prefix.
command - The IRC message command.
params - The IRC message parameters.
Method Detail

getPrefix

public java.lang.String getPrefix()
Gets the IRC message prefix.

Returns:
The IRC message prefix.

getNick

public java.lang.String getNick()
Gets the nick (part of prefix).

Returns:
The nick.

getUser

public java.lang.String getUser()
Gets the user (part of prefix).

Returns:
The user.

getHost

public java.lang.String getHost()
Gets the host (part of prefix).

Returns:
The host.

getCommand

public java.lang.String getCommand()
Gets the IRC message command.

Returns:
The IRC message command.

getParams

public java.lang.String getParams()
Gets the IRC message parameters.

Returns:
The IRC message parameters.

getUsedCount

public int getUsedCount()
Gets how many times have this IRC message been used.

Returns:
The number of times that the IRC message has been used.

isUsed

public boolean isUsed()
Returns if the IRC message has been previously used.

Returns:
true if the IRC message has been previously used. false if the IRC message has NOT been previously used.

markAsUsed

public void markAsUsed()
Marks the IRC message as used. To do so it increments the usedCount counter.


mustBeDiscarded

public void mustBeDiscarded()
Marks the IRC message to be discarded. That should avoid that another message listeners to access it.


getMustBeDiscarded

public boolean getMustBeDiscarded()
Gets if the IRC message must be discarded.

Returns:
true if the IRC message must be discarded. false if NOT must be discarded.

asString

public java.lang.String asString()
Gives a String representation of the IRC message. Usually the format correspond to the exact format in what has been sent.

Returns:
A String that represents this IRC message.

asStringWithoutPrefix

public java.lang.String asStringWithoutPrefix()
Gives a String representation of the IRC message but ignoring its prefix.

Returns:
A String that represents this IRC message without prefix.