1
2
3
4
5
6
7
8
9
10
11
12
13 package org.abstracthorizon.danube.webdav.util;
14
15 import org.abstracthorizon.danube.http.HTTPConnection;
16
17
18
19
20
21
22 public class Depth {
23
24
25 public static final int NONE = -1;
26
27
28 public static final int ZERO = 0;
29
30
31 public static final int ONE = 1;
32
33
34 public static final int INFINITY = 2;
35
36
37
38
39
40
41 public static int collectDepth(HTTPConnection connection) {
42 String depthHeader = connection.getRequestHeaders().getOnly("Depth");
43 if (depthHeader == null) {
44 return NONE;
45 } else if ("0".equals(depthHeader)) {
46 return ZERO;
47 } else if ("1".equals(depthHeader)) {
48 return ONE;
49 } else if ("infinity".equals(depthHeader)) {
50 return INFINITY;
51 } else {
52 return NONE;
53 }
54 }
55
56
57
58
59
60
61 public static String toString(int depth) {
62 if (depth == NONE) {
63 return "NONE";
64 } else if (depth == ZERO) {
65 return "0";
66 } else if (depth == ONE) {
67 return "1";
68 } else if (depth == INFINITY) {
69 return "infinity";
70 } else {
71 return "NONE";
72 }
73 }
74 }