1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 package info.magnolia.jcr.wrapper;
35
36 import java.io.InputStream;
37 import java.math.BigDecimal;
38 import java.util.Calendar;
39
40 import javax.jcr.AccessDeniedException;
41 import javax.jcr.Binary;
42 import javax.jcr.InvalidItemStateException;
43 import javax.jcr.Item;
44 import javax.jcr.ItemExistsException;
45 import javax.jcr.ItemNotFoundException;
46 import javax.jcr.ItemVisitor;
47 import javax.jcr.Node;
48 import javax.jcr.Property;
49 import javax.jcr.ReferentialIntegrityException;
50 import javax.jcr.RepositoryException;
51 import javax.jcr.Session;
52 import javax.jcr.Value;
53 import javax.jcr.ValueFormatException;
54 import javax.jcr.lock.LockException;
55 import javax.jcr.nodetype.ConstraintViolationException;
56 import javax.jcr.nodetype.NoSuchNodeTypeException;
57 import javax.jcr.nodetype.PropertyDefinition;
58 import javax.jcr.version.VersionException;
59
60
61
62
63
64
65 public abstract class DelegatePropertyWrapper implements Property {
66
67 private Property wrapped;
68
69 public DelegatePropertyWrapper(Property wrapped) {
70 this.wrapped = wrapped;
71 setWrappedProperty(wrapped);
72 }
73
74 protected Property getWrappedProperty() {
75 return wrapped;
76 }
77
78 protected void setWrappedProperty(Property property) {
79 if (wrapped == null) {
80 throw new IllegalArgumentException();
81 } else {
82 this.wrapped = property;
83 }
84 }
85
86 @Override
87 public String toString() {
88 return wrapped != null ? wrapped.toString() : "";
89 }
90
91
92
93
94
95
96
97 @Override
98 public void setValue(Value value) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException {
99 getWrappedProperty().setValue(value);
100 }
101
102 @Override
103 public void setValue(Value[] values) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException {
104 getWrappedProperty().setValue(values);
105 }
106
107 @Override
108 public void setValue(String value) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException {
109 getWrappedProperty().setValue(value);
110 }
111
112 @Override
113 public void setValue(String[] values) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException {
114 getWrappedProperty().setValue(values);
115 }
116
117 @Override
118 public void setValue(InputStream value) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException {
119 getWrappedProperty().setValue(value);
120 }
121
122 @Override
123 public void setValue(Binary value) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException {
124 getWrappedProperty().setValue(value);
125 }
126
127 @Override
128 public void setValue(long value) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException {
129 getWrappedProperty().setValue(value);
130 }
131
132 @Override
133 public void setValue(double value) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException {
134 getWrappedProperty().setValue(value);
135 }
136
137 @Override
138 public void setValue(BigDecimal value) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException {
139 getWrappedProperty().setValue(value);
140 }
141
142 @Override
143 public void setValue(Calendar value) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException {
144 getWrappedProperty().setValue(value);
145 }
146
147 @Override
148 public void setValue(boolean value) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException {
149 getWrappedProperty().setValue(value);
150 }
151
152 @Override
153 public void setValue(Node value) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException {
154 getWrappedProperty().setValue(value);
155 }
156
157 @Override
158 public Value getValue() throws ValueFormatException, RepositoryException {
159 return getWrappedProperty().getValue();
160 }
161
162 @Override
163 public Value[] getValues() throws ValueFormatException, RepositoryException {
164 return getWrappedProperty().getValues();
165 }
166
167 @Override
168 public String getString() throws ValueFormatException, RepositoryException {
169 return getWrappedProperty().getString();
170 }
171
172 @Override
173 public InputStream getStream() throws ValueFormatException, RepositoryException {
174 return getWrappedProperty().getStream();
175 }
176
177 @Override
178 public Binary getBinary() throws ValueFormatException, RepositoryException {
179 return getWrappedProperty().getBinary();
180 }
181
182 @Override
183 public long getLong() throws ValueFormatException, RepositoryException {
184 return getWrappedProperty().getLong();
185 }
186
187 @Override
188 public double getDouble() throws ValueFormatException, RepositoryException {
189 return getWrappedProperty().getDouble();
190 }
191
192 @Override
193 public BigDecimal getDecimal() throws ValueFormatException, RepositoryException {
194 return getWrappedProperty().getDecimal();
195 }
196
197 @Override
198 public Calendar getDate() throws ValueFormatException, RepositoryException {
199 return getWrappedProperty().getDate();
200 }
201
202 @Override
203 public boolean getBoolean() throws ValueFormatException, RepositoryException {
204 return getWrappedProperty().getBoolean();
205 }
206
207 @Override
208 public Node getNode() throws ItemNotFoundException, ValueFormatException, RepositoryException {
209 return getWrappedProperty().getNode();
210 }
211
212 @Override
213 public Property getProperty() throws ItemNotFoundException, ValueFormatException, RepositoryException {
214 return getWrappedProperty().getProperty();
215 }
216
217 @Override
218 public long getLength() throws ValueFormatException, RepositoryException {
219 return getWrappedProperty().getLength();
220 }
221
222 @Override
223 public long[] getLengths() throws ValueFormatException, RepositoryException {
224 return getWrappedProperty().getLengths();
225 }
226
227 @Override
228 public PropertyDefinition getDefinition() throws RepositoryException {
229 return getWrappedProperty().getDefinition();
230 }
231
232 @Override
233 public int getType() throws RepositoryException {
234 return getWrappedProperty().getType();
235 }
236
237 @Override
238 public boolean isMultiple() throws RepositoryException {
239 return getWrappedProperty().isMultiple();
240 }
241
242 @Override
243 public String getPath() throws RepositoryException {
244 return getWrappedProperty().getPath();
245 }
246
247 @Override
248 public String getName() throws RepositoryException {
249 return getWrappedProperty().getName();
250 }
251
252 @Override
253 public Item getAncestor(int depth) throws ItemNotFoundException, AccessDeniedException, RepositoryException {
254 return getWrappedProperty().getAncestor(depth);
255 }
256
257 @Override
258 public Node getParent() throws ItemNotFoundException, AccessDeniedException, RepositoryException {
259 return getWrappedProperty().getParent();
260 }
261
262 @Override
263 public int getDepth() throws RepositoryException {
264 return getWrappedProperty().getDepth();
265 }
266
267 @Override
268 public Session getSession() throws RepositoryException {
269 return getWrappedProperty().getSession();
270 }
271
272 @Override
273 public boolean isNode() {
274 return getWrappedProperty().isNode();
275 }
276
277 @Override
278 public boolean isNew() {
279 return getWrappedProperty().isNew();
280 }
281
282 @Override
283 public boolean isModified() {
284 return getWrappedProperty().isModified();
285 }
286
287 @Override
288 public boolean isSame(Item otherItem) throws RepositoryException {
289 return getWrappedProperty().isSame(otherItem);
290 }
291
292 @Override
293 public void accept(ItemVisitor visitor) throws RepositoryException {
294 getWrappedProperty().accept(visitor);
295 }
296
297 @Override
298 public void save() throws AccessDeniedException, ItemExistsException, ConstraintViolationException, InvalidItemStateException, ReferentialIntegrityException, VersionException, LockException, NoSuchNodeTypeException, RepositoryException {
299 getWrappedProperty().save();
300 }
301
302 @Override
303 public void refresh(boolean keepChanges) throws InvalidItemStateException, RepositoryException {
304 getWrappedProperty().refresh(keepChanges);
305 }
306
307 @Override
308 public void remove() throws VersionException, LockException, ConstraintViolationException, AccessDeniedException, RepositoryException {
309 getWrappedProperty().remove();
310 }
311 }