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