View Javadoc

1   /**
2    * Copyright 2010-2013 The Kuali Foundation
3    *
4    * Licensed under the Educational Community 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.opensource.org/licenses/ecl2.php
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.kuali.maven.wagon;
17  
18  import org.kuali.common.aws.s3.SimpleFormatter;
19  
20  /**
21   * Holds timing and byte count information about a transfer operation
22   *
23   * @author Jeff Caddel
24   *
25   * @since May 27, 2010 6:51:19 PM
26   */
27  public class TransferTracker {
28  	long initiated;
29  	long started;
30  	long completed;
31  	int byteCount;
32  	SimpleFormatter formatter = new SimpleFormatter();
33  
34  	public long getInitiated() {
35  		return initiated;
36  	}
37  
38  	public void setInitiated(long initiated) {
39  		this.initiated = initiated;
40  	}
41  
42  	public long getStarted() {
43  		return started;
44  	}
45  
46  	public void setStarted(long started) {
47  		this.started = started;
48  	}
49  
50  	public long getCompleted() {
51  		return completed;
52  	}
53  
54  	public void setCompleted(long completed) {
55  		this.completed = completed;
56  	}
57  
58  	public int getByteCount() {
59  		return byteCount;
60  	}
61  
62  	public void setByteCount(int byteCount) {
63  		this.byteCount = byteCount;
64  	}
65  
66  	@Override
67      public String toString() {
68  		long elapsed = completed - started;
69  		StringBuffer sb = new StringBuffer();
70  		sb.append("[" + formatter.getTime(elapsed));
71  		sb.append(", " + formatter.getSize(byteCount));
72  		sb.append(", " + formatter.getRate(elapsed, byteCount));
73  		sb.append("]");
74  		return sb.toString();
75  	}
76  }