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 import org.abstracthorizon.danube.webdav.xml.dav.response.properties.ResponseProperty;
20
21 import java.io.PrintWriter;
22 import java.util.ArrayList;
23 import java.util.List;
24
25
26
27
28
29
30 public class ResponseProp implements XMLRenderer {
31
32
33 public static final String TAG_NAME = "prop";
34
35
36 protected List<ResponseProperty> properties;
37
38
39
40
41 public ResponseProp() {
42 }
43
44
45
46
47
48 public List<ResponseProperty> getProperties() {
49 if (properties == null) {
50 properties = new ArrayList<ResponseProperty>();
51 }
52 return properties;
53 }
54
55 @Override
56 public String toString() {
57 StringBuffer result = new StringBuffer("Prop[");
58 if (properties != null) {
59 boolean first = true;
60 for (ResponseProperty property : properties) {
61 if (first) {
62 first = false;
63 } else {
64 result.append(',');
65 }
66 result.append(property.toString());
67 }
68 }
69 result.append(']');
70 return result.toString();
71 }
72
73
74
75
76
77
78 public void render(PrintWriter writer, NamespacesProvider provider) {
79 writer.println(XMLUtils.createStartTag(provider, DAVNamespace.DAV_NAMESPACE_URL, TAG_NAME));
80 if (properties != null) {
81 for (ResponseProperty property : properties) {
82 property.render(writer, provider);
83 }
84 }
85 writer.println(XMLUtils.createEndTag(provider, DAVNamespace.DAV_NAMESPACE_URL, TAG_NAME));
86 }
87
88
89
90
91
92
93
94 public void renderWithNamespaces(PrintWriter writer, NamespacesProvider provider) {
95 writer.print(XMLUtils.createStartOpenTag(provider, DAVNamespace.DAV_NAMESPACE_URL, TAG_NAME));
96 writer.print(' ');
97 MultiStatus.renderNamespaces(writer, provider);
98 writer.println('>');
99 if (properties != null) {
100 for (ResponseProperty property : properties) {
101 property.render(writer, provider);
102 }
103 }
104 writer.println(XMLUtils.createEndTag(provider, DAVNamespace.DAV_NAMESPACE_URL, TAG_NAME));
105 }
106 }