KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > outerj > daisy > repository > acl > AclPermission


1 /*
2  * Copyright 2004 Outerthought bvba and Schaubroeck nv
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not 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.
15  */

16 package org.outerj.daisy.repository.acl;
17
18 /**
19  * Enumeration of all available ACL Permissions.
20  */

21 public final class AclPermission {
22     private String JavaDoc name;
23     private int pos;
24
25     private AclPermission(String JavaDoc name, int pos) {
26         this.name = name;
27         this.pos = pos;
28     }
29
30     /**
31      * Returns a number corresponding to the position in the {@link #ENUM} array.
32      */

33     public int getPos() {
34         return pos;
35     }
36
37     public String JavaDoc toString() {
38         return name;
39     }
40
41     public static AclPermission fromString(String JavaDoc value) {
42         if (value.equals("read"))
43             return AclPermission.READ;
44         else if (value.equals("readLive"))
45             return AclPermission.READ_LIVE;
46         else if (value.equals("write"))
47             return AclPermission.WRITE;
48         else if (value.equals("publish"))
49             return AclPermission.PUBLISH;
50         else if (value.equals("delete"))
51             return AclPermission.DELETE;
52         else
53             throw new RuntimeException JavaDoc("Unrecognized ACL permission: " + value);
54     }
55
56     public static final AclPermission READ_LIVE = new AclPermission("readLive", 0);
57     public static final AclPermission READ = new AclPermission("read", 1);
58     public static final AclPermission WRITE = new AclPermission("write", 2);
59     public static final AclPermission PUBLISH = new AclPermission("publish", 3);
60     public static final AclPermission DELETE = new AclPermission("delete", 4);
61
62     public static final AclPermission[] ENUM = {READ_LIVE, READ, WRITE, PUBLISH, DELETE};
63 }
64
Popular Tags