KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mmbase > applications > packaging > projects > packageStep


1 /*
2  * This software is OSI Certified Open Source Software.
3  * OSI Certified is a certification mark of the Open Source Initiative.
4  * The license (Mozilla version 1.0) can be read at the MMBase site.
5  * See http://www.MMBase.org/license
6  */

7 package org.mmbase.applications.packaging.projects;
8
9 import java.util.ArrayList JavaDoc;
10 import java.util.Iterator JavaDoc;
11
12 /**
13  *
14  * @version $Id: packageStep.java,v 1.5 2005/10/02 17:10:58 michiel Exp $
15  * @author Daniel Ockeloen
16  * @rename PackageStep
17  */

18 public class packageStep {
19
20     private String JavaDoc userfeedback;
21
22     private ArrayList JavaDoc packagesteps;
23
24     private int timestamp;
25
26     private int type = 0;
27
28     private int errorcount = 0;
29
30     private int warningcount = 0;
31
32     private int parent = -1;
33
34     public final static int TYPE_ERROR = 1;
35
36     public final static int TYPE_WARNING = 2;
37
38
39     /**
40      * Constructor for the PackageStep object
41      */

42     public packageStep() {
43         timestamp = (int) (System.currentTimeMillis() / 1000);
44     }
45
46
47     /**
48      * Sets the userFeedBack attribute of the packageStep object
49      *
50      * @param line The new userFeedBack value
51      */

52     public void setUserFeedBack(String JavaDoc line) {
53         userfeedback = line;
54     }
55
56
57
58     /**
59      * Sets the type attribute of the packageStep object
60      *
61      * @param type The new type value
62      */

63     public void setType(int type) {
64         this.type = type;
65         if (type == TYPE_WARNING) {
66             warningcount++;
67         }
68         if (type == TYPE_ERROR) {
69             errorcount++;
70         }
71     }
72
73
74     /**
75      * Gets the userFeedBack attribute of the packageStep object
76      *
77      * @return The userFeedBack value
78      */

79     public String JavaDoc getUserFeedBack() {
80         return userfeedback;
81     }
82
83
84     /**
85      * Gets the timeStamp attribute of the packageStep object
86      *
87      * @return The timeStamp value
88      */

89     public int getTimeStamp() {
90         return timestamp;
91     }
92
93
94     /**
95      * Gets the errorCount attribute of the packageStep object
96      *
97      * @return The errorCount value
98      */

99     public int getErrorCount() {
100         // count all the errors of the subs
101
if (packagesteps != null) {
102             int total = errorcount;
103             Iterator JavaDoc e = packagesteps.iterator();
104             while (e.hasNext()) {
105                 packageStep step = (packageStep) e.next();
106                 total += step.getErrorCount();
107             }
108             return total;
109         } else {
110             return errorcount;
111         }
112     }
113
114
115     /**
116      * Gets the warningCount attribute of the packageStep object
117      *
118      * @return The warningCount value
119      */

120     public int getWarningCount() {
121         if (packagesteps != null) {
122             int total = warningcount;
123             Iterator JavaDoc e = packagesteps.iterator();
124             while (e.hasNext()) {
125                 packageStep step = (packageStep) e.next();
126                 total += step.getWarningCount();
127             }
128             return total;
129         } else {
130             return warningcount;
131         }
132     }
133
134
135     /**
136      * Gets the packageSteps attribute of the packageStep object
137      *
138      * @return The packageSteps value
139      */

140     public Iterator JavaDoc getPackageSteps() {
141         if (packagesteps != null) {
142             return packagesteps.iterator();
143         } else {
144             return null;
145         }
146     }
147
148
149     /**
150      * Gets the packageSteps attribute of the packageStep object
151      *
152      * @param logid Description of the Parameter
153      * @return The packageSteps value
154      */

155     public Iterator JavaDoc getPackageSteps(int logid) {
156         // is it me ?
157
if (logid == getId()) {
158             return getPackageSteps();
159         }
160
161         // well maybe its one of my subs ?
162
Iterator JavaDoc e = getPackageSteps();
163         if (e != null) {
164             while (e.hasNext()) {
165                 packageStep step = (packageStep) e.next();
166                 Object JavaDoc o = step.getPackageSteps(logid);
167                 if (o != null) {
168                     return (Iterator JavaDoc) o;
169                 }
170             }
171         }
172         return null;
173     }
174
175
176     /**
177      * Gets the nextPackageStep attribute of the packageStep object
178      *
179      * @return The nextPackageStep value
180      */

181     public packageStep getNextPackageStep() {
182         // create new step
183
packageStep step = new packageStep();
184         step.setParent(getId());
185         if (packagesteps == null) {
186             packagesteps = new ArrayList JavaDoc();
187             packagesteps.add(step);
188             return step;
189         } else {
190             packagesteps.add(step);
191             return step;
192         }
193     }
194
195
196     /**
197      * Gets the id attribute of the packageStep object
198      *
199      * @return The id value
200      */

201     public int getId() {
202         return this.hashCode();
203     }
204
205
206     /**
207      * Sets the parent attribute of the packageStep object
208      *
209      * @param parent The new parent value
210      */

211     public void setParent(int parent) {
212         this.parent = parent;
213     }
214
215
216     /**
217      * Description of the Method
218      *
219      * @return Description of the Return Value
220      */

221     public boolean hasChilds() {
222         if (packagesteps != null) {
223             return true;
224         }
225         return false;
226     }
227
228
229     /**
230      * Gets the parent attribute of the packageStep object
231      *
232      * @return The parent value
233      */

234     public int getParent() {
235         return parent;
236     }
237 }
238
239
Popular Tags