1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.commons.net.io;
17
18 import java.util.EventListener;
19
20 /**
21 * The CopyStreamListener class can accept CopyStreamEvents to keep track
22 * of the progress of a stream copying operation. However, it is currently
23 * not used that way within NetComponents for performance reasons. Rather
24 * the bytesTransferred(long, int) method is called directly rather than
25 * passing an event to bytesTransferred(CopyStreamEvent), saving the creation
26 * of a CopyStreamEvent instance. Also, the only place where
27 * CopyStreamListener is currently used within NetComponents is in the
28 * static methods of the uninstantiable org.apache.commons.io.Util class, which
29 * would preclude the use of addCopyStreamListener and
30 * removeCopyStreamListener methods. However, future additions may use the
31 * JavaBean event model, which is why the hooks have been included from the
32 * beginning.
33 * <p>
34 * <p>
35 * @see CopyStreamEvent
36 * @see CopyStreamAdapter
37 * @see Util
38 * @author <a href="mailto:savarese@apache.org">Daniel F. Savarese</a>
39 * @version $Id: CopyStreamListener.java 165675 2005-05-02 20:09:55Z rwinston $
40 */
41 public interface CopyStreamListener extends EventListener
42 {
43 /**
44 * This method is invoked by a CopyStreamEvent source after copying
45 * a block of bytes from a stream. The CopyStreamEvent will contain
46 * the total number of bytes transferred so far and the number of bytes
47 * transferred in the last write.
48 * @param event The CopyStreamEvent fired by the copying of a block of
49 * bytes.
50 */
51 public void bytesTransferred(CopyStreamEvent event);
52
53
54 /**
55 * This method is not part of the JavaBeans model and is used by the
56 * static methods in the org.apache.commons.io.Util class for efficiency.
57 * It is invoked after a block of bytes to inform the listener of the
58 * transfer.
59 * @param totalBytesTransferred The total number of bytes transferred
60 * so far by the copy operation.
61 * @param bytesTransferred The number of bytes copied by the most recent
62 * write.
63 * @param streamSize The number of bytes in the stream being copied.
64 * This may be equal to CopyStreamEvent.UNKNOWN_STREAM_SIZE if
65 * the size is unknown.
66 */
67 public void bytesTransferred(long totalBytesTransferred,
68 int bytesTransferred,
69 long streamSize);
70 }