KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > ivata > groupware > business > addressbook > person > group > right > UserRightFilter


1 /*
2  * Copyright (c) 2001 - 2005 ivata limited.
3  * All rights reserved.
4  * -----------------------------------------------------------------------------
5  * ivata groupware may be redistributed under the GNU General Public
6  * License as published by the Free Software Foundation;
7  * version 2 of the License.
8  *
9  * These programs are free software; you can redistribute them and/or
10  * modify them under the terms of the GNU General Public License
11  * as published by the Free Software Foundation; version 2 of the License.
12  *
13  * These programs are distributed in the hope that they will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16  *
17  * See the GNU General Public License in the file LICENSE.txt for more
18  * details.
19  *
20  * If you would like a copy of the GNU General Public License write to
21  *
22  * Free Software Foundation, Inc.
23  * 59 Temple Place - Suite 330
24  * Boston, MA 02111-1307, USA.
25  *
26  *
27  * To arrange commercial support and licensing, contact ivata at
28  * http://www.ivata.com/contact.jsp
29  * -----------------------------------------------------------------------------
30  * $Log: UserRightFilter.java,v $
31  * Revision 1.2 2005/04/09 17:19:07 colinmacleod
32  * Changed copyright text to GPL v2 explicitly.
33  *
34  * Revision 1.1.1.1 2005/03/10 17:50:35 colinmacleod
35  * Restructured ivata op around Hibernate/PicoContainer.
36  * Renamed ivata groupware.
37  *
38  * Revision 1.4 2004/07/13 19:41:14 colinmacleod
39  * Moved project to POJOs from EJBs.
40  * Applied PicoContainer to services layer (replacing session EJBs).
41  * Applied Hibernate to persistence layer (replacing entity EJBs).
42  *
43  * Revision 1.3 2004/03/21 21:16:06 colinmacleod
44  * Shortened name to ivata op.
45  *
46  * Revision 1.2 2004/02/01 22:00:32 colinmacleod
47  * Added full names to author tags
48  *
49  * Revision 1.1.1.1 2004/01/27 20:57:51 colinmacleod
50  * Moved ivata openportal to SourceForge..
51  *
52  * Revision 1.3 2003/10/17 12:36:12 jano
53  * fixing problems with building
54  * converting intranet -> portal
55  * Eclipse building
56  *
57  * Revision 1.2 2003/10/15 13:18:02 colin
58  * fixing for XDoclet
59  *
60  * Revision 1.1 2003/02/24 19:09:21 colin
61  * moved to business
62  *
63  * Revision 1.4 2003/02/04 17:43:45 colin
64  * copyright notice
65  *
66  * Revision 1.3 2002/06/21 12:48:58 colin
67  * restructured com.ivata.groupware.web
68  *
69  * Revision 1.2 2002/06/17 07:28:44 colin
70  * improved and extended javadoc documentation
71  *
72  * Revision 1.1 2002/06/13 11:21:24 colin
73  * first version with rose model integration.
74  * -----------------------------------------------------------------------------
75  */

76 package com.ivata.groupware.business.addressbook.person.group.right;
77
78
79 import java.io.IOException JavaDoc;
80 import java.io.ObjectInputStream JavaDoc;
81 import java.io.ObjectOutputStream JavaDoc;
82 import java.io.Serializable JavaDoc;
83
84
85 /**
86  * <p>Some classes access the system on the basis of user rights, and use this
87  * class to filter the results according to the parameters given</p>
88  *
89  * <p>The parameters here are the same as for
90  * {@link RightLocalHome#findTargetIdByUserNameAccessDetail
91  * RightLocalHome.findTargetIdByUserNameAccessDetail}.</p>
92  *
93  * @since 2002-05-19
94  * @author Colin MacLeod
95  * <a HREF='mailto:colin.macleod@ivata.com'>colin.macleod@ivata.com</a>
96  * @see RightLocalHome#findTargetIdByUserNameAccessDetail
97  * @version $Revision: 1.2 $
98  */

