KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sourceforge > cruisecontrol > ProjectState


1 /********************************************************************************
2  * CruiseControl, a Continuous Integration Toolkit
3  * Copyright (c) 2001-2003, ThoughtWorks, Inc.
4  * 651 W Washington Ave. Suite 600
5  * Chicago, IL 60661 USA
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * + Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  *
15  * + Redistributions in binary form must reproduce the above
16  * copyright notice, this list of conditions and the following
17  * disclaimer in the documentation and/or other materials provided
18  * with the distribution.
19  *
20  * + Neither the name of ThoughtWorks, Inc., CruiseControl, nor the
21  * names of its contributors may be used to endorse or promote
22  * products derived from this software without specific prior
23  * written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
29  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36  ********************************************************************************/

37 package net.sourceforge.cruisecontrol;
38
39 import java.io.ObjectStreamException JavaDoc;
40 import java.io.Serializable JavaDoc;
41 import java.util.HashMap JavaDoc;
42 import java.util.Map JavaDoc;
43
44 /**
45  * An enumeration of Project states following standard typesafe enumeration
46  * pattern in Java.
47  */

48 public final class ProjectState implements Serializable JavaDoc {
49     private static final Map JavaDoc ALL_STATES = new HashMap JavaDoc();
50
51     public static final ProjectState QUEUED =
52             new ProjectState(1, "queued", "in build queue");
53     public static final ProjectState IDLE =
54             new ProjectState(0, "idle", "idle");
55     public static final ProjectState BOOTSTRAPPING =
56             new ProjectState(2, "bootstrapping", "bootstrapping");
57     public static final ProjectState MODIFICATIONSET =
58             new ProjectState(3, "modificationset", "checking for modifications");
59     public static final ProjectState BUILDING =
60             new ProjectState(4, "building", "now building");
61     public static final ProjectState MERGING_LOGS =
62             new ProjectState(5, "merging", "merging accumulated log files");
63     public static final ProjectState PUBLISHING =
64             new ProjectState(6, "publishing", "publishing build results");
65     public static final ProjectState PAUSED =
66             new ProjectState(7, "paused", "paused");
67     public static final ProjectState STOPPED =
68             new ProjectState(8, "stopped", "stopped");
69     public static final ProjectState WAITING =
70             new ProjectState(9, "waiting", "waiting for next time to build");
71     
72     private String JavaDoc description;
73     private String JavaDoc name;
74     private int code;
75
76     private ProjectState (int code, String JavaDoc name, String JavaDoc desc) {
77         this.code = code;
78         this.name = name;
79         this.description = desc;
80         ALL_STATES.put(name, this);
81     }
82
83     public String JavaDoc getDescription() {
84         return description;
85     }
86
87     public int getCode() {
88         return code;
89     }
90
91     public String JavaDoc getName() {
92         return name;
93     }
94     
95     /**
96      * A <strong>magic</strong> method used by Java Object Serialization. This
97      * allows ProjectState to force the deserialization process to use one of
98      * the ProjectState enum instances that already exist.
99      *
100      * @return a replacement object instance
101      * @throws ObjectStreamException never actually thrown
102      */

103     private Object JavaDoc readResolve() throws ObjectStreamException JavaDoc {
104         return ALL_STATES.get(name);
105     }
106 }
107
Popular Tags