This project has retired. For details please refer to its
Attic page.
CmisExtensionElementImpl xref
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.chemistry.opencmis.commons.impl.dataobjects;
20
21 import java.util.ArrayList;
22 import java.util.Collections;
23 import java.util.HashMap;
24 import java.util.List;
25 import java.util.Map;
26
27 import org.apache.chemistry.opencmis.commons.data.CmisExtensionElement;
28
29 public class CmisExtensionElementImpl implements CmisExtensionElement {
30
31 private static final long serialVersionUID = 1L;
32
33 private final String name;
34 private final String namespace;
35 private final String value;
36 private Map<String, String> attributes;
37 private final List<CmisExtensionElement> children;
38
39
40
41
42 public CmisExtensionElementImpl(String namespace, String name, Map<String, String> attributes, String value) {
43 if (name == null) {
44 throw new IllegalArgumentException("Name must set!");
45 }
46
47 this.name = name;
48 this.namespace = namespace;
49 this.value = value;
50 children = Collections.emptyList();
51
52 if (attributes != null) {
53 this.attributes = Collections.unmodifiableMap(new HashMap<String, String>(attributes));
54 } else {
55 this.attributes = Collections.emptyMap();
56 }
57 }
58
59
60
61
62 public CmisExtensionElementImpl(String namespace, String name, Map<String, String> attributes,
63 List<CmisExtensionElement> children) {
64 if (name == null) {
65 throw new IllegalArgumentException("Name must set!");
66 }
67
68 this.name = name;
69 this.namespace = namespace;
70 this.value = null;
71
72 if (children != null) {
73 this.children = Collections.unmodifiableList(new ArrayList<CmisExtensionElement>(children));
74 } else {
75 this.children = Collections.emptyList();
76 }
77
78 if (attributes != null) {
79 this.attributes = Collections.unmodifiableMap(new HashMap<String, String>(attributes));
80 } else {
81 this.attributes = Collections.emptyMap();
82 }
83 }
84
85
86
87
88 public CmisExtensionElementImpl(CmisExtensionElement element) {
89 if (element == null) {
90 throw new IllegalArgumentException("Element must set!");
91 }
92 if (element.getName() == null) {
93 throw new IllegalArgumentException("Name must set!");
94 }
95
96 this.name = element.getName();
97 this.namespace = element.getNamespace();
98 this.value = element.getValue();
99 this.children = element.getChildren();
100 }
101
102 public String getName() {
103 return name;
104 }
105
106 public String getNamespace() {
107 return namespace;
108 }
109
110 public String getValue() {
111 return value;
112 }
113
114 public List<CmisExtensionElement> getChildren() {
115 return children;
116 }
117
118 public Map<String, String> getAttributes() {
119 return attributes;
120 }
121
122 @Override
123 public String toString() {
124 return (namespace == null ? "" : "{" + namespace + "}") + name + " " + attributes + ": "
125 + (children.isEmpty() ? value : children.toString());
126 }
127 }