View Javadoc

1   /**
2    * This file Copyright (c) 2009-2011 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.cms.util;
35  
36  import java.io.InputStream;
37  import java.util.Calendar;
38  import java.util.Collection;
39  
40  import javax.jcr.ItemNotFoundException;
41  import javax.jcr.PathNotFoundException;
42  import javax.jcr.Property;
43  import javax.jcr.RepositoryException;
44  import javax.jcr.Value;
45  
46  import info.magnolia.cms.core.Content;
47  import info.magnolia.cms.core.HierarchyManager;
48  import info.magnolia.cms.core.NodeData;
49  import info.magnolia.cms.security.AccessDeniedException;
50  
51  
52  /**
53   * Wraps a {@link NodeData} to which it delegates. Used to manipulate node datas.
54   * @version $Id: NodeDataWrapper.java 41137 2011-01-06 18:19:25Z gjoseph $
55   */
56  public abstract class NodeDataWrapper implements NodeData {
57  
58      private NodeData wrappedNodeData;
59  
60      public NodeDataWrapper() {
61      }
62  
63      public NodeDataWrapper(NodeData wrappedNodeData) {
64          this.wrappedNodeData = wrappedNodeData;
65      }
66  
67      public NodeData getWrappedNodeData() {
68          return this.wrappedNodeData;
69      }
70  
71      public void setWrappedNodeData(NodeData wrappedNodeData) {
72          this.wrappedNodeData = wrappedNodeData;
73      }
74  
75      public String toString() {
76          final StringBuilder buffer = new StringBuilder();
77          buffer.append(getClass().getSimpleName());
78          buffer.append(" for ");
79          buffer.append(getWrappedNodeData().toString());
80          return buffer.toString();
81      }
82  
83      // ---- below are only generated delegate methods
84      public void delete() throws RepositoryException {
85          getWrappedNodeData().delete();
86      }
87  
88      public String getAttribute(String name) {
89          return getWrappedNodeData().getAttribute(name);
90      }
91  
92      public Collection getAttributeNames() throws RepositoryException {
93          return getWrappedNodeData().getAttributeNames();
94      }
95  
96      public boolean getBoolean() {
97          return getWrappedNodeData().getBoolean();
98      }
99  
100     public long getContentLength() {
101         return getWrappedNodeData().getContentLength();
102     }
103 
104     public Calendar getDate() {
105         return getWrappedNodeData().getDate();
106     }
107 
108     public double getDouble() {
109         return getWrappedNodeData().getDouble();
110     }
111 
112     public String getHandle() {
113         return getWrappedNodeData().getHandle();
114     }
115 
116     public HierarchyManager getHierarchyManager() {
117         return getWrappedNodeData().getHierarchyManager();
118     }
119 
120     public Property getJCRProperty() {
121         return getWrappedNodeData().getJCRProperty();
122     }
123 
124     public long getLong() {
125         return getWrappedNodeData().getLong();
126     }
127 
128     public String getName() {
129         return getWrappedNodeData().getName();
130     }
131 
132     public Content getParent() throws AccessDeniedException, ItemNotFoundException, javax.jcr.AccessDeniedException, RepositoryException {
133         return getWrappedNodeData().getParent();
134     }
135 
136     public Content getReferencedContent() throws RepositoryException, PathNotFoundException, RepositoryException {
137         return getWrappedNodeData().getReferencedContent();
138     }
139 
140     public Content getReferencedContent(String repositoryId) throws PathNotFoundException, RepositoryException {
141         return getWrappedNodeData().getReferencedContent(repositoryId);
142     }
143 
144     public InputStream getStream() {
145         return getWrappedNodeData().getStream();
146     }
147 
148     public String getString() {
149         return getWrappedNodeData().getString();
150     }
151 
152     public String getString(String lineBreak) {
153         return getWrappedNodeData().getString(lineBreak);
154     }
155 
156     public int getType() {
157         return getWrappedNodeData().getType();
158     }
159 
160     public Value getValue() {
161         return getWrappedNodeData().getValue();
162     }
163 
164     public Value[] getValues() {
165         return getWrappedNodeData().getValues();
166     }
167 
168     public boolean isExist() {
169         return getWrappedNodeData().isExist();
170     }
171 
172     public boolean isGranted(long permissions) {
173         return getWrappedNodeData().isGranted(permissions);
174     }
175 
176     public int isMultiValue() {
177         return getWrappedNodeData().isMultiValue();
178     }
179 
180     public void refresh(boolean keepChanges) throws RepositoryException {
181         getWrappedNodeData().refresh(keepChanges);
182     }
183 
184     public void save() throws RepositoryException {
185         getWrappedNodeData().save();
186     }
187 
188     public void setAttribute(String name, Calendar value) throws RepositoryException, AccessDeniedException, UnsupportedOperationException {
189         getWrappedNodeData().setAttribute(name, value);
190     }
191 
192     public void setAttribute(String name, String value) throws RepositoryException, AccessDeniedException, UnsupportedOperationException {
193         getWrappedNodeData().setAttribute(name, value);
194     }
195 
196     public void setValue(boolean value) throws RepositoryException, AccessDeniedException {
197         getWrappedNodeData().setValue(value);
198     }
199 
200     public void setValue(Calendar value) throws RepositoryException, AccessDeniedException {
201         getWrappedNodeData().setValue(value);
202     }
203 
204     public void setValue(double value) throws RepositoryException, AccessDeniedException {
205         getWrappedNodeData().setValue(value);
206     }
207 
208     public void setValue(InputStream value) throws RepositoryException, AccessDeniedException {
209         getWrappedNodeData().setValue(value);
210     }
211 
212     public void setValue(int value) throws RepositoryException, AccessDeniedException {
213         getWrappedNodeData().setValue(value);
214     }
215 
216     public void setValue(long value) throws RepositoryException, AccessDeniedException {
217         getWrappedNodeData().setValue(value);
218     }
219 
220     public void setValue(String value) throws RepositoryException, AccessDeniedException {
221         getWrappedNodeData().setValue(value);
222     }
223 
224     public void setValue(Content value) throws RepositoryException, AccessDeniedException {
225         getWrappedNodeData().setValue(value);
226     }
227 
228     public void setValue(Value value) throws RepositoryException, AccessDeniedException {
229         getWrappedNodeData().setValue(value);
230     }
231 
232     public void setValue(Value[] value) throws RepositoryException, AccessDeniedException {
233         getWrappedNodeData().setValue(value);
234     }
235 
236 }