KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > gnu > mail > treeutil > StatusEvent


1 /*
2  * StatusEvent.java
3  * Copyright (C) 1999 dog <dog@dog.net.uk>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * You may retrieve the latest version of this library from
20  * http://www.dog.net.uk/knife/
21  */

22
23 package gnu.mail.treeutil;
24
25 import java.util.*;
26
27 /**
28  * A status message.
29  *
30  * @author dog@dog.net.uk
31  * @version 1.0.2
32  */

33 public class StatusEvent
34     extends EventObject
35 {
36
37     public static final int OPERATION_START = 0;
38
39     public static final int OPERATION_UPDATE = 1;
40
41     public static final int OPERATION_END = 2;
42
43     public static final int UNKNOWN = -1;
44
45     protected int type;
46
47     protected String JavaDoc operation;
48
49     protected int minimum = UNKNOWN;
50     
51     protected int maximum = UNKNOWN;
52     
53     protected int value = UNKNOWN;
54     
55     /**
56      * Creates a new status event with the specified type and operation.
57      */

58     public StatusEvent(Object JavaDoc source, int type, String JavaDoc operation)
59     {
60         super(source);
61         switch (type)
62         {
63           case OPERATION_START:
64           case OPERATION_UPDATE:
65           case OPERATION_END:
66             this.type = type;
67             break;
68           default:
69             throw new IllegalArgumentException JavaDoc("Illegal event type: "+type);
70         }
71         this.operation = operation;
72     }
73     
74     /**
75      * Creates a new status event representing an update of the specified operation.
76      */

77     public StatusEvent(Object JavaDoc source, int type, String JavaDoc operation, int minimum, int maximum, int value)
78     {
79         super(source);
80         switch (type)
81         {
82           case OPERATION_START:
83           case OPERATION_UPDATE:
84           case OPERATION_END:
85             this.type = type;
86             break;
87           default:
88             throw new IllegalArgumentException JavaDoc("Illegal event type: "+type);
89         }
90         this.operation = operation;
91         this.minimum = minimum;
92         this.maximum = maximum;
93         this.value = value;
94     }
95
96     /**
97      * Returns the type of event (OPERATION_START, OPERATION_UPDATE, or OPERATION_END).
98      */

99     public int getType()
100     {
101         return type;
102     }
103
104     /**
105      * Returns a string describing the operation being performed.
106      */

107     public String JavaDoc getOperation()
108     {
109         return operation;
110     }
111
112     /**
113      * Returns the start point of the operation.
114      */

115     public int getMinimum()
116     {
117         return minimum;
118     }
119
120     /**
121      * Returns the end point of the operation.
122      */

123     public int getMaximum()
124     {
125         return maximum;
126     }
127
128     /**
129      * Returns the current point in the operation.
130      */

131     public int getValue()
132     {
133         return value;
134     }
135
136 }
137
Popular Tags