View Javadoc
1   /**
2    * This file Copyright (c) 2011-2018 Magnolia International
3    * Ltd.  (http://www.magnolia-cms.com). All rights reserved.
4    *
5    *
6    * This file is dual-licensed under both the Magnolia
7    * Network Agreement and the GNU General Public License.
8    * You may elect to use one or the other of these licenses.
9    *
10   * This file is distributed in the hope that it will be
11   * useful, but AS-IS and WITHOUT ANY WARRANTY; without even the
12   * implied warranty of MERCHANTABILITY or FITNESS FOR A
13   * PARTICULAR PURPOSE, TITLE, or NONINFRINGEMENT.
14   * Redistribution, except as permitted by whichever of the GPL
15   * or MNA you select, is prohibited.
16   *
17   * 1. For the GPL license (GPL), you can redistribute and/or
18   * modify this file under the terms of the GNU General
19   * Public License, Version 3, as published by the Free Software
20   * Foundation.  You should have received a copy of the GNU
21   * General Public License, Version 3 along with this program;
22   * if not, write to the Free Software Foundation, Inc., 51
23   * Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
24   *
25   * 2. For the Magnolia Network Agreement (MNA), this file
26   * and the accompanying materials are made available under the
27   * terms of the MNA which accompanies this distribution, and
28   * is available at http://www.magnolia-cms.com/mna.html
29   *
30   * Any modifications to this file must keep this entire header
31   * intact.
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   * Wrapper for JCR property.
62   */
63  public abstract class DelegatePropertyWrapper implements Property {
64  
65      private Property wrapped;
66  
67      public DelegatePropertyWrapper(Property wrapped) {
68          this.wrapped = wrapped;
69      }
70  
71      protected Property getWrappedProperty() {
72          return wrapped;
73      }
74  
75      protected void setWrappedProperty(Property property) {
76          this.wrapped = property;
77      }
78  
79      @Override
80      public String toString() {
81          return wrapped != null ? wrapped.toString() : "";
82      }
83  
84      /////////////
85      //
86      //  Delegating method stubs
87      //
88      /////////////
89  
90      @Override
91      public void setValue(Value value) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException {
92          getWrappedProperty().setValue(value);
93      }
94  
95      @Override
96      public void setValue(Value[] values) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException {
97          getWrappedProperty().setValue(values);
98      }
99  
100     @Override
101     public void setValue(String value) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException {
102         getWrappedProperty().setValue(value);
103     }
104 
105     @Override
106     public void setValue(String[] values) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException {
107         getWrappedProperty().setValue(values);
108     }
109 
110     @Override
111     public void setValue(InputStream value) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException {
112         getWrappedProperty().setValue(value);
113     }
114 
115     @Override
116     public void setValue(Binary value) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException {
117         getWrappedProperty().setValue(value);
118     }
119 
120     @Override
121     public void setValue(long value) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException {
122         getWrappedProperty().setValue(value);
123     }
124 
125     @Override
126     public void setValue(double value) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException {
127         getWrappedProperty().setValue(value);
128     }
129 
130     @Override
131     public void setValue(BigDecimal value) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException {
132         getWrappedProperty().setValue(value);
133     }
134 
135     @Override
136     public void setValue(Calendar value) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException {
137         getWrappedProperty().setValue(value);
138     }
139 
140     @Override
141     public void setValue(boolean value) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException {
142         getWrappedProperty().setValue(value);
143     }
144 
145     @Override
146     public void setValue(Node value) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException {
147         getWrappedProperty().setValue(value);
148     }
149 
150     @Override
151     public Value getValue() throws ValueFormatException, RepositoryException {
152         return getWrappedProperty().getValue();
153     }
154 
155     @Override
156     public Value[] getValues() throws ValueFormatException, RepositoryException {
157         return getWrappedProperty().getValues();
158     }
159 
160     @Override
161     public String getString() throws ValueFormatException, RepositoryException {
162         return getWrappedProperty().getString();
163     }
164 
165     @Override
166     public InputStream getStream() throws ValueFormatException, RepositoryException {
167         return getWrappedProperty().getStream();
168     }
169 
170     @Override
171     public Binary getBinary() throws ValueFormatException, RepositoryException {
172         return getWrappedProperty().getBinary();
173     }
174 
175     @Override
176     public long getLong() throws ValueFormatException, RepositoryException {
177         return getWrappedProperty().getLong();
178     }
179 
180     @Override
181     public double getDouble() throws ValueFormatException, RepositoryException {
182         return getWrappedProperty().getDouble();
183     }
184 
185     @Override
186     public BigDecimal getDecimal() throws ValueFormatException, RepositoryException {
187         return getWrappedProperty().getDecimal();
188     }
189 
190     @Override
191     public Calendar getDate() throws ValueFormatException, RepositoryException {
192         return getWrappedProperty().getDate();
193     }
194 
195     @Override
196     public boolean getBoolean() throws ValueFormatException, RepositoryException {
197         return getWrappedProperty().getBoolean();
198     }
199 
200     @Override
201     public Node getNode() throws ItemNotFoundException, ValueFormatException, RepositoryException {
202         return getWrappedProperty().getNode();
203     }
204 
205     @Override
206     public Property getProperty() throws ItemNotFoundException, ValueFormatException, RepositoryException {
207         return getWrappedProperty().getProperty();
208     }
209 
210     @Override
211     public long getLength() throws ValueFormatException, RepositoryException {
212         return getWrappedProperty().getLength();
213     }
214 
215     @Override
216     public long[] getLengths() throws ValueFormatException, RepositoryException {
217         return getWrappedProperty().getLengths();
218     }
219 
220     @Override
221     public PropertyDefinition getDefinition() throws RepositoryException {
222         return getWrappedProperty().getDefinition();
223     }
224 
225     @Override
226     public int getType() throws RepositoryException {
227         return getWrappedProperty().getType();
228     }
229 
230     @Override
231     public boolean isMultiple() throws RepositoryException {
232         return getWrappedProperty().isMultiple();
233     }
234 
235     @Override
236     public String getPath() throws RepositoryException {
237         return getWrappedProperty().getPath();
238     }
239 
240     @Override
241     public String getName() throws RepositoryException {
242         return getWrappedProperty().getName();
243     }
244 
245     @Override
246     public Item getAncestor(int depth) throws ItemNotFoundException, AccessDeniedException, RepositoryException {
247         return getWrappedProperty().getAncestor(depth);
248     }
249 
250     @Override
251     public Node getParent() throws ItemNotFoundException, AccessDeniedException, RepositoryException {
252         return getWrappedProperty().getParent();
253     }
254 
255     @Override
256     public int getDepth() throws RepositoryException {
257         return getWrappedProperty().getDepth();
258     }
259 
260     @Override
261     public Session getSession() throws RepositoryException {
262         return getWrappedProperty().getSession();
263     }
264 
265     @Override
266     public boolean isNode() {
267         return getWrappedProperty().isNode();
268     }
269 
270     @Override
271     public boolean isNew() {
272         return getWrappedProperty().isNew();
273     }
274 
275     @Override
276     public boolean isModified() {
277         return getWrappedProperty().isModified();
278     }
279 
280     @Override
281     public boolean isSame(Item otherItem) throws RepositoryException {
282         return getWrappedProperty().isSame(otherItem);
283     }
284 
285     @Override
286     public void accept(ItemVisitor visitor) throws RepositoryException {
287         getWrappedProperty().accept(visitor);
288     }
289 
290     @Override
291     public void save() throws AccessDeniedException, ItemExistsException, ConstraintViolationException, InvalidItemStateException, ReferentialIntegrityException, VersionException, LockException, NoSuchNodeTypeException, RepositoryException {
292         getWrappedProperty().save();
293     }
294 
295     @Override
296     public void refresh(boolean keepChanges) throws InvalidItemStateException, RepositoryException {
297         getWrappedProperty().refresh(keepChanges);
298     }
299 
300     @Override
301     public void remove() throws VersionException, LockException, ConstraintViolationException, AccessDeniedException, RepositoryException {
302         getWrappedProperty().remove();
303     }
304 }