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 nl.hippo.client.api.content.Document;
19 import nl.hippo.client.api.content.DocumentMetadata;
20 import nl.hippo.client.api.content.DocumentPath;
21 import nl.hippo.client.api.content.RawResponse;
22
23 import org.apache.commons.lang.builder.EqualsBuilder;
24 import org.apache.commons.lang.builder.HashCodeBuilder;
25 import org.apache.commons.lang.builder.ToStringBuilder;
26 import org.apache.commons.lang.builder.ToStringStyle;
27
28 /**
29 * Java binding for a document XML fragment
30 */
31 public class DocumentImpl implements Document {
32
33 private static final long serialVersionUID = 1L;
34
35 protected DocumentMetadata metadata;
36 protected RawResponse content;
37 protected DocumentPath path;
38
39
40
41
42 protected String tmpPath;
43 protected String tmpContent;
44
45
46 private DocumentImpl() {
47 }
48
49 protected DocumentImpl(DocumentPath path, DocumentMetadata metadata, RawResponse content) {
50 this.path = path;
51 this.metadata = metadata;
52 this.content = content;
53 }
54
55 public RawResponse getContent() {
56 return content;
57 }
58
59 public DocumentPath getPath() {
60 return path;
61 }
62
63 public DocumentMetadata getMetadata() {
64 return metadata;
65 }
66
67 public String toString() {
68 ToStringBuilder builder = new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
69 .append("Path", path == null ? "null": path.getFullPath())
70 .append("Content", content == null ? "null": content.toString())
71 .append("Metadata", metadata == null ? "null" : metadata.toString());
72 return builder.toString();
73 }
74
75 public boolean equals(Object obj) {
76 if (obj instanceof DocumentImpl == false) {
77 return false;
78 }
79 if (this == obj) {
80 return true;
81 }
82 DocumentImpl rhs = (DocumentImpl) obj;
83 return new EqualsBuilder()
84 .append(content, rhs.content)
85 .append(path, rhs.path)
86 .append(metadata, rhs.metadata)
87 .isEquals();
88 }
89
90 public int hashCode() {
91 int hash = new HashCodeBuilder(17, 27)
92 .append(getPath())
93 .append(getContent())
94 .append(getMetadata())
95 .toHashCode();
96 return hash;
97 }
98
99 }