This project has retired. For details please refer to its
Attic page.
BindingsObjectFactoryImpl 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.io.InputStream;
22 import java.io.Serializable;
23 import java.math.BigDecimal;
24 import java.math.BigInteger;
25 import java.util.GregorianCalendar;
26 import java.util.List;
27
28 import org.apache.chemistry.opencmis.commons.data.Ace;
29 import org.apache.chemistry.opencmis.commons.data.Acl;
30 import org.apache.chemistry.opencmis.commons.data.ContentStream;
31 import org.apache.chemistry.opencmis.commons.data.Properties;
32 import org.apache.chemistry.opencmis.commons.data.PropertyBoolean;
33 import org.apache.chemistry.opencmis.commons.data.PropertyData;
34 import org.apache.chemistry.opencmis.commons.data.PropertyDateTime;
35 import org.apache.chemistry.opencmis.commons.data.PropertyDecimal;
36 import org.apache.chemistry.opencmis.commons.data.PropertyHtml;
37 import org.apache.chemistry.opencmis.commons.data.PropertyId;
38 import org.apache.chemistry.opencmis.commons.data.PropertyInteger;
39 import org.apache.chemistry.opencmis.commons.data.PropertyString;
40 import org.apache.chemistry.opencmis.commons.data.PropertyUri;
41 import org.apache.chemistry.opencmis.commons.definitions.PropertyBooleanDefinition;
42 import org.apache.chemistry.opencmis.commons.definitions.PropertyDateTimeDefinition;
43 import org.apache.chemistry.opencmis.commons.definitions.PropertyDecimalDefinition;
44 import org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition;
45 import org.apache.chemistry.opencmis.commons.definitions.PropertyHtmlDefinition;
46 import org.apache.chemistry.opencmis.commons.definitions.PropertyIdDefinition;
47 import org.apache.chemistry.opencmis.commons.definitions.PropertyIntegerDefinition;
48 import org.apache.chemistry.opencmis.commons.definitions.PropertyStringDefinition;
49 import org.apache.chemistry.opencmis.commons.definitions.PropertyUriDefinition;
50 import org.apache.chemistry.opencmis.commons.enums.Cardinality;
51 import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException;
52 import org.apache.chemistry.opencmis.commons.spi.BindingsObjectFactory;
53
54
55
56
57
58
59
60 public class BindingsObjectFactoryImpl implements BindingsObjectFactory, Serializable {
61
62 private static final long serialVersionUID = 1L;
63
64 public BindingsObjectFactoryImpl() {
65 }
66
67 public Ace createAccessControlEntry(String principal, List<String> permissions) {
68 return new AccessControlEntryImpl(new AccessControlPrincipalDataImpl(principal), permissions);
69 }
70
71 public Acl createAccessControlList(List<Ace> aces) {
72 return new AccessControlListImpl(aces);
73 }
74
75 public ContentStream createContentStream(String filename, BigInteger length, String mimetype, InputStream stream) {
76 return new ContentStreamImpl(filename, length, mimetype, stream);
77 }
78
79 public Properties createPropertiesData(List<PropertyData<?>> properties) {
80 return new PropertiesImpl(properties);
81 }
82
83 @SuppressWarnings("unchecked")
84 public <T> AbstractPropertyData<T> createPropertyData(
85 PropertyDefinition<T> pd, Object value) {
86 String id = pd.getId();
87 boolean single = pd.getCardinality() == Cardinality.SINGLE;
88 if (pd instanceof PropertyBooleanDefinition) {
89 if (single) {
90 return (AbstractPropertyData<T>) createPropertyBooleanData(id,
91 (Boolean) value);
92 } else {
93 return (AbstractPropertyData<T>) createPropertyBooleanData(id,
94 (List<Boolean>) value);
95 }
96 } else if (pd instanceof PropertyDateTimeDefinition) {
97 if (single) {
98 return (AbstractPropertyData<T>) createPropertyDateTimeData(id,
99 (GregorianCalendar) value);
100 } else {
101 return (AbstractPropertyData<T>) createPropertyDateTimeData(id,
102 (List<GregorianCalendar>) value);
103 }
104 } else if (pd instanceof PropertyDecimalDefinition) {
105 if (single) {
106 return (AbstractPropertyData<T>) createPropertyDecimalData(id,
107 (BigDecimal) value);
108 } else {
109 return (AbstractPropertyData<T>) createPropertyDecimalData(id,
110 (List<BigDecimal>) value);
111 }
112 } else if (pd instanceof PropertyHtmlDefinition) {
113 if (single) {
114 return (AbstractPropertyData<T>) createPropertyHtmlData(id,
115 (String) value);
116 } else {
117 return (AbstractPropertyData<T>) createPropertyHtmlData(id,
118 (List<String>) value);
119 }
120 } else if (pd instanceof PropertyIdDefinition) {
121 if (single) {
122 return (AbstractPropertyData<T>) createPropertyIdData(id,
123 (String) value);
124 } else {
125 return (AbstractPropertyData<T>) createPropertyIdData(id,
126 (List<String>) value);
127 }
128 } else if (pd instanceof PropertyIntegerDefinition) {
129 if (single) {
130 return (AbstractPropertyData<T>) createPropertyIntegerData(id,
131 (BigInteger) value);
132 } else {
133 return (AbstractPropertyData<T>) createPropertyIntegerData(id,
134 (List<BigInteger>) value);
135 }
136 } else if (pd instanceof PropertyStringDefinition) {
137 if (single) {
138 return (AbstractPropertyData<T>) createPropertyStringData(id,
139 (String) value);
140 } else {
141 return (AbstractPropertyData<T>) createPropertyStringData(id,
142 (List<String>) value);
143 }
144 } else if (pd instanceof PropertyUriDefinition) {
145 if (single) {
146 return (AbstractPropertyData<T>) createPropertyUriData(id,
147 (String) value);
148 } else {
149 return (AbstractPropertyData<T>) createPropertyUriData(id,
150 (List<String>) value);
151 }
152 }
153 throw new CmisRuntimeException("Unknown property definition: " + pd);
154 }
155
156 public PropertyBoolean createPropertyBooleanData(String id, List<Boolean> values) {
157 return new PropertyBooleanImpl(id, values);
158 }
159
160 public PropertyBoolean createPropertyBooleanData(String id, Boolean value) {
161 return new PropertyBooleanImpl(id, value);
162 }
163
164 public PropertyDateTime createPropertyDateTimeData(String id, List<GregorianCalendar> values) {
165 return new PropertyDateTimeImpl(id, values);
166 }
167
168 public PropertyDateTime createPropertyDateTimeData(String id, GregorianCalendar value) {
169 return new PropertyDateTimeImpl(id, value);
170 }
171
172 public PropertyDecimal createPropertyDecimalData(String id, List<BigDecimal> values) {
173 return new PropertyDecimalImpl(id, values);
174 }
175
176 public PropertyDecimal createPropertyDecimalData(String id, BigDecimal value) {
177 return new PropertyDecimalImpl(id, value);
178 }
179
180 public PropertyHtml createPropertyHtmlData(String id, List<String> values) {
181 return new PropertyHtmlImpl(id, values);
182 }
183
184 public PropertyHtml createPropertyHtmlData(String id, String value) {
185 return new PropertyHtmlImpl(id, value);
186 }
187
188 public PropertyId createPropertyIdData(String id, List<String> values) {
189 return new PropertyIdImpl(id, values);
190 }
191
192 public PropertyId createPropertyIdData(String id, String value) {
193 return new PropertyIdImpl(id, value);
194 }
195
196 public PropertyInteger createPropertyIntegerData(String id, List<BigInteger> values) {
197 return new PropertyIntegerImpl(id, values);
198 }
199
200 public PropertyInteger createPropertyIntegerData(String id, BigInteger value) {
201 return new PropertyIntegerImpl(id, value);
202 }
203
204 public PropertyString createPropertyStringData(String id, List<String> values) {
205 return new PropertyStringImpl(id, values);
206 }
207
208 public PropertyString createPropertyStringData(String id, String value) {
209 return new PropertyStringImpl(id, value);
210 }
211
212 public PropertyUri createPropertyUriData(String id, List<String> values) {
213 return new PropertyUriImpl(id, values);
214 }
215
216 public PropertyUri createPropertyUriData(String id, String value) {
217 return new PropertyUriImpl(id, value);
218 }
219 }