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.HTTPServerConnectionHandler;
16 import org.abstracthorizon.danube.http.Status;
17 import org.abstracthorizon.danube.webdav.util.NamespacesProvider;
18 import org.abstracthorizon.danube.webdav.xml.common.XMLUtils;
19 import org.abstracthorizon.danube.webdav.xml.dav.DAVNamespace;
20
21 import java.io.PrintWriter;
22 import java.util.Date;
23
24 public class GetLastModified extends ResponseProperty {
25
26 public static final String TAG_NAME = "getlastmodified";
27
28 protected long modified = -1;
29 protected String cachedDate;
30
31
32
33
34
35 public GetLastModified(Status status) {
36 super(status);
37 }
38
39
40
41
42
43 public GetLastModified(long modified) {
44 this.modified = modified;
45 }
46
47
48
49
50
51 public long getLastModified() {
52 return modified;
53 }
54
55
56
57
58
59 public String asString() {
60 if (cachedDate == null) {
61 if (modified != -1) {
62 cachedDate = HTTPServerConnectionHandler.DATE_FORMAT.format(new Date(modified));
63 }
64 }
65 return cachedDate;
66 }
67
68 @Override
69 public String toString() {
70 if (modified != -1) {
71 return "GetLastModified[" + asString() + "]";
72 } else {
73 return "GetLastModified[]";
74 }
75 }
76
77
78
79
80
81
82 public void render(PrintWriter writer, NamespacesProvider provider) {
83 writer.println(XMLUtils.createTag(provider, DAVNamespace.DAV_NAMESPACE_URL, TAG_NAME, asString()));
84 }
85
86 }