KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > webdav > lib > Privilege


1 /*
2  * $Header: /home/cvs/jakarta-slide/webdavclient/clientlib/src/java/org/apache/webdav/lib/Privilege.java,v 1.3 2004/07/28 09:31:40 ib Exp $
3  * $Revision: 1.3 $
4  * $Date: 2004/07/28 09:31:40 $
5  *
6  * ====================================================================
7  *
8  * Copyright 1999-2002 The Apache Software Foundation
9  *
10  * Licensed under the Apache License, Version 2.0 (the "License");
11  * you may not use this file except in compliance with the License.
12  * You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS,
18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  *
22  */

23
24 package org.apache.webdav.lib;
25
26
27
28 /**
29  * This interface models a DAV ACE privilege.
30  *
31  * @version $Revision: 1.3 $
32  */

33 public class Privilege {
34
35
36     // -------------------------------------------------------------- Constants
37

38
39     // Standard WebDAV ACP privileges
40
public static final Privilege ALL =
41         new Privilege(Constants.DAV, "all", null);
42     public static final Privilege READ =
43         new Privilege(Constants.DAV, "read", null);
44     public static final Privilege WRITE =
45         new Privilege(Constants.DAV, "write", null);
46     public static final Privilege READ_ACL =
47         new Privilege(Constants.DAV, "read-acl", null);
48     public static final Privilege WRITE_ACL =
49         new Privilege(Constants.DAV, "write-acl", null);
50
51     // TODO: Add the Slide specific privileges ?
52

53
54     // ----------------------------------------------------------- Constructors
55

56
57     public Privilege(String JavaDoc namespace, String JavaDoc name, String JavaDoc parameter) {
58         this.namespace = namespace;
59         this.name = name;
60         this.parameter = parameter;
61     }
62
63
64     // ----------------------------------------------------- Instance Variables
65

66
67     /**
68      * Custom privilege namespace.
69      */

70     protected String JavaDoc namespace;
71
72
73     /**
74      * Custom privilege element name.
75      */

76     protected String JavaDoc name;
77
78
79     /**
80      * Additional parameter (usually, an URI).
81      */

82     protected String JavaDoc parameter;
83
84
85     // ------------------------------------------------------------- Properties
86

87
88     /**
89      * Namespace accessor.
90      */

91     public String JavaDoc getNamespace() {
92         return namespace;
93     }
94
95
96     /**
97      * Name accessor.
98      */

99     public String JavaDoc getName() {
100         return name;
101     }
102
103
104     /**
105      * Parameter accessor.
106      */

107     public String JavaDoc getParameter() {
108         return parameter;
109     }
110
111
112     // --------------------------------------------------------- Public Methods
113

114
115     /**
116      * Equals.
117      */

118     public boolean equals(Object JavaDoc obj) {
119         if ((obj == null) || !(obj instanceof Privilege)) {
120             return false;
121         } else {
122             if (this == obj)
123                 return true;
124             Privilege privilege = (Privilege) obj;
125             if ((namespace.equals(privilege.getNamespace()))
126                 && (name.equals(privilege.getName()))) {
127                 if (parameter == null) {
128                     if (privilege.getParameter() == null)
129                         return true;
130                 } else {
131                     if (privilege.getParameter() != null)
132                         return (parameter.equals(privilege.getParameter()));
133                 }
134             }
135         }
136         return false;
137     }
138
139
140 }
141
Popular Tags