KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > util > explorer > core > role > lib > DefaultRole


1 /*====================================================================
2
3 Objectweb Explorer framework
4 Copyright (C) 2000-2005 INRIA - USTL - LIFL - GOAL
5 Contact: openccm@objectweb.org
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 USA
21
22 Initial developer(s): Jerome Moroy.
23 Contributor(s): ______________________________________.
24
25 ====================================================================
26 $Id: DefaultRole.java,v 1.2 2005/07/06 15:36:01 moroy Exp $
27 ====================================================================*/

28
29 package org.objectweb.util.explorer.core.role.lib;
30
31 import org.objectweb.util.explorer.core.common.lib.DefaultKey;
32 import org.objectweb.util.explorer.core.role.api.Role;
33
34 /**
35  * Default implementation of a role.
36  *
37  * @author <a HREF="mailto:Jerome.Moroy@lifl.fr">Jerome Moroy</a>
38  * @version 0.1
39  *
40  */

41 public class DefaultRole
42   implements Role
43 {
44
45     // ==================================================================
46
//
47
// Internal states.
48
//
49
// ==================================================================
50

51     /** The id of the role. */
52     protected String JavaDoc role_id_;
53     
54     /** Indicates if this role must be visible in the "role" menu */
55     protected boolean isConcrete_ = true;
56
57     // ==================================================================
58
//
59
// Constructor.
60
//
61
// ==================================================================
62

63     /**
64      * Default constructor.
65      * @param role_id The id of the role.
66      */

67     public DefaultRole(String JavaDoc role_id){
68         if(role_id==null)
69             role_id = "";
70         role_id_ = role_id;
71     }
72
73     // ==================================================================
74
//
75
// No internal method.
76
//
77
// ==================================================================
78

79     // ==================================================================
80
//
81
// Public methods for Role interface.
82
//
83
// ==================================================================
84

85     /**
86      * @see org.objectweb.util.explorer.core.role.api.Role#getId()
87      */

88     public String JavaDoc getId() {
89         return role_id_;
90     }
91
92     /**
93      * Indicates the kind of the role (concrete or abstract). The default value is true.
94      */

95      public void setConcrete(boolean isConcrete){
96         isConcrete_ = isConcrete;
97     }
98     
99     /**
100      * Indicates if this role is concrete or not. A concrete role is visible in the "role" menu. The default value is true.
101      */

102     public boolean isConcrete(){
103         return isConcrete_;
104     }
105
106     // ==================================================================
107
//
108
// Public methods surcharging Object class.
109
//
110
// ==================================================================
111

112     /**
113      * Surcharging the Object.equals method.
114      * @see DefaultKey#equals(DefaultKey)
115      */

116     public boolean equals(Object JavaDoc obj){
117         if(obj!=null){
118             return ((DefaultRole)obj).getId().trim().equals(role_id_.trim());
119         }
120         return false;
121     }
122     
123     /**
124      * Surcharging "toString" method.
125      */

126     public String JavaDoc toString(){
127         return "DefaultRole[id=" + this.getId() + "]";
128     }
129     
130     /**
131      * Returns a hash code value for the object.
132      * @see java.lang.Object#hashCode()
133      */

134     public int hashCode(){
135        return role_id_.hashCode();
136     }
137 }
138
Popular Tags