KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > roller > pojos > RoleData


1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. The ASF licenses this file to You
4 * under the Apache License, Version 2.0 (the "License"); you may not
5 * 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. For additional information regarding
15 * copyright in this work, please see the NOTICE file in the top level
16 * directory of this distribution.
17 */

18
19 package org.apache.roller.pojos;
20
21
22 /**
23  * Role bean.
24  * @author David M Johnson
25  *
26  * @ejb:bean name="RoleData"
27  * @struts.form include-all="true"
28  * @hibernate.class lazy="false" table="userrole"
29  * @hibernate.cache usage="read-write"
30  */

31 public class RoleData
32    extends org.apache.roller.pojos.PersistentObject
33    implements java.io.Serializable JavaDoc
34 {
35    static final long serialVersionUID = -4254083071697970972L;
36
37    private java.lang.String JavaDoc id;
38    private java.lang.String JavaDoc userName;
39    private UserData user;
40    private java.lang.String JavaDoc role;
41
42    public RoleData()
43    {
44    }
45
46    public RoleData(String JavaDoc id, UserData user, String JavaDoc role)
47    {
48       this.id = id;
49       this.userName = user.getUserName();
50       this.user = user;
51       this.role = role;
52    }
53
54    public RoleData( RoleData otherData )
55    {
56        setData(otherData);
57    }
58
59    /**
60     * @ejb:pk-field
61     * @ejb:persistent-field
62     * @hibernate.id column="id"
63     * generator-class="uuid.hex" unsaved-value="null"
64     */

65    public java.lang.String JavaDoc getId()
66    {
67       return this.id;
68    }
69    /** @ejb:persistent-field */
70    public void setId( java.lang.String JavaDoc id )
71    {
72       this.id = id;
73    }
74
75    /**
76     * @ejb:persistent-field
77     * @hibernate.property column="username" non-null="true" unique="false"
78     */

79    public java.lang.String JavaDoc getUserName()
80    {
81       return this.userName;
82    }
83    /** @ejb:persistent-field */
84    public void setUserName( java.lang.String JavaDoc userName )
85    {
86       this.userName = userName;
87    }
88
89    /**
90     * @hibernate.many-to-one column="userid" cascade="none" not-null="true"
91     * @ejb:persistent-field
92     */

93    public UserData getUser()
94    {
95       return this.user;
96    }
97    /** @ejb:persistent-field */
98    public void setUser( UserData user )
99    {
100       this.user = user;
101    }
102
103    /**
104     * @ejb:persistent-field
105     * @hibernate.property column="rolename" non-null="true" unique="false"
106     */

107    public java.lang.String JavaDoc getRole()
108    {
109       return this.role;
110    }
111    /** @ejb:persistent-field */
112    public void setRole( java.lang.String JavaDoc role )
113    {
114       this.role = role;
115    }
116
117    public String JavaDoc toString()
118    {
119       StringBuffer JavaDoc str = new StringBuffer JavaDoc("{");
120
121       str.append("id=" + id + " " + "userName=" + userName + " " + "user=" + user + " " + "role=" + role);
122       str.append('}');
123
124       return(str.toString());
125    }
126
127    public boolean equals( Object JavaDoc pOther )
128    {
129       if( pOther instanceof RoleData )
130       {
131          RoleData lTest = (RoleData) pOther;
132          boolean lEquals = true;
133
134          if( this.userName == null )
135          {
136             lEquals = lEquals && ( lTest.getUserName() == null );
137          }
138          else
139          {
140             lEquals = lEquals && this.userName.equals( lTest.getUserName() );
141          }
142          if( this.user == null )
143          {
144             lEquals = lEquals && ( lTest.getUser() == null );
145          }
146          else
147          {
148             lEquals = lEquals && this.user.equals( lTest.getUser() );
149          }
150          if( this.role == null )
151          {
152             lEquals = lEquals && ( lTest.getRole() == null );
153          }
154          else
155          {
156             lEquals = lEquals && this.role.equals( lTest.getRole() );
157          }
158
159          return lEquals;
160       }
161       else
162       {
163          return false;
164       }
165    }
166
167    public int hashCode()
168    {
169       int result = 17;
170       result = 37*result + ((this.id != null) ? this.id.hashCode() : 0);
171       result = 37*result + ((this.userName != null) ? this.userName.hashCode() : 0);
172       result = 37*result + ((this.user != null) ? this.user.hashCode() : 0);
173       result = 37*result + ((this.role != null) ? this.role.hashCode() : 0);
174       return result;
175       }
176
177    /**
178     * Setter is needed in RollerImpl.storePersistentObject()
179     */

180    public void setData( org.apache.roller.pojos.PersistentObject otherData )
181    {
182
183       this.id = ((RoleData)otherData).getId();
184       this.userName = ((RoleData)otherData).getUserName();
185       this.user = ((RoleData)otherData).getUser();
186       this.role = ((RoleData)otherData).getRole();
187    }
188
189 }
190
Popular Tags