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