net.kano.joscar.rvcmd.sendfile
Class FileSendBlock

java.lang.Object
  extended byFileSendBlock
All Implemented Interfaces:
LiveWritable

public class FileSendBlock
extends java.lang.Object
implements LiveWritable

A data structure containing information about a file or directory of files being sent in a file transfer request.


Field Summary
static int SENDTYPE_DIR
          A code indicating that all of the files in a directory are being sent.
static int SENDTYPE_SINGLEFILE
          A code indicating that a single file is being sent.
 
Constructor Summary
FileSendBlock(int sendType, java.lang.String filename, int fileCount, long totalFileSize)
          Creates a new outgoing file send block with the given properties.
FileSendBlock(java.lang.String filename, long size)
          Creates a file send block describing a single file with the given size.
 
Method Summary
 int getFileCount()
          Returns the total number of files being sent.
 java.lang.String getFilename()
          Returns the name of the file being sent.
 int getSendType()
          Returns the "send type" code for this transfer.
 long getTotalFileSize()
          Returns the total cumulative file size, in bytes, of all files being sent.
static FileSendBlock readFileSendBlock(ByteBlock block)
          Creates a new file send block object from the given incoming block of binary data.
 java.lang.String toString()
           
 void write(java.io.OutputStream out)
          Writes a representation of this object to the given stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SENDTYPE_SINGLEFILE

public static final int SENDTYPE_SINGLEFILE
A code indicating that a single file is being sent.

See Also:
Constant Field Values

SENDTYPE_DIR

public static final int SENDTYPE_DIR
A code indicating that all of the files in a directory are being sent.

See Also:
Constant Field Values
Constructor Detail

FileSendBlock

public FileSendBlock(java.lang.String filename,
                     long size)
Creates a file send block describing a single file with the given size. That is, creates a file send block with the given properties, a type of SENDTYPE_SINGLEFILE and a file count of 1.

Using this constructor is eqiuvalent to using new FileSendBlock(SENDTYPE_SINGLEFILE, filename, 1, size).

Parameters:
filename - the name of the file being sent
size - the size of the file being sent

FileSendBlock

public FileSendBlock(int sendType,
                     java.lang.String filename,
                     int fileCount,
                     long totalFileSize)
Creates a new outgoing file send block with the given properties.

Note that when sending all files in the directory dirName, WinAIM sends "dirName\*" as the value of filename.

Parameters:
sendType - a "send type" code, like SENDTYPE_SINGLEFILE
filename - the name of the file or directory being sent
fileCount - the number of files being sent (not including the base directory itself, if sending an entire directory)
totalFileSize - the total cumulative file size of all of the files being sent
Method Detail

readFileSendBlock

public static FileSendBlock readFileSendBlock(ByteBlock block)
Creates a new file send block object from the given incoming block of binary data.

Parameters:
block - a block of binary data containing a file send block
Returns:
a file send block object read from the given block of data

getSendType

public final int getSendType()
Returns the "send type" code for this transfer. This will normally be either SENDTYPE_SINGLEFILE or SENDTYPE_DIR.

Returns:
this block's "send type" code

getFileCount

public final int getFileCount()
Returns the total number of files being sent.

Returns:
the total number of files being sent

getTotalFileSize

public final long getTotalFileSize()
Returns the total cumulative file size, in bytes, of all files being sent.

Returns:
the total file size of all files being sent

getFilename

public final java.lang.String getFilename()
Returns the name of the file being sent. Note that when sending an entire directory of files, WinAIM sends something resembling "directoryName\*" as the filename, indicating that the transferred files should be placed in a new directory called directoryName.

Returns:
the name of the file being sent

write

public void write(java.io.OutputStream out)
           throws java.io.IOException
Description copied from interface: LiveWritable
Writes a representation of this object to the given stream.

Specified by:
write in interface LiveWritable
Parameters:
out - the stream to which to write
Throws:
java.io.IOException - if an I/O error occurs

toString

public java.lang.String toString()