99 public class UserRightFilter implements Serializable JavaDoc {
100
101     /**
102      * <p>Default constructor.</p>
103      */

104     public UserRightFilter() {
105         super();
106     }
107
108     /**
109      * <p>Construct a user right filter from all its fields.</p>
110      *
111      * @param userName the user to filter results for. See {@link #setUserName
112      * setUserName}.
113      * @param access the access type. See {@link #setAccess setAccess}.
114      * @param detail the specific user right you want to filter against. See
115      * {@link #setDetail setDetail}.
116      */

117     public UserRightFilter(String JavaDoc userName, Integer JavaDoc access,
118         Integer JavaDoc detail) {
119         setUserName(userName);
120         setAccess(access);
121         setDetail(detail);
122     }
123
124     /**
125      * <p>Stores the name of the user for whom the results will be filtered.</p>
126      */

127     private String JavaDoc userName = null;
128
129     /**
130      * <p>Stores the access type. This parameter should be set to one of the 'ACCESS_...'
131      * constants in {@link RightConstants RightConstants}.</p>
132      *
133      * @see RightConstants
134      */

135     private Integer JavaDoc access = null;
136
137     /**
138      * <p>Get the access type. This parameter should be set to one of the 'ACCESS_...'
139      * constants in {@link RightConstants RightConstants}.</p>
140      *
141      * @return the access type.
142      * @see RightConstants
143      */

144     private Integer JavaDoc detail = null;
145
146     /**
147      * <p>Get the access type. This parameter should be set to one of the 'ACCESS_...'
148      * constants in {@link RightConstants RightConstants}.</p>
149      *
150      * @return the value of the access type.
151      * @see RightConstants
152      */

153     public final Integer JavaDoc getAccess() {
154         return access;
155     }
156
157     /**
158      * <p>Get the detail of the user right being checked. This parameter should
159      * be set to one of the 'DETAIL_...' constants in
160      * {@link RightConstants RightConstants}.</p>
161      *
162      * @return the user right detail.
163      * @see RightConstants
164      */

165     public final Integer JavaDoc getDetail() {
166         return detail;
167     }
168
169     /**
170      * <p>Get the name of the user for whom the results will be filtered.</p>
171      *
172      * @return the name of the user for whom the results will be filtered.
173      */

174     public final String JavaDoc getUserName() {
175         return userName;
176     }
177
178     /**
179      * <p>Set the access type. This parameter should be set to one of the 'ACCESS_...'
180      * constants in {@link RightConstants RightConstants}.</p>
181      *
182      * @param access the new value of the access type.
183      * @see RightConstants
184      */

185     public final void setAccess(final Integer JavaDoc access) {
186         this.access = access;
187     }
188
189     /**
190      * <p>Set the detail of the user right being checked. This parameter should
191      * be set to one of the 'DETAIL_...' constants in
192      * {@link RightConstants RightConstants}.</p>
193      *
194      * @param detail the new value of the user right detail.
195      * @see RightConstants
196      */

197     public final void setDetail(final Integer JavaDoc detail) {
198         this.detail = detail;
199     }
200
201     /**
202      * <p>Set the name of the user for whom the results will be filtered.</p>
203      *
204      * @param userName new name for the user for whom the results will
205      * be filtered.
206      */

207     public final void setUserName(final String JavaDoc userName) {
208         this.userName = userName;
209     }
210
211     /**
212      * <p>Serialize the object to the output stream provided.</p>
213      *
214      * @exception IOException thrown by
215      * <code>ObjectOutputStream.defaultWriteObject( )</code>
216      * @param oos the output stream to serialize the object to
217      */

218     private void writeObject(final ObjectOutputStream JavaDoc oos) throws IOException JavaDoc {
219         oos.defaultWriteObject();
220     }
221
222     /**
223      * <p>Serialize the object from the input stream provided.</p>
224      *
225      * @exception ClassNotFoundException thrown by
226      * <code>ObjectInputStream.defaultReadObject</code>.
227      * @exception IOException thrown by
228      * <code>ObjectInputStream.defaultReadObject</code>.
229      * @param ois the input stream to serialize the object from
230      */

231     private void readObject(final ObjectInputStream JavaDoc ois) throws ClassNotFoundException JavaDoc, IOException JavaDoc {
232         ois.defaultReadObject();
233     }
234
235     /**
236      * <p>Comparison method. See if the object supplied is a user right filter and,
237      * if so, whether or not its contents are the same as this one.</p>
238      *
239      * @param compare the object to compare with this one.
240      * @return <code>true</code> if the filter supplied in <code>compare</code>
241      * is effectively the same as this one, otherwise false.
242      */

243     public boolean equals(final Object JavaDoc compare) {
244         // first check it is non-null and the class is right
245
if ((compare == null) ||
246             !(this.getClass().isInstance(compare))) {
247             return false;
248         }
249         UserRightFilter filter = (UserRightFilter) compare;
250
251         // check that the user names, access and detail are the same for both
252
return (((userName == null) ?
253                     (filter.userName == null) :
254                     userName.equals(filter.userName)) &&
255                 ((access == null) ?
256                     (filter.access == null) :
257                     access.equals(filter.access)) &&
258                 ((detail == null) ?
259                     (filter.detail == null) :
260                     detail.equals(filter.detail)));
261     }
262 }
263
Popular Tags