See on Tõrva Gümnaasiumi vana veebilehe arhiiv. Uus veebileht: https://torva.edu.ee/

DCCFile (PJIRC project)

Lisamaterjalide loend

Algne fail: vana_veeb/pjirc/doc/javadoc/irc/dcc/DCCFile.html.

========== START OF NAVBAR ==========
=========== END OF NAVBAR ===========
======== START OF CLASS DATA ========

irc.dcc
Class DCCFile

java.lang.Object
  |
  +--irc.dcc.DCCFile

public class DCCFile
extends java.lang.Object

The DCCFile, used for file transferts.


Constructor Summary
DCCFile(java.io.File f, DCCFileHandler handler)
          Create a new DCCFile.
 
Method Summary
 void addDCCFileListener(DCCFileListener lis)
          Add a listener.
 void byteReceived(byte b)
          Write a new byte in the destination file.
 void fileReceived()
          Notify this dcc file the file reception is terminated.
 void fileReceiveFailed()
          Notify this dcc file the file reception has failed.
 void fileSent()
          Notify this file the sending is terminated.
 void fileSentFailed()
          Notify this file the sending has failed.
 java.lang.String getName()
          Get the file name.
 int getSize()
          Get the file size.
 boolean isDownloading()
          Return true if the transfert is a download transfert.
 boolean isUploading()
          Return true if the transfert is an upload transfert.
 void leave()
          Request this transfert to be closed.
 void prepareReceive(int size)
          Prepare to receive file.
 void prepareSend()
          Prepare to send the file.
 byte readByte()
          Read the next byte while sending.
 void receive(java.lang.String ip, java.lang.String port, java.lang.String size)
          Prepare the file reception in active mode.
 void removeDCCFileListener(DCCFileListener lis)
          Remove a listener.
 java.lang.String send()
          Prepare the file sending in passive mode.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DCCFile

public DCCFile(java.io.File f,
               DCCFileHandler handler)
Create a new DCCFile.

Parameters:
f - the file to transfert.
handler - the file handler.

Method Detail

addDCCFileListener

public void addDCCFileListener(DCCFileListener lis)
Add a listener.

Parameters:
lis - listener to add.


removeDCCFileListener

public void removeDCCFileListener(DCCFileListener lis)
Remove a listener.

Parameters:
lis - listener to remove.


prepareSend

public void prepareSend()
Prepare to send the file.


readByte

public byte readByte()
Read the next byte while sending.

Returns:
next byte, or -1 if end of file reached.


getSize

public int getSize()
Get the file size.

Returns:
the file size, in byte.


isUploading

public boolean isUploading()
Return true if the transfert is an upload transfert.

Returns:
true if uplading, false otherwise.


isDownloading

public boolean isDownloading()
Return true if the transfert is a download transfert.

Returns:
true if downloading, false otherwise.


fileSent

public void fileSent()
Notify this file the sending is terminated.


fileSentFailed

public void fileSentFailed()
Notify this file the sending has failed.


prepareReceive

public void prepareReceive(int size)
Prepare to receive file.

Parameters:
size - the file size.


byteReceived

public void byteReceived(byte b)
Write a new byte in the destination file.

Parameters:
b - the new received byte.


fileReceived

public void fileReceived()
Notify this dcc file the file reception is terminated.


fileReceiveFailed

public void fileReceiveFailed()
Notify this dcc file the file reception has failed.


getName

public java.lang.String getName()
Get the file name.


leave

public void leave()
Request this transfert to be closed.


send

public java.lang.String send()
Prepare the file sending in passive mode.

Returns:
the string to be sent to peer in order to begin the file transfert.


receive

public void receive(java.lang.String ip,
                    java.lang.String port,
                    java.lang.String size)
Prepare the file reception in active mode.

Parameters:
ip - ip to contact.
port - port to contact.
size - file size to transfert.