KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > webdav > lib > properties > CurrentUserPrivilegeSetProperty


1 /*
2  * $Header: /home/cvs/jakarta-slide/webdavclient/clientlib/src/java/org/apache/webdav/lib/properties/CurrentUserPrivilegeSetProperty.java,v 1.4 2004/08/02 15:45:50 unico Exp $
3  * $Revision: 1.4 $
4  * $Date: 2004/08/02 15:45:50 $
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 package org.apache.webdav.lib.properties;
24
25 import org.apache.webdav.lib.BaseProperty;
26 import org.apache.webdav.lib.ResponseEntity;
27 import org.apache.webdav.lib.util.DOMUtils;
28 import org.w3c.dom.Element JavaDoc;
29 import org.w3c.dom.NodeList JavaDoc;
30
31 /**
32  * Title: CurrentUserPrivilegeSetProperty.java
33  * Description:
34  * Company: SpeedLegal Holdings Inc.
35  * @version 1.0
36  */

37
38
39 public class CurrentUserPrivilegeSetProperty extends BaseProperty {
40
41
42     // -------------------------------------------------------------- Constants
43

44
45     /**
46      * The property name.
47      */

48     public static final String JavaDoc TAG_NAME = "current-user-privilege-set";
49
50
51     // ----------------------------------------------------------- Constructors
52

53
54     /**
55      * Default constructor for the property.
56      */

57     public CurrentUserPrivilegeSetProperty
58         (ResponseEntity response, Element JavaDoc element) {
59         super(response, element);
60     }
61
62
63     // --------------------------------------------------------- Public Methods
64

65
66     public boolean hasReadAccess() {
67         NodeList JavaDoc readPrivilege = DOMUtils.getElementsByTagNameNS(getElement(), "read", "DAV:");
68         return (readPrivilege.getLength() == 1);
69     }
70
71     public boolean hasWriteAccess() {
72         NodeList JavaDoc writePrivilege = DOMUtils.getElementsByTagNameNS(getElement(), "write", "DAV:");
73
74         return (writePrivilege.getLength() == 1);
75     }
76
77     public boolean hasReadWriteAccess() {
78         return (hasReadAccess() && hasWriteAccess());
79     }
80
81
82     public String JavaDoc getPropertyAsString() {
83         String JavaDoc theResult="";
84         theResult = (hasReadAccess()) ? "Read" : theResult;
85         theResult = (hasWriteAccess()) ? theResult+" Write" : theResult;
86         return theResult.trim();
87     }
88 }
89
90
91
92
93
Popular Tags