1
2
3
4
5
6
7
8
9
10
11
12
13 package org.abstracthorizon.danube.webdav.xml.dav.response.properties;
14
15 import org.abstracthorizon.danube.http.Status;
16 import org.abstracthorizon.danube.webdav.util.NamespacesProvider;
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 GetContentLength extends ResponseProperty {
28
29
30 public static final String TAG_NAME = "getcontentlength";
31
32
33 protected long contentLength = -1;
34
35
36
37
38
39 public GetContentLength(Status status) {
40 super(status);
41 }
42
43
44
45
46
47 public GetContentLength(long contentLength) {
48 this.contentLength = contentLength;
49 }
50
51
52
53
54
55 public long getContentLength() {
56 return contentLength;
57 }
58
59 @Override
60 public String toString() {
61 return "GetContentLength[" + contentLength + "]";
62 }
63
64
65
66
67
68
69 public void render(PrintWriter writer, NamespacesProvider provider) {
70 if (contentLength >= 0) {
71 writer.println(XMLUtils.createTag(provider, DAVNamespace.DAV_NAMESPACE_URL, TAG_NAME, Long.toString(contentLength)));
72 } else {
73 writer.println(XMLUtils.createEmptyTag(provider, DAVNamespace.DAV_NAMESPACE_URL, TAG_NAME));
74 }
75 }
76
77 }