View Javadoc

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  package org.apache.jetspeed.om.servlet.impl;
18  
19  import java.io.Serializable;
20  
21  import org.apache.jetspeed.om.common.servlet.MutableSecurityRole;
22  import org.apache.pluto.om.common.SecurityRole;
23  
24  /***
25   * MutableSecurityRoleImpl
26   *
27   * @author <a href="mailto:ate@douma.nu">Ate Douma </a>
28   * @version $Id: SecurityRoleImpl.java 516881 2007-03-11 10:34:21Z ate $
29   */
30  public class SecurityRoleImpl implements SecurityRole, MutableSecurityRole, Serializable {
31  
32      protected long webAppId;
33  
34      private String description;
35  
36      private String roleName;
37  
38      /***
39       * Default constructor.
40       */
41      public SecurityRoleImpl() {
42      }
43  
44      /***
45       * @see org.apache.pluto.om.common.SecurityRole#getDescription()
46       */
47      public String getDescription() {
48          return description;
49      }
50  
51      /***
52       * @see org.apache.pluto.om.common.SecurityRole#getRoleName()
53       */
54      public String getRoleName() {
55          return roleName;
56      }
57  
58      /***
59       * @see org.apache.jetspeed.om.common.servlet.MutableSecurityRole#setDescription(java.lang.String)
60       */
61      public void setDescription(String description) {
62          this.description = description;
63      }
64  
65      /***
66       * @see org.apache.jetspeed.om.common.servlet.MutableSecurityRole#setRoleName(java.lang.String)
67       */
68      public void setRoleName(String roleName) {
69          this.roleName = roleName;
70      }
71  
72      /***
73       * Convert {@link SecurityRole}to String.
74       *
75       * @return String value of SecurityRole.
76       */
77      public String toString() {
78          String securityRole = "[[roleName, " + this.roleName + "], [description, " + this.description + "]]";
79          return securityRole;
80      }
81      
82      /***
83       * @see java.lang.Object#equals(java.lang.Object)
84       */
85      public boolean equals(Object obj) {
86          if ( obj != null && obj instanceof SecurityRoleImpl ) {
87              //TODO: Because of a bug in OJB 1.0.rc4 fields seems not have been set
88              //      before this object is put into a HashMap.
89              //      Therefore, for the time being, check against null values is
90              //      required.
91              //      Once 1.0rc5 or higher can be used the following line should be
92              //      used again.
93              //return getRoleName().equals(((SecurityRoleImpl)obj).getRoleName());
94              return getRoleName() != null && getRoleName().equals(((SecurityRoleImpl)obj).getRoleName());
95          }
96          return false;
97      }
98  
99      /*** 
100      * @see java.lang.Object#hashCode()
101      */
102     public int hashCode() {
103         //TODO: Because of a bug in OJB 1.0.rc4 fields seems not have been set
104         //      before this object is put into a HashMap.
105         //      Therefore, for the time being, check against null values is
106         //      required.
107         //      Once 1.0rc5 or higher can be used the following line should be
108         //      used again.
109         //return getRoleName().hashCode();
110         return getRoleName() != null ? getRoleName().hashCode() : 0;
111     }
112 }