1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.common.util;
17
18
19
20
21
22
23 @Deprecated
24 public class PercentCompleteInformer extends AbstractProgressInformer {
25
26 protected long progress;
27
28 int percentageIncrement = 1;
29 int percentCompletePrevious;
30 long total;
31
32 public PercentCompleteInformer() {
33 this(0);
34 }
35
36 public PercentCompleteInformer(long total) {
37 this(total, null);
38 }
39
40 public PercentCompleteInformer(long total, LogMsg startMessage) {
41 super();
42 this.total = total;
43 this.startMessage = startMessage;
44 }
45
46
47
48
49 public synchronized void incrementProgress() {
50 incrementProgress(1);
51 }
52
53
54
55
56 public synchronized void incrementProgress(long amount) {
57
58 this.progress += amount;
59
60
61 int percentComplete = (int) ((progress * 100) / total);
62
63
64 if (isEnoughProgress(percentComplete, percentCompletePrevious, percentageIncrement)) {
65
66 this.percentCompletePrevious = percentComplete;
67 printStream.print(progressToken);
68 }
69 }
70
71 protected boolean isEnoughProgress(int percentComplete, int percentCompletePrevious, int percentageIncrement) {
72 int needed = percentCompletePrevious + percentageIncrement;
73 return percentComplete >= needed;
74 }
75
76 public int getPercentageIncrement() {
77 return percentageIncrement;
78 }
79
80 public void setPercentageIncrement(int percentageIncrement) {
81 this.percentageIncrement = percentageIncrement;
82 }
83
84 public int getPercentCompletePrevious() {
85 return percentCompletePrevious;
86 }
87
88 public void setPercentCompletePrevious(int percentCompletePrevious) {
89 this.percentCompletePrevious = percentCompletePrevious;
90 }
91
92 public long getTotal() {
93 return total;
94 }
95
96 public void setTotal(long total) {
97 this.total = total;
98 }
99 }