KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > fr > jayasoft > ivy > repository > RepositoryCopyProgressListener


1 /*
2  * This file is subject to the licence found in LICENCE.TXT in the root directory of the project.
3  * Copyright Jayasoft 2005 - All rights reserved
4  *
5  * #SNAPSHOT#
6  */

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 JavaDoc _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 JavaDoc getTotalLength() {
38         return _totalLength;
39     }
40
41     public void setTotalLength(Long JavaDoc totalLength) {
42         _totalLength = totalLength;
43     }
44 }
Popular Tags