KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mmbase > applications > packaging > installhandlers > installStep


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.installhandlers;
8
9 import java.util.ArrayList JavaDoc;
10 import java.util.Iterator JavaDoc;
11
12 /**
13  * @author Daniel Ockeloen
14  *
15  * background hanlder for sending email, a call backthread
16  * that is used to send email (one thread per active email
17  * node)
18  * @created July 20, 2004
19  */

20 public class installStep {
21
22     private String JavaDoc userfeedback;
23
24     private ArrayList JavaDoc installsteps;
25
26     private int timestamp;
27
28     private int type = 0;
29
30     private int errorcount = 0;
31
32     private int warningcount = 0;
33
34     private int parent = -1;
35
36     /**
37      * Description of the Field
38      */

39     public final static int TYPE_ERROR = 1;
40
41     /**
42      * Description of the Field
43      */

44     public final static int TYPE_WARNING = 2;
45
46
47     /**
48      *Constructor for the installStep object
49      */

50     public installStep() {
51         timestamp = (int) (System.currentTimeMillis() / 1000);
52     }
53
54
55     /**
56      * Sets the userFeedBack attribute of the installStep object
57      *
58      * @param line The new userFeedBack value
59      */

60     public void setUserFeedBack(String JavaDoc line) {
61         userfeedback = line;
62     }
63
64
65     /**
66      * Sets the type attribute of the installStep object
67      *
68      * @param type The new type value
69      */

70     public void setType(int type) {
71         this.type = type;
72         if (type == TYPE_WARNING) {
73             warningcount++;
74         }
75         if (type == TYPE_ERROR) {
76             errorcount++;
77         }
78     }
79
80
81     /**
82      * Gets the userFeedBack attribute of the installStep object
83      *
84      * @return The userFeedBack value
85      */

86     public String JavaDoc getUserFeedBack() {
87         return userfeedback;
88     }
89
90
91     /**
92      * Gets the timeStamp attribute of the installStep object
93      *
94      * @return The timeStamp value
95      */

96     public int getTimeStamp() {
97         return timestamp;
98     }
99
100
101     /**
102      * Gets the errorCount attribute of the installStep object
103      *
104      * @return The errorCount value
105      */

106     public int getErrorCount() {
107         // count all the errors of the subs
108
if (installsteps != null) {
109             int total = errorcount;
110             Iterator JavaDoc e = installsteps.iterator();
111             while (e.hasNext()) {
112                 installStep step = (installStep) e.next();
113                 total += step.getErrorCount();
114             }
115             return total;
116         } else {
117             return errorcount;
118         }
119     }
120
121
122     /**
123      * Gets the warningCount attribute of the installStep object
124      *
125      * @return The warningCount value
126      */

127     public int getWarningCount() {
128         if (installsteps != null) {
129             int total = warningcount;
130             Iterator JavaDoc e = installsteps.iterator();
131             while (e.hasNext()) {
132                 installStep step = (installStep) e.next();
133                 total += step.getWarningCount();
134             }
135             return total;
136         } else {
137             return warningcount;
138         }
139     }
140
141
142     /**
143      * Gets the installSteps attribute of the installStep object
144      *
145      * @return The installSteps value
146      */

147     public Iterator JavaDoc getInstallSteps() {
148         if (installsteps != null) {
149             return installsteps.iterator();
150         } else {
151             return null;
152         }
153     }
154
155
156     /**
157      * Gets the installSteps attribute of the installStep object
158      *
159      * @param logid Description of the Parameter
160      * @return The installSteps value
161      */

162     public Iterator JavaDoc getInstallSteps(int logid) {
163         // is it me ?
164
if (logid == getId()) {
165             return getInstallSteps();
166         }
167
168         // well maybe its one of my subs ?
169
Iterator JavaDoc e = getInstallSteps();
170         if (e != null) {
171             while (e.hasNext()) {
172                 installStep step = (installStep) e.next();
173                 Object JavaDoc o = step.getInstallSteps(logid);
174                 if (o != null) {
175                     return (Iterator JavaDoc) o;
176                 }
177             }
178         }
179         return null;
180     }
181
182
183     /**
184      * Gets the nextInstallStep attribute of the installStep object
185      *
186      * @return The nextInstallStep value
187      */

188     public installStep getNextInstallStep() {
189         // create new step
190
installStep step = new installStep();
191         step.setParent(getId());
192         if (installsteps == null) {
193             installsteps = new ArrayList JavaDoc();
194             installsteps.add(step);
195             return step;
196         } else {
197             installsteps.add(step);
198             return step;
199         }
200     }
201
202
203     /**
204      * Gets the id attribute of the installStep object
205      *
206      * @return The id value
207      */

208     public int getId() {
209         return this.hashCode();
210     }
211
212
213     /**
214      * Sets the parent attribute of the installStep object
215      *
216      * @param parent The new parent value
217      */

218     public void setParent(int parent) {
219         this.parent = parent;
220     }
221
222
223     /**
224      * Description of the Method
225      *
226      * @return Description of the Return Value
227      */

228     public boolean hasChilds() {
229         if (installsteps != null) {
230             return true;
231         }
232         return false;
233     }
234
235
236     /**
237      * Gets the parent attribute of the installStep object
238      *
239      * @return The parent value
240      */

241     public int getParent() {
242         return parent;
243     }
244 }
245
246
Popular Tags