KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > lenya > cms > ac > usecase > UsecaseRoles


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */

17
18 /* $Id: UsecaseRoles.java 42616 2004-03-03 12:56:33Z gregor $ */
19
20 package org.apache.lenya.cms.ac.usecase;
21
22 import java.util.HashMap JavaDoc;
23 import java.util.Map JavaDoc;
24
25 public class UsecaseRoles {
26     
27     private Map JavaDoc usecaseToRoles = new HashMap JavaDoc();
28     
29     /**
30      * Ctor.
31      */

32     public UsecaseRoles() {
33     }
34     
35     /**
36      * Sets the roles for a usecase.
37      * @param usecaseId The usecase ID.
38      * @param roleIds The role IDs.
39      */

40     public void setRoles(String JavaDoc usecaseId, String JavaDoc[] roleIds) {
41         usecaseToRoles.put(usecaseId, roleIds);
42     }
43     
44     /**
45      * Returns the roles for a usecase.
46      * If no roles are defined for this usecase, an array of size 0 is returned.
47      * @param usecaseId The usecase ID.
48      * @return A role array.
49      */

50     public String JavaDoc[] getRoles(String JavaDoc usecaseId) {
51         String JavaDoc[] usecaseRoles;
52         if (usecaseToRoles.containsKey(usecaseId)) {
53             usecaseRoles = (String JavaDoc[]) usecaseToRoles.get(usecaseId);
54         } else {
55             usecaseRoles = new String JavaDoc[0];
56         }
57         return usecaseRoles;
58     }
59     
60     /**
61      * Checks if a usecase has roles.
62      * @param usecaseId The usecase ID.
63      * @return A boolean value.
64      */

65     public boolean hasRoles(String JavaDoc usecaseId) {
66         return usecaseToRoles.containsKey(usecaseId);
67     }
68
69 }
70
Popular Tags