KickJava   Java API By Example, From Geeks To Geeks.

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


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 PermissionObject implements Serializable JavaDoc {
29
30     /**
31      *
32      */

33     private static final long serialVersionUID = 2314370572011936088L;
34
35     /**
36      * Field <code>USER</code>
37      */

38     public static final int USER = 1;
39
40     /**
41      * Field <code>GROUP</code>
42      */

43     public static final int GROUP = 2;
44
45     /**
46      * Field <code>FORUM</code>
47      */

48     public static final int FORUM = 3;
49
50     /**
51      * Field <code>TOPIC</code>
52      */

53     public static final int TOPIC = 4;
54
55     /**
56      * Field <code>MESSAGE</code>
57      */

58     public static final int MESSAGE = 5;
59
60     /**
61      * Field <code>SYSTEM</code>
62      */

63     public static final int SYSTEM = 6;
64
65     /**
66      * Field <code>ATTACH</code>
67      */

68     public static final int ATTACH = 7;
69
70     /**
71      * Represents access to all objects if used in permission points set and
72      * present not applicable attribute if used as protection point
73      */

74     public static final PermissionObject ALL_OBJECTS = new PermissionObject(
75             PermissionPoint.ALL);
76
77     private int id;
78
79     /**
80      * @param id
81      */

82     public PermissionObject(int id) {
83         super();
84         this.id = id;
85     }
86
87     private String JavaDoc name;
88
89     /**
90      * @param id
91      * @param name
92      */

93     public PermissionObject(int id, String JavaDoc name) {
94         super();
95         this.id = id;
96         this.name = name;
97     }
98
99     /**
100      * @return a hash code value for this object.
101      * @see Object#equals(Object)
102      * @see Hashtable
103      */

104     public int hashCode() {
105         return id;
106     }
107
108     /**
109      * @param obj
110      * the reference object with which to compare.
111      * @return <code>true</code> if this object is the same as the obj
112      * argument; <code>false</code> otherwise.
113      * @see Boolean#hashCode()
114      * @see Hashtable
115      */

116     public boolean equals(Object JavaDoc obj) {
117         if (obj instanceof PermissionObject) {
118             return id == ((PermissionObject) obj).id
119                     || id == PermissionPoint.ALL
120                     || ((PermissionObject) obj).id == PermissionPoint.ALL;
121         }
122         return false;
123     }
124 }
Popular Tags