1 16 package org.apache.commons.net.io; 17 18 import java.util.Enumeration ; 19 import org.apache.commons.net.util.ListenerList; 20 21 39 public class CopyStreamAdapter implements CopyStreamListener 40 { 41 private ListenerList internalListeners; 42 43 46 public CopyStreamAdapter() 47 { 48 internalListeners = new ListenerList(); 49 } 50 51 61 public void bytesTransferred(CopyStreamEvent event) 62 { 63 bytesTransferred(event.getTotalBytesTransferred(), 64 event.getBytesTransferred(), 65 event.getStreamSize()); 66 } 67 68 83 public void bytesTransferred(long totalBytesTransferred, 84 int bytesTransferred, long streamSize) 85 { 86 Enumeration listeners; 87 CopyStreamEvent event; 88 89 listeners = internalListeners.getListeners(); 90 91 event = new CopyStreamEvent(this, 92 totalBytesTransferred, 93 bytesTransferred, 94 streamSize); 95 96 while (listeners.hasMoreElements()) 97 { 98 ((CopyStreamListener) (listeners.nextElement())). 99 bytesTransferred(event); 100 } 101 } 102 103 109 public void addCopyStreamListener(CopyStreamListener listener) 110 { 111 internalListeners.addListener(listener); 112 } 113 114 119 public void removeCopyStreamListener(CopyStreamListener listener) 120 { 121 internalListeners.removeListener(listener); 122 } 123 } 124 | Popular Tags |