001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: package org.apache.jetspeed.om.servlet.impl;
018:
019: import java.io.Serializable;
020:
021: import org.apache.jetspeed.om.common.servlet.MutableSecurityRole;
022: import org.apache.pluto.om.common.SecurityRole;
023:
024: /**
025: * MutableSecurityRoleImpl
026: *
027: * @author <a href="mailto:ate@douma.nu">Ate Douma </a>
028: * @version $Id: SecurityRoleImpl.java 516881 2007-03-11 10:34:21Z ate $
029: */
030: public class SecurityRoleImpl implements SecurityRole,
031: MutableSecurityRole, Serializable {
032:
033: protected long webAppId;
034:
035: private String description;
036:
037: private String roleName;
038:
039: /**
040: * Default constructor.
041: */
042: public SecurityRoleImpl() {
043: }
044:
045: /**
046: * @see org.apache.pluto.om.common.SecurityRole#getDescription()
047: */
048: public String getDescription() {
049: return description;
050: }
051:
052: /**
053: * @see org.apache.pluto.om.common.SecurityRole#getRoleName()
054: */
055: public String getRoleName() {
056: return roleName;
057: }
058:
059: /**
060: * @see org.apache.jetspeed.om.common.servlet.MutableSecurityRole#setDescription(java.lang.String)
061: */
062: public void setDescription(String description) {
063: this .description = description;
064: }
065:
066: /**
067: * @see org.apache.jetspeed.om.common.servlet.MutableSecurityRole#setRoleName(java.lang.String)
068: */
069: public void setRoleName(String roleName) {
070: this .roleName = roleName;
071: }
072:
073: /**
074: * Convert {@link SecurityRole}to String.
075: *
076: * @return String value of SecurityRole.
077: */
078: public String toString() {
079: String securityRole = "[[roleName, " + this .roleName
080: + "], [description, " + this .description + "]]";
081: return securityRole;
082: }
083:
084: /**
085: * @see java.lang.Object#equals(java.lang.Object)
086: */
087: public boolean equals(Object obj) {
088: if (obj != null && obj instanceof SecurityRoleImpl) {
089: //TODO: Because of a bug in OJB 1.0.rc4 fields seems not have been set
090: // before this object is put into a HashMap.
091: // Therefore, for the time being, check against null values is
092: // required.
093: // Once 1.0rc5 or higher can be used the following line should be
094: // used again.
095: //return getRoleName().equals(((SecurityRoleImpl)obj).getRoleName());
096: return getRoleName() != null
097: && getRoleName().equals(
098: ((SecurityRoleImpl) obj).getRoleName());
099: }
100: return false;
101: }
102:
103: /**
104: * @see java.lang.Object#hashCode()
105: */
106: public int hashCode() {
107: //TODO: Because of a bug in OJB 1.0.rc4 fields seems not have been set
108: // before this object is put into a HashMap.
109: // Therefore, for the time being, check against null values is
110: // required.
111: // Once 1.0rc5 or higher can be used the following line should be
112: // used again.
113: //return getRoleName().hashCode();
114: return getRoleName() != null ? getRoleName().hashCode() : 0;
115: }
116: }
|