1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18 package org.apache.commons.net.io; 19 20 import java.util.EventListener; 21 22 /** 23 * The CopyStreamListener class can accept CopyStreamEvents to keep track 24 * of the progress of a stream copying operation. However, it is currently 25 * not used that way within NetComponents for performance reasons. Rather 26 * the bytesTransferred(long, int) method is called directly rather than 27 * passing an event to bytesTransferred(CopyStreamEvent), saving the creation 28 * of a CopyStreamEvent instance. Also, the only place where 29 * CopyStreamListener is currently used within NetComponents is in the 30 * static methods of the uninstantiable org.apache.commons.io.Util class, which 31 * would preclude the use of addCopyStreamListener and 32 * removeCopyStreamListener methods. However, future additions may use the 33 * JavaBean event model, which is why the hooks have been included from the 34 * beginning. 35 * <p> 36 * <p> 37 * @see CopyStreamEvent 38 * @see CopyStreamAdapter 39 * @see Util 40 * @version $Id: CopyStreamListener.java 1299238 2012-03-10 17:12:28Z sebb $ 41 */ 42 public interface CopyStreamListener extends EventListener 43 { 44 /** 45 * This method is invoked by a CopyStreamEvent source after copying 46 * a block of bytes from a stream. The CopyStreamEvent will contain 47 * the total number of bytes transferred so far and the number of bytes 48 * transferred in the last write. 49 * @param event The CopyStreamEvent fired by the copying of a block of 50 * bytes. 51 */ 52 public void bytesTransferred(CopyStreamEvent event); 53 54 55 /** 56 * This method is not part of the JavaBeans model and is used by the 57 * static methods in the org.apache.commons.io.Util class for efficiency. 58 * It is invoked after a block of bytes to inform the listener of the 59 * transfer. 60 * @param totalBytesTransferred The total number of bytes transferred 61 * so far by the copy operation. 62 * @param bytesTransferred The number of bytes copied by the most recent 63 * write. 64 * @param streamSize The number of bytes in the stream being copied. 65 * This may be equal to CopyStreamEvent.UNKNOWN_STREAM_SIZE if 66 * the size is unknown. 67 */ 68 public void bytesTransferred(long totalBytesTransferred, 69 int bytesTransferred, 70 long streamSize); 71 }