KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > nightlabs > ipanema > module > ModuleType


1 /* ************************************************************************** *
2  * Copyright (C) 2004 NightLabs GmbH, Marco Schulze *
3  * All rights reserved. *
4  * http://www.NightLabs.de *
5  * *
6  * This program and the accompanying materials are free software; you can re- *
7  * distribute it and/or modify it under the terms of the GNU General Public *
8  * License as published by the Free Software Foundation; either ver 2 of the *
9  * License, or any later version. *
10  * *
11  * This module is distributed in the hope that it will be useful, but WITHOUT *
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FIT- *
13  * NESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more *
14  * details. *
15  * *
16  * You should have received a copy of the GNU General Public License along *
17  * with this module; if not, write to the Free Software Foundation, Inc.: *
18  * 59 Temple Place, Suite 330 *
19  * Boston MA 02111-1307 *
20  * USA *
21  * *
22  * Or get it online: *
23  * http://www.opensource.org/licenses/gpl-license.php *
24  * *
25  * In case, you want to use this module or parts of it in a proprietary pro- *
26  * ject, you can purchase it under the NightLabs Commercial License. Please *
27  * contact NightLabs GmbH under info AT nightlabs DOT com for more infos or *
28  * visit http://www.NightLabs.com *
29  * ************************************************************************** */

30
31 /*
32  * Created on 13.08.2004
33  */

34 package com.nightlabs.ipanema.module;
35
36 /**
37  * @author marco
38  */

39 public class ModuleType
40 {
41     public static final String JavaDoc _MODULE_TYPE_WEB = "WEB";
42     public static final String JavaDoc _MODULE_TYPE_EJB = "EJB";
43
44     public static final ModuleType MODULE_TYPE_WEB = new ModuleType(_MODULE_TYPE_WEB, true);
45     public static final ModuleType MODULE_TYPE_EJB = new ModuleType(_MODULE_TYPE_EJB, true);
46
47     private transient boolean readOnly = false;
48     public ModuleType()
49     {
50         moduleType = _MODULE_TYPE_WEB;
51     }
52     
53     protected ModuleType(String JavaDoc _moduleType, boolean _readOnly)
54     {
55         this(_moduleType);
56         this.readOnly = _readOnly;
57     }
58
59     public ModuleType(String JavaDoc _moduleType)
60     {
61         this.moduleType = _moduleType;
62     }
63
64     private String JavaDoc moduleType;
65
66     /**
67      * @return Returns the moduleType.
68      */

69     public String JavaDoc getModuleType() {
70         return moduleType;
71     }
72     /**
73      * @param moduleType The moduleType to set.
74      */

75     public void setModuleType(String JavaDoc moduleType) {
76         if (readOnly)
77             throw new IllegalStateException JavaDoc("This instance of ModuleType is readonly!");
78         this.moduleType = moduleType;
79     }
80
81     /**
82      * @see java.lang.Object#equals(java.lang.Object)
83      */

84     public boolean equals(Object JavaDoc obj) {
85         if (!(obj instanceof ModuleType))
86             return false;
87         
88         ModuleType other = (ModuleType)obj;
89         return this.moduleType.equals(other.moduleType);
90     }
91     /**
92      * @see java.lang.Object#hashCode()
93      */

94     public int hashCode() {
95         return moduleType.hashCode();
96     }
97
98     private String JavaDoc thisString = null;
99     /**
100      * @see java.lang.Object#toString()
101      */

102     public String JavaDoc toString() {
103         if (thisString == null) {
104             StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
105             sb.append(this.getClass().getName());
106             sb.append('{');
107             sb.append(moduleType.toString());
108             sb.append('}');
109             thisString = sb.toString();
110         }
111         return thisString;
112     }
113 }
114
Popular Tags