1 /***
2 * AccessType.java
3 *
4 * This file is part of the creme library.
5 * The creme library intends to ease the development effort of large
6 * applications by providing easy to use support classes.
7 *
8 * Copyright (C) 2003 Denis Bregeon
9 *
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or (at your option) any later version.
14 *
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 *
24 * contact information: dbregeon@sourceforge.net
25 */
26 package org.jcreme.permissioning;
27
28 import java.util.Hashtable;
29
30 import org.jcreme.enumerations.Enumeration;
31
32 /***
33 * This enumeration represent the functional domains of an organization.
34 * Permissions to access certain data types are based on Domains. This ensures
35 * that the some business Domains have no access to some data if needed.
36 *
37 * @author $Author: dbregeon $
38 * @version $Revision: 1.1 $
39 */
40 public class AccessType extends Enumeration {
41 protected static final Hashtable fromName = new Hashtable();
42
43 /***
44 * The name of the READ access type.
45 */
46 public static final String S_READ = "read";
47
48 /***
49 * Represents access for reading data.
50 */
51 public static final AccessType READ = new AccessType(S_READ);
52
53 /***
54 * The name of the WRITE access type.
55 */
56 public static final String S_WRITE = "write";
57
58 /***
59 * Represents access for writing data.
60 */
61 public static final AccessType WRITE = new AccessType(S_WRITE);
62
63 /***
64 * The name of the DELETE access type.
65 */
66 public static final String S_DELETE = "delete";
67
68 /***
69 * Represents access for deleting data.
70 */
71 public static final AccessType DELETE = new AccessType(S_DELETE);
72
73 /***
74 * The name of the CREATE access type.
75 */
76 public static final String S_CREATE = "create";
77
78 /***
79 * Represents access for creating data.
80 */
81 public static final AccessType CREATE = new AccessType(S_CREATE);
82
83 protected AccessType(String name) {
84 super(name);
85 }
86
87
88
89
90
91
92 protected Hashtable getFromName() {
93 return fromName;
94 }
95
96 /***
97 *
98 * @param name
99 * @return the AccessType associated to name.
100 */
101 public static AccessType getAccessType(String name) {
102 AccessType result = null;
103 if (name != null) {
104 result = (AccessType) fromName.get(name);
105 }
106 return result;
107 }
108
109 /***
110 *
111 * @return the list of possible AccessTypes.
112 */
113 public static AccessType[] getAccessTypes() {
114 return (AccessType[]) fromName.values().toArray(new AccessType[0]);
115 }
116
117 /***
118 * @return the instances of this class.
119 */
120 public static Enumeration[] getValues() {
121 return (Enumeration[]) fromName.values().toArray(new Enumeration[0]);
122 }
123
124 }