1
2
3
4
5
6
7
8
9
10
11
12
13 package org.abstracthorizon.danube.webdav.xml.dav.request;
14
15 import org.abstracthorizon.danube.webdav.xml.XMLParserHandler;
16 import org.abstracthorizon.danube.webdav.xml.dav.DAVAbstractXMLParser;
17 import org.abstracthorizon.danube.webdav.xml.dav.DAVFactory;
18 import org.abstracthorizon.danube.webdav.xml.dav.RequestProp;
19
20 import java.util.ArrayList;
21 import java.util.List;
22
23 import org.xml.sax.Attributes;
24 import org.xml.sax.SAXException;
25
26
27
28
29
30
31 public class PropertyUpdate extends DAVAbstractXMLParser {
32
33
34 protected List<RequestProp> list = new ArrayList<RequestProp>();
35
36
37
38
39
40
41 public PropertyUpdate(XMLParserHandler parent, DAVFactory factory) {
42 super(parent, factory);
43 }
44
45 @Override
46 public Object start(Object current, String tag, Attributes attributes) throws SAXException {
47 if ("set".equals(tag)) {
48 RequestProp set = davFactory.newSet(this);
49 list.add(set);
50 return set;
51 } else if ("remove".equals(tag)) {
52 RequestProp remove = davFactory.newRemove(this);
53 list.add(remove);
54 return remove;
55 } else {
56 return super.start(current, tag, attributes);
57 }
58 }
59
60 @Override
61 public Object end(Object current, String tag, String value) {
62 return this;
63 }
64
65
66
67
68
69 public List<RequestProp> getProperties() {
70 return list;
71 }
72
73 @Override
74 public String toString() {
75 StringBuffer res = new StringBuffer("PropertyUpdate[");
76 boolean first = true;
77 for (Object object: list) {
78 if (first) {
79 first = false;
80 } else {
81 res.append(',');
82 }
83 res.append(object);
84 }
85 res.append(']');
86 return res.toString();
87 }
88
89
90 }