KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > speedo > pobjects > cap > JDORole


1 /*
2  * Created on 29 oct. 2004
3  */

4 package org.objectweb.speedo.pobjects.cap;
5
6 import java.util.Collection JavaDoc;
7
8 /**
9  * @author mhoudu
10  */

11 public class JDORole {
12
13     /** the role identifier */
14     private int id;
15     
16     /** the role label */
17     private String JavaDoc label;
18     
19     /** the role scopes */
20     private Collection JavaDoc scopes;
21     
22     /** the role actions type JDORoleHasAction*/
23     private Collection JavaDoc actions;
24     
25     /**
26      * Default constructor.
27      * @param id The role identifier.
28      * @param label The role label.
29      * @param scopes The role scopes.
30      * @param actions The role actions.
31      */

32     public JDORole(
33             int id,
34             String JavaDoc label,
35             Collection JavaDoc scopes,
36             Collection JavaDoc actions)
37     {
38         this.id = id;
39         this.label = label;
40         this.scopes = scopes;
41         this.actions = actions;
42     }
43
44     /**
45      * Adds an action to the role.
46      * @param action The action to add.
47      * @param isDisplayedInMenu The flag which indicates if the action has to be displayed in the menu or not.
48      * @param displayOrder The isplay order.
49      */

50     public void addAction(
51             JDOAction action,
52             boolean isDisplayedInMenu,
53             int displayOrder)
54     {
55         JDORoleHasAction action4role = new JDORoleHasAction(this, action, isDisplayedInMenu, displayOrder);
56         actions.add(action4role);
57     }
58     
59     /**
60      * Tells if this role has the specified scope.
61      * @param scope the scope to check.
62      * @return <tt>true</tt> if this role has the specified scope,
63      * <tt>false</tt> otherwise.
64      */

65     public boolean hasScope(JDOScope scope)
66     {
67         return scopes.contains(scope);
68     }
69
70     /**
71      * Tells if this role has the specified action.
72      * @param action the action to check.
73      * @return <tt>true</tt> if this role has the specified action,
74      * <tt>false</tt> otherwise.
75      */

76     public boolean hasAction(JDOAction action)
77     {
78         return actions.contains(action);
79     }
80
81     /**
82      * Gets the id.
83      * @return Returns the id.
84      */

85     public int getId()
86     {
87         return id;
88     }
89     
90     /**
91      * Sets the id.
92      * @param id The id to set.
93      */

94     public void setId(int id)
95     {
96         this.id = id;
97     }
98     
99     /**
100      * Gets the label.
101      * @return Returns the label.
102      */

103     public String JavaDoc getLabel()
104     {
105         return label;
106     }
107     
108     /**
109      * Sets the label.
110      * @param label The label to set.
111      */

112     public void setLabel(String JavaDoc label)
113     {
114         this.label = label;
115     }
116     
117     /**
118      * Gets the scopes.
119      * @return Returns the scopes.
120      */

121     public Collection JavaDoc getScopes()
122     {
123         return scopes;
124     }
125     
126     /**
127      * Sets the scopes.
128      * @param scopes The scope to set.
129      */

130     public void setScopes(Collection JavaDoc scopes)
131     {
132         this.scopes = scopes;
133     }
134
135     /**
136      * Gets the actions.
137      * @return Returns the actions.
138      */

139     public Collection JavaDoc getActions()
140     {
141         return actions;
142     }
143     
144     /**
145      * Sets the actions.
146      * @param actions The actions to set.
147      */

148     public void setActions(Collection JavaDoc actions)
149     {
150         this.actions = actions;
151     }
152    
153 }
Popular Tags