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 Owner implements XMLRenderer {
28
29
30 public static final String TAG_NAME = "owner";
31
32
33 protected Object owner;
34
35
36
37
38
39 public Owner(Object owner) {
40 this.owner = owner;
41 }
42
43
44
45
46
47 public Object getOwner() {
48 return owner;
49 }
50
51 @Override
52 public String toString() {
53 if (owner != null) {
54 return "Owner[" + owner + "]";
55 } else {
56 return "Owner[]";
57 }
58 }
59
60
61
62
63
64
65 public void render(PrintWriter writer, NamespacesProvider provider) {
66 if (owner != null) {
67 if (owner instanceof XMLRenderer) {
68 writer.println(XMLUtils.createStartTag(provider, DAVNamespace.DAV_NAMESPACE_URL, TAG_NAME));
69 ((XMLRenderer)owner).render(writer, provider);
70 writer.println(XMLUtils.createEndTag(provider, DAVNamespace.DAV_NAMESPACE_URL, TAG_NAME));
71 } else {
72 writer.print(XMLUtils.createStartTag(provider, DAVNamespace.DAV_NAMESPACE_URL, TAG_NAME));
73 writer.print(owner);
74 writer.println(XMLUtils.createEndTag(provider, DAVNamespace.DAV_NAMESPACE_URL, TAG_NAME));
75 }
76 } else {
77 writer.print(XMLUtils.createTag(provider, DAVNamespace.DAV_NAMESPACE_URL, TAG_NAME, null));
78 }
79 }
80
81 }