KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > catalina > users > MemoryRole


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

17
18
19 package org.apache.catalina.users;
20
21
22 import org.apache.catalina.UserDatabase;
23
24
25 /**
26  * <p>Concrete implementation of {@link org.apache.catalina.Role} for the
27  * {@link MemoryUserDatabase} implementation of {@link UserDatabase}.</p>
28  *
29  * @author Craig R. McClanahan
30  * @version $Revision: 467222 $ $Date: 2006-10-24 05:17:11 +0200 (mar., 24 oct. 2006) $
31  * @since 4.1
32  */

33
34 public class MemoryRole extends AbstractRole {
35
36
37     // ----------------------------------------------------------- Constructors
38

39
40     /**
41      * Package-private constructor used by the factory method in
42      * {@link MemoryUserDatabase}.
43      *
44      * @param database The {@link MemoryUserDatabase} that owns this role
45      * @param rolename Role name of this role
46      * @param description Description of this role
47      */

48     MemoryRole(MemoryUserDatabase database,
49                String JavaDoc rolename, String JavaDoc description) {
50
51         super();
52         this.database = database;
53         setRolename(rolename);
54         setDescription(description);
55
56     }
57
58
59     // ----------------------------------------------------- Instance Variables
60

61
62     /**
63      * The {@link MemoryUserDatabase} that owns this role.
64      */

65     protected MemoryUserDatabase database = null;
66
67
68     // ------------------------------------------------------------- Properties
69

70
71     /**
72      * Return the {@link UserDatabase} within which this role is defined.
73      */

74     public UserDatabase getUserDatabase() {
75
76         return (this.database);
77
78     }
79
80
81     // --------------------------------------------------------- Public Methods
82

83
84     /**
85      * <p>Return a String representation of this role in XML format.</p>
86      */

87     public String JavaDoc toString() {
88
89         StringBuffer JavaDoc sb = new StringBuffer JavaDoc("<role rolename=\"");
90         sb.append(rolename);
91         sb.append("\"");
92         if (description != null) {
93             sb.append(" description=\"");
94             sb.append(description);
95             sb.append("\"");
96         }
97         sb.append("/>");
98         return (sb.toString());
99
100     }
101
102
103 }
104
Popular Tags