001 /**
002 * Copyright 2010-2013 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016 package org.kuali.maven.wagon;
017
018 import org.kuali.common.aws.s3.SimpleFormatter;
019
020 /**
021 * Holds timing and byte count information about a transfer operation
022 *
023 * @author Jeff Caddel
024 *
025 * @since May 27, 2010 6:51:19 PM
026 */
027 public class TransferTracker {
028 long initiated;
029 long started;
030 long completed;
031 int byteCount;
032 SimpleFormatter formatter = new SimpleFormatter();
033
034 public long getInitiated() {
035 return initiated;
036 }
037
038 public void setInitiated(long initiated) {
039 this.initiated = initiated;
040 }
041
042 public long getStarted() {
043 return started;
044 }
045
046 public void setStarted(long started) {
047 this.started = started;
048 }
049
050 public long getCompleted() {
051 return completed;
052 }
053
054 public void setCompleted(long completed) {
055 this.completed = completed;
056 }
057
058 public int getByteCount() {
059 return byteCount;
060 }
061
062 public void setByteCount(int byteCount) {
063 this.byteCount = byteCount;
064 }
065
066 @Override
067 public String toString() {
068 long elapsed = completed - started;
069 StringBuffer sb = new StringBuffer();
070 sb.append("[" + formatter.getTime(elapsed));
071 sb.append(", " + formatter.getSize(byteCount));
072 sb.append(", " + formatter.getRate(elapsed, byteCount));
073 sb.append("]");
074 return sb.toString();
075 }
076 }