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 Depth implements XMLRenderer {
28
29
30
31
32
33
34 public static final Depth[] DEPTHS = new Depth[]{
35 new Depth(org.abstracthorizon.danube.webdav.util.Depth.ZERO),
36 new Depth(org.abstracthorizon.danube.webdav.util.Depth.ONE),
37 new Depth(org.abstracthorizon.danube.webdav.util.Depth.INFINITY)
38 };
39
40
41 public static final String TAG_NAME = "depth";
42
43
44 protected int depth;
45
46
47
48
49
50 public Depth(int depth) {
51 this.depth = depth;
52 }
53
54
55
56
57
58 public int getDepth() {
59 return depth;
60 }
61
62 @Override
63 public String toString() {
64 return "Depth[" + org.abstracthorizon.danube.webdav.util.Depth.toString(depth) + "]";
65 }
66
67
68
69
70
71
72 public void render(PrintWriter writer, NamespacesProvider provider) {
73 if (depth == org.abstracthorizon.danube.webdav.util.Depth.INFINITY) {
74 writer.println(XMLUtils.createTag(provider, DAVNamespace.DAV_NAMESPACE_URL, TAG_NAME, "Infinity"));
75 } else if (depth == org.abstracthorizon.danube.webdav.util.Depth.ONE) {
76 writer.println(XMLUtils.createTag(provider, DAVNamespace.DAV_NAMESPACE_URL, TAG_NAME, "1"));
77 } else if (depth == org.abstracthorizon.danube.webdav.util.Depth.ZERO) {
78 writer.println(XMLUtils.createTag(provider, DAVNamespace.DAV_NAMESPACE_URL, TAG_NAME, "0"));
79 } else {
80 writer.println(XMLUtils.createTag(provider, DAVNamespace.DAV_NAMESPACE_URL, TAG_NAME, null));
81 }
82 }
83
84 }