1
2
3
4
5
6
7
8
9
10
11
12
13 package org.abstracthorizon.danube.webdav.xml.dav.response;
14
15 import org.abstracthorizon.danube.webdav.util.NamespacesProvider;
16 import org.abstracthorizon.danube.webdav.xml.XMLRenderer;
17 import org.abstracthorizon.danube.webdav.xml.common.XMLUtils;
18 import org.abstracthorizon.danube.webdav.xml.dav.DAVNamespace;
19
20 import java.io.PrintWriter;
21
22
23
24
25
26
27 public class LockScope implements XMLRenderer {
28
29
30 public static final String TAG_NAME = "lockscope";
31
32
33 public static final LockScope EXCLUSIVE = new LockScope(true);
34
35
36 public static final LockScope SHARED = new LockScope(false);
37
38
39 protected boolean exclusive = false;
40
41
42
43
44
45 public LockScope(boolean exclusive) {
46 this.exclusive = exclusive;
47 }
48
49 @Override
50 public String toString() {
51 if (exclusive) {
52 return "LockScope[exclusive]";
53 } else {
54 return "LockScope[shared]";
55 }
56 }
57
58
59
60
61
62
63 public void render(PrintWriter writer, NamespacesProvider provider) {
64 writer.print(XMLUtils.createStartTag(provider, DAVNamespace.DAV_NAMESPACE_URL, TAG_NAME));
65 if (exclusive) {
66 writer.print(XMLUtils.createTag(provider, DAVNamespace.DAV_NAMESPACE_URL, "exclusive", null));
67 } else {
68 writer.print(XMLUtils.createTag(provider, DAVNamespace.DAV_NAMESPACE_URL, "shared", null));
69 }
70 writer.println(XMLUtils.createEndTag(provider, DAVNamespace.DAV_NAMESPACE_URL, TAG_NAME));
71 }
72
73 }