01: /*
02: * Copyright 2006 John G. Wilson
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: *
16: */
17:
18: package org.codehaus.groovy.runtime.wrappers;
19:
20: import groovy.lang.GroovyObject;
21: import groovy.lang.MetaClass;
22:
23: /**
24: * @author John Wilson
25: *
26: */
27:
28: public class GroovyObjectWrapper extends Wrapper {
29: protected final GroovyObject wrapped;
30:
31: public GroovyObjectWrapper(final GroovyObject wrapped,
32: final Class constrainedType) {
33: super (constrainedType);
34: this .wrapped = wrapped;
35: }
36:
37: public Object unwrap() {
38: return this .wrapped;
39: }
40:
41: /**
42: * Note the rest of these method will only be used post 1.0
43: */
44:
45: /* (non-Javadoc)
46: * @see groovy.lang.GroovyObject#getProperty(java.lang.String)
47: */
48: public Object getProperty(final String property) {
49: return this .wrapped.getProperty(property);
50: }
51:
52: /* (non-Javadoc)
53: * @see groovy.lang.GroovyObject#invokeMethod(java.lang.String, java.lang.Object)
54: */
55: public Object invokeMethod(final String name, final Object args) {
56: return this .wrapped.invokeMethod(name, args);
57: }
58:
59: /* (non-Javadoc)
60: * @see groovy.lang.GroovyObject#setMetaClass(groovy.lang.MetaClass)
61: */
62: public void setMetaClass(final MetaClass metaClass) {
63: this .wrapped.setMetaClass(metaClass);
64: }
65:
66: /* (non-Javadoc)
67: * @see groovy.lang.GroovyObject#setProperty(java.lang.String, java.lang.Object)
68: */
69: public void setProperty(final String property, final Object newValue) {
70: this .wrapped.setProperty(property, newValue);
71: }
72:
73: protected Object getWrapped() {
74: return this .wrapped;
75: }
76:
77: protected MetaClass getDelegatedMetaClass() {
78: return this.wrapped.getMetaClass();
79: }
80: }
|