01: /*
02: * $Id: AbstractReadOnlyModel.java 460492 2006-05-02 19:02:12Z ivaynberg $
03: * $Revision: 460492 $
04: * $Date: 2006-05-02 21:02:12 +0200 (Tue, 02 May 2006) $
05: *
06: * ==============================================================================
07: * Licensed under the Apache License, Version 2.0 (the "License"); you may not
08: * use this file except in compliance with the License. You may obtain a copy of
09: * the License at
10: *
11: * http://www.apache.org/licenses/LICENSE-2.0
12: *
13: * Unless required by applicable law or agreed to in writing, software
14: * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15: * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
16: * License for the specific language governing permissions and limitations under
17: * the License.
18: */
19: package wicket.model;
20:
21: import wicket.Component;
22:
23: /**
24: * AbstractReadOnlyModel is an adapter base class for implementing models which have no
25: * detach logic and are read-only.
26: *
27: * @author Igor Vaynberg ( ivaynberg )
28: */
29: public abstract class AbstractReadOnlyModel extends AbstractModel {
30:
31: /**
32: * @see IModel#getObject(Component)
33: */
34: public abstract Object getObject(Component component);
35:
36: /**
37: * This default implementation of setObject unconditionally throws an
38: * UnsupportedOperationException. Since the method is final, any subclass is
39: * effectively a read-only model.
40: *
41: * @param component
42: * The component wanting to set the object
43: * @param object
44: * The object to set into the model
45: * @throws UnsupportedOperationException
46: */
47: public final void setObject(final Component component,
48: final Object object) {
49: throw new UnsupportedOperationException("Model " + getClass()
50: + " does not support setObject(Object)");
51: }
52:
53: /**
54: * @see java.lang.Object#toString()
55: */
56: public String toString() {
57: return super.toString();
58: }
59: }
|