com.leafdigital.irc.api
Class IRCMsg

java.lang.Object
  extended by leafchat.core.api.Msg
      extended by com.leafdigital.irc.api.IRCMsg
Direct Known Subclasses:
ErrorIRCMsg, PingIRCMsg, ServerIRCMsg, UnknownIRCMsg, UserSourceIRCMsg

public class IRCMsg
extends Msg

Represents a parsed message received from an IRC server, parsed


Field Summary
static MessageInfo info
          Message info for scripting.
 
Fields inherited from class leafchat.core.api.Msg
PRIORITY_AFTERNORMAL, PRIORITY_BEFORENORMAL, PRIORITY_EARLY, PRIORITY_FIRST, PRIORITY_LAST, PRIORITY_LATE, PRIORITY_NORMAL
 
Constructor Summary
IRCMsg()
           
 
Method Summary
static byte[] constructBytes(java.lang.String iso)
           
static byte[] constructBytes(java.lang.String isoPart, byte[] secondPart)
          Creates bytes suitable for an IRC message where the first part is in ISO 8859-1 and the second part has been converted to bytes
 java.lang.String convertEncoding(byte[] data)
           
static java.lang.String convertISO(byte[] data)
          Converts text using ISO 8859-1 which is generally appropriate for 'system' parts of a message
 java.lang.String getCommand()
           
 byte[] getCommandBytes()
           
 byte[] getLine()
           
 java.lang.String getLineISO()
           
 java.lang.String getParamISO(int index)
           
 byte[][] getParams()
           
 java.lang.String getPrefix()
           
 byte[] getPrefixBytes()
           
 Server getServer()
           
 boolean hasEncoding()
           
 boolean includesPostfix()
           
 void init(IRCMsg base)
           
 void init(Server s, byte[] line, byte[] prefix, byte[] command, byte[][] params, boolean includesPostfix)
          Init with actual parameters
 boolean isParamInteger(int index)
           
 void setEncoding(IRCEncoding.EncodingInfo encoding)
          Sets up encoding for message (used by system only).
static byte[][] splitBytes(byte[] data)
          Given an array of bytes, splits it on spaces.
 java.lang.String toString()
           
 
Methods inherited from class leafchat.core.api.Msg
isHandled, isStopped, markHandled, markStopped, sequenceBefore, setSequence, setSequence
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

info

public static MessageInfo info
Message info for scripting.

Constructor Detail

IRCMsg

public IRCMsg()
Method Detail

convertISO

public static java.lang.String convertISO(byte[] data)
Converts text using ISO 8859-1 which is generally appropriate for 'system' parts of a message

Parameters:
data - Bytes
Returns:
String

convertEncoding

public java.lang.String convertEncoding(byte[] data)
Parameters:
data - Bytes from this message
Returns:
Message converted into a string as per user's encoding preferences

splitBytes

public static byte[][] splitBytes(byte[] data)
Given an array of bytes, splits it on spaces.

Parameters:
data - Data to split
Returns:
Array of byte arrays with split data

constructBytes

public static byte[] constructBytes(java.lang.String isoPart,
                                    byte[] secondPart)
Creates bytes suitable for an IRC message where the first part is in ISO 8859-1 and the second part has been converted to bytes

Parameters:
isoPart - ISO part of text (may be null)
secondPart - Other character set part (may be null)
Returns:
Bytes containing both parts

constructBytes

public static byte[] constructBytes(java.lang.String iso)
Parameters:
iso - String that should be converted to bytes
Returns:
Bytes of string in ISO-8859-1 charset

setEncoding

public void setEncoding(IRCEncoding.EncodingInfo encoding)
Sets up encoding for message (used by system only).

Parameters:
encoding - Encoding

hasEncoding

public boolean hasEncoding()
Returns:
True if encoding has been set up (used by system)

init

public void init(IRCMsg base)
Parameters:
base - Message to copy parameters from

init

public void init(Server s,
                 byte[] line,
                 byte[] prefix,
                 byte[] command,
                 byte[][] params,
                 boolean includesPostfix)
Init with actual parameters

Parameters:
s - Server
line - Original line
prefix - Prefix (or null)
command - Command
params - Parameters
includesPostfix - Whether or not the last param was a postfix type

getServer

public Server getServer()
Returns:
Server that sent the message

getLine

public byte[] getLine()
Returns:
Entire line

getLineISO

public java.lang.String getLineISO()
Returns:
Entire line as string

getPrefixBytes

public byte[] getPrefixBytes()
Returns:
Prefix (may be null)

getPrefix

public java.lang.String getPrefix()
Returns:
Prefix (may be null)

getCommandBytes

public byte[] getCommandBytes()
Returns:
Command

getCommand

public java.lang.String getCommand()
Returns:
Command

getParams

public byte[][] getParams()
Returns:
Parameters

getParamISO

public java.lang.String getParamISO(int index)
Parameters:
index - Parameter index
Returns:
ISO-converted string

isParamInteger

public boolean isParamInteger(int index)
Parameters:
index - Parameter index
Returns:
True if it is an integer

includesPostfix

public boolean includesPostfix()
Returns:
True if last param was a postfix type

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2011 Samuel Marshall. All rights reserved.