01: /*
02: * Copyright 2001-2005 The Apache Software Foundation
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
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: * This method is invoked by a CopyStreamEvent source after copying
44: * a block of bytes from a stream. The CopyStreamEvent will contain
45: * the total number of bytes transferred so far and the number of bytes
46: * transferred in the last write.
47: * @param event The CopyStreamEvent fired by the copying of a block of
48: * bytes.
49: */
50: public void bytesTransferred(CopyStreamEvent event);
51:
52: /**
53: * This method is not part of the JavaBeans model and is used by the
54: * static methods in the org.apache.commons.io.Util class for efficiency.
55: * It is invoked after a block of bytes to inform the listener of the
56: * transfer.
57: * @param totalBytesTransferred The total number of bytes transferred
58: * so far by the copy operation.
59: * @param bytesTransferred The number of bytes copied by the most recent
60: * write.
61: * @param streamSize The number of bytes in the stream being copied.
62: * This may be equal to CopyStreamEvent.UNKNOWN_STREAM_SIZE if
63: * the size is unknown.
64: */
65: public void bytesTransferred(long totalBytesTransferred,
66: int bytesTransferred, long streamSize);
67: }
|