org.elite.jdcbot.framework
Class DCIO

java.lang.Object
  extended by org.elite.jdcbot.framework.DCIO
Direct Known Subclasses:
DownloadHandler, DownloadManager, InputThread, InputThreadTarget, UploadManager

public class DCIO
extends java.lang.Object

Created on 26-May-08
The purpose of this class is to implement methods that are needed for IO easily send and recerive and parse commands.

Since:
0.7
Version:
0.1
Author:
AppleGrew

Field Summary
private  java.lang.String ioexception_msg
           
 
Constructor Summary
DCIO()
           
 
Method Summary
 java.lang.String parseCmdArgs(java.lang.String cmd)
          Parses a raw command for the command's arguments, i.e.
 java.lang.String parseCmdName(java.lang.String cmd)
          Parses a raw command for the command name.
 java.lang.String[] parseRawCmd(java.lang.String cmd)
          Parses the given raw command and returns the command name in position 0 and the rest arguments in later slots.
Note: This is a simple generalized parser.
 java.lang.String ReadCommand(java.io.InputStream in)
          Reading raw command from in.
 java.lang.String ReadCommand(java.net.Socket socket)
           
 void SendCommand(java.lang.String buffer, java.io.OutputStream out)
          Sends raw command to out.
 void SendCommand(java.lang.String buffer, java.net.Socket socket)
           
 void set_IOExceptionMsg(java.lang.String msg)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ioexception_msg

private java.lang.String ioexception_msg
Constructor Detail

DCIO

public DCIO()
Method Detail

set_IOExceptionMsg

public void set_IOExceptionMsg(java.lang.String msg)

ReadCommand

public final java.lang.String ReadCommand(java.io.InputStream in)
                                   throws java.lang.Exception
Reading raw command from in.

Parameters:
The - socket stream from which to read the command.
Returns:
Command from hub
Throws:
java.lang.Exception

ReadCommand

public final java.lang.String ReadCommand(java.net.Socket socket)
                                   throws java.lang.Exception
Throws:
java.lang.Exception

SendCommand

public final void SendCommand(java.lang.String buffer,
                              java.io.OutputStream out)
                       throws java.lang.Exception
Sends raw command to out.

Parameters:
buffer - Line which needs to be send. This method won't append "|" on the end on the string if it doesn't exist, so it is up to make sure buffer ends with "|" if you calling this method.
out - The socket stream into which to write the raw command.
Throws:
java.lang.Exception

SendCommand

public final void SendCommand(java.lang.String buffer,
                              java.net.Socket socket)
                       throws java.lang.Exception
Throws:
java.lang.Exception

parseRawCmd

public final java.lang.String[] parseRawCmd(java.lang.String cmd)
Parses the given raw command and returns the command name in position 0 and the rest arguments in later slots.
Note: This is a simple generalized parser. It simply splits at point of white space, hence it is not useful to parse private/public messages etc.

Parameters:
cmd - The raw command to parse.
Returns:

parseCmdName

public final java.lang.String parseCmdName(java.lang.String cmd)
Parses a raw command for the command name.

Parameters:
cmd - The raw command to parse.
Returns:

parseCmdArgs

public final java.lang.String parseCmdArgs(java.lang.String cmd)
Parses a raw command for the command's arguments, i.e. Everything in the raw command except the command name and the trailing pipe (|).

Parameters:
cmd - The raw command to parse.
Returns: