1 7 package fr.jayasoft.ivy.repository; 8 9 import fr.jayasoft.ivy.util.CopyProgressEvent; 10 import fr.jayasoft.ivy.util.CopyProgressListener; 11 12 public class RepositoryCopyProgressListener implements CopyProgressListener { 13 private final AbstractRepository _repository; 14 15 public RepositoryCopyProgressListener(AbstractRepository repository) { 16 _repository = repository; 17 } 18 19 private Long _totalLength = null; 20 public void start(CopyProgressEvent evt) { 21 if (_totalLength != null) { 22 _repository.fireTransferStarted(_totalLength.longValue()); 23 } else { 24 _repository.fireTransferStarted(); 25 } 26 } 27 28 public void progress(CopyProgressEvent evt) { 29 _repository.fireTransferProgress(evt.getReadBytes()); 30 } 31 32 public void end(CopyProgressEvent evt) { 33 _repository.fireTransferProgress(evt.getReadBytes()); 34 _repository.fireTransferCompleted(); 35 } 36 37 public Long getTotalLength() { 38 return _totalLength; 39 } 40 41 public void setTotalLength(Long totalLength) { 42 _totalLength = totalLength; 43 } 44 } | Popular Tags |