| 1 | |
package org.kuali.maven.mojo.s3; |
| 2 | |
|
| 3 | |
import java.io.PrintStream; |
| 4 | |
|
| 5 | 0 | public class ProgressTracker { |
| 6 | |
|
| 7 | |
int count; |
| 8 | |
int total; |
| 9 | 0 | PrintStream out = System.out; |
| 10 | 0 | String startToken = "[INFO] Progress: "; |
| 11 | 0 | String completeToken = "\n"; |
| 12 | 0 | String progressToken = "."; |
| 13 | |
|
| 14 | |
public synchronized int getCount() { |
| 15 | 0 | return count; |
| 16 | |
} |
| 17 | |
|
| 18 | |
public synchronized void increment() { |
| 19 | 0 | if (count == 0) { |
| 20 | 0 | showProgressStart(); |
| 21 | |
} |
| 22 | 0 | showProgress(++count, total); |
| 23 | 0 | if (count == total) { |
| 24 | 0 | showProgressComplete(); |
| 25 | |
} |
| 26 | 0 | } |
| 27 | |
|
| 28 | |
protected void showProgressComplete() { |
| 29 | 0 | out.print(completeToken); |
| 30 | 0 | } |
| 31 | |
|
| 32 | |
protected void showProgressStart() { |
| 33 | 0 | out.print(startToken); |
| 34 | 0 | } |
| 35 | |
|
| 36 | |
protected void showProgress(int count, int total) { |
| 37 | 0 | out.print(progressToken); |
| 38 | 0 | } |
| 39 | |
|
| 40 | |
public int getTotal() { |
| 41 | 0 | return total; |
| 42 | |
} |
| 43 | |
|
| 44 | |
public void setTotal(int total) { |
| 45 | 0 | this.total = total; |
| 46 | 0 | } |
| 47 | |
|
| 48 | |
public PrintStream getOut() { |
| 49 | 0 | return out; |
| 50 | |
} |
| 51 | |
|
| 52 | |
public void setOut(PrintStream out) { |
| 53 | 0 | this.out = out; |
| 54 | 0 | } |
| 55 | |
|
| 56 | |
public String getStartToken() { |
| 57 | 0 | return startToken; |
| 58 | |
} |
| 59 | |
|
| 60 | |
public void setStartToken(String startToken) { |
| 61 | 0 | this.startToken = startToken; |
| 62 | 0 | } |
| 63 | |
|
| 64 | |
public String getCompleteToken() { |
| 65 | 0 | return completeToken; |
| 66 | |
} |
| 67 | |
|
| 68 | |
public void setCompleteToken(String completeToken) { |
| 69 | 0 | this.completeToken = completeToken; |
| 70 | 0 | } |
| 71 | |
|
| 72 | |
public String getProgressToken() { |
| 73 | 0 | return progressToken; |
| 74 | |
} |
| 75 | |
|
| 76 | |
public void setProgressToken(String progressToken) { |
| 77 | 0 | this.progressToken = progressToken; |
| 78 | 0 | } |
| 79 | |
|
| 80 | |
} |