This project has retired. For details please refer to its
Attic page.
PropertiesImpl 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.Collection;
23 import java.util.Collections;
24 import java.util.Iterator;
25 import java.util.LinkedHashMap;
26 import java.util.List;
27 import java.util.Map;
28
29 import org.apache.chemistry.opencmis.commons.data.Properties;
30 import org.apache.chemistry.opencmis.commons.data.PropertyData;
31
32
33
34
35 public class PropertiesImpl extends AbstractExtensionData implements Properties {
36
37 private static final long serialVersionUID = 1L;
38
39 List<PropertyData<?>> propertyList = new ArrayList<PropertyData<?>>();
40 Map<String, PropertyData<?>> properties = new LinkedHashMap<String, PropertyData<?>>();
41
42
43
44
45 public PropertiesImpl() {
46 }
47
48
49
50
51
52
53
54 public PropertiesImpl(Collection<PropertyData<?>> properties) {
55 if (properties != null) {
56 for (PropertyData<?> prop : properties) {
57 addProperty(prop);
58 }
59 }
60 }
61
62 public Map<String, PropertyData<?>> getProperties() {
63 return Collections.unmodifiableMap(properties);
64 }
65
66 public List<PropertyData<?>> getPropertyList() {
67 return Collections.unmodifiableList(propertyList);
68 }
69
70
71
72
73
74
75
76 public void addProperty(PropertyData<?> property) {
77 if (property == null) {
78 return;
79 }
80
81 propertyList.add(property);
82 properties.put(property.getId(), property);
83 }
84
85
86
87
88
89
90
91 public void replaceProperty(PropertyData<?> property) {
92 if ((property == null) || (property.getId() == null)) {
93 return;
94 }
95
96 removeProperty(property.getId());
97
98 propertyList.add(property);
99 properties.put(property.getId(), property);
100 }
101
102
103
104
105
106
107
108 public void removeProperty(String id) {
109 if (id == null) {
110 return;
111 }
112
113 Iterator<PropertyData<?>> iterator = propertyList.iterator();
114 while (iterator.hasNext()) {
115 PropertyData<?> property = iterator.next();
116 if (id.equals(property.getId())) {
117 iterator.remove();
118 break;
119 }
120 }
121
122 properties.remove(id);
123 }
124
125 @Override
126 public String toString() {
127 return "Properties Data [properties=" + propertyList + "]" + super.toString();
128 }
129
130 }