KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > portal > tools > model > User


1 /*
2  * Copyright 1999-2005 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 package org.apache.cocoon.portal.tools.model;
17
18 import java.util.ArrayList JavaDoc;
19 import java.util.Iterator JavaDoc;
20
21 /**
22  *
23  * @version CVS $Id: User.java 149055 2005-01-29 18:21:34Z cziegeler $
24  */

25 public class User {
26     
27     private String JavaDoc name;
28     private ArrayList JavaDoc roles = new ArrayList JavaDoc();
29     
30     public User(String JavaDoc name, String JavaDoc role) {
31         this.name = name;
32         this.roles.add(role);
33     }
34     
35     public User(String JavaDoc name, ArrayList JavaDoc roles) {
36         this.name = name;
37         this.roles = roles;
38     }
39
40     public User(String JavaDoc name, String JavaDoc[] roles) {
41         this.name = name;
42         for(int i = 0; i < roles.length; i++) {
43             this.roles.add(roles[i]);
44         }
45     }
46
47     
48     public String JavaDoc getName() {
49         return this.name;
50     }
51     
52     public void setName(String JavaDoc name) {
53         this.name = name;
54     }
55     
56     public ArrayList JavaDoc getRoles() {
57         return this.roles;
58     }
59     
60     public boolean hasRole(String JavaDoc role) {
61         for(Iterator JavaDoc it = roles.iterator(); it.hasNext();) {
62             if(((String JavaDoc) it.next()).equals(role)) {
63                 return true;
64             }
65         }
66         return false;
67     }
68
69 }
70
Popular Tags