KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jresearch > gossip > am > values > PermissionOperation


1 /*
2  *
3  * ***** BEGIN LICENSE BLOCK ***** The contents of this file are subject to the
4  * Mozilla Public License Version 1.1 (the "License"); you may not use this file
5  * except in compliance with the License. You may obtain a copy of the License
6  * at http://www.mozilla.org/MPL/
7  *
8  * Software distributed under the License is distributed on an "AS IS" basis,
9  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
10  * the specific language governing rights and limitations under the License.
11  *
12  * The Original Code is JGossip forum code.
13  *
14  * The Initial Developer of the Original Code is the JResearch, Org. Portions
15  * created by the Initial Developer are Copyright (C) 2004 the Initial
16  * Developer. All Rights Reserved.
17  *
18  * Contributor(s): Stanislav Spiridonov <stas@jresearch.org>, Dmitry Belov
19  * <bel@jresearch.org>
20  *
21  * ***** END LICENSE BLOCK *****
22  */

23 package org.jresearch.gossip.am.values;
24
25 import java.io.Serializable JavaDoc;
26 import java.util.Hashtable JavaDoc;
27
28 public class PermissionOperation implements Serializable JavaDoc {
29     /**
30      *
31      */

32     private static final long serialVersionUID = -1587895912669011068L;
33
34     /**
35      * Field <code>READ</code>
36      */

37     public static final int READ = 1;
38
39     /**
40      * Field <code>ADD</code>
41      */

42     public static final int ADD = 2;
43
44     /**
45      * Field <code>UPDATE</code>
46      */

47     public static final int UPDATE = 3;
48
49     /**
50      * Field <code>DELETE</code>
51      */

52     public static final int DELETE = 4;
53
54     /**
55      * Field <code>LOCK</code>
56      */

57     public static final int CHANGE_STATUS = 5;
58
59     /**
60      * @author dbelov
61      *
62      */

63     public static class Forum {
64
65         /**
66          * Field <code>SUBSCRIBE</code>
67          */

68         public static final int SUBSCRIBE = 7;
69
70         /**
71          * Field <code>ATTACH_FILE</code>
72          */

73         public static final int MOVE_TOPIC = 8;
74     }
75
76     /**
77      * Represents access to all operations if used in permission points set and
78      * present not applicable attribute if used as protection point
79      */

80     public static final PermissionOperation ALL_OPERATIONS = new PermissionOperation(
81             PermissionPoint.ALL);
82
83     private int id;
84
85     private String JavaDoc name;
86
87     /**
88      * @param id
89      */

90     public PermissionOperation(int id) {
91         super();
92         this.id = id;
93     }
94
95     /**
96      * @param id
97      * @param name
98      */

99     public PermissionOperation(int id, String JavaDoc name) {
100         super();
101         this.id = id;
102         this.name = name;
103     }
104
105     /**
106      * @return a hash code value for this object.
107      * @see Object#equals(Object)
108      * @see Hashtable
109      */

110     public int hashCode() {
111         return id;
112     }
113
114     /**
115      * @param obj
116      * the reference object with which to compare.
117      * @return <code>true</code> if this object is the same as the obj
118      * argument; <code>false</code> otherwise.
119      * @see Boolean#hashCode()
120      * @see Hashtable
121      */

122     public boolean equals(Object JavaDoc obj) {
123         if (obj instanceof PermissionOperation) {
124             return id == ((PermissionOperation) obj).id
125                     || id == PermissionPoint.ALL
126                     || ((PermissionOperation) obj).id == PermissionPoint.ALL;
127         }
128         return false;
129     }
130 }
Popular Tags