1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package nl.hippo.client.webdav.binding.content;
17
18 import java.util.ArrayList;
19 import java.util.Iterator;
20 import java.util.List;
21
22 import nl.hippo.client.api.content.DocumentCollection;
23
24 import org.apache.commons.lang.builder.ToStringBuilder;
25 import org.apache.commons.lang.builder.ToStringStyle;
26
27 /**
28 * Java binding for a searchresult XML fragment
29 */
30 public class DocumentCollectionImpl implements DocumentCollection {
31
32 private static final long serialVersionUID = 1L;
33
34 private ArrayList documents;
35
36 private DocumentCollectionImpl() {
37 }
38
39 public DocumentCollectionImpl(List documents) {
40 this.documents = new ArrayList(documents);
41 }
42
43 public List getDocuments() {
44 return documents;
45 }
46
47 public String toString() {
48 ToStringBuilder builder = new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).append("ResourceCount",
49 documents.size());
50
51 Iterator it = documents.iterator();
52 while (it.hasNext()) {
53 DocumentImpl resource = (DocumentImpl) it.next();
54 builder.append(resource.toString());
55 }
56 return builder.toString();
57 }
58
59 public boolean equals(Object obj) {
60 boolean eq;
61 if (obj == null) {
62 eq = false;
63 } else if (!(obj instanceof DocumentCollectionImpl)) {
64 eq = false;
65 } else if (this == obj) {
66 eq = true;
67 } else {
68 DocumentCollectionImpl rhs = (DocumentCollectionImpl) obj;
69 if (documents == null) {
70 eq = (rhs.documents == null);
71 } else {
72 eq = (documents.equals(rhs.documents));
73 }
74 }
75 return eq;
76 }
77
78 public int hashCode() {
79 int result;
80 if (documents == null) {
81 result = 0;
82 } else {
83 result = documents.hashCode();
84 }
85 return result;
86 }
87
88 }