001: /*
002: * Copyright 2005 John G. Wilson
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: *
016: */
017:
018: package groovy.lang;
019:
020: import java.lang.reflect.Method;
021: import java.util.List;
022:
023: import org.codehaus.groovy.ast.ClassNode;
024: import org.codehaus.groovy.runtime.InvokerHelper;
025:
026: /**
027: * @author John Wilson
028: *
029: */
030:
031: public class DelegatingMetaClass extends MetaClass {
032: protected final MetaClass delegate;
033:
034: public DelegatingMetaClass(final MetaClass delegate) {
035: super (delegate.theClass);
036:
037: this .delegate = delegate;
038: }
039:
040: public DelegatingMetaClass(final Class theClass) {
041: this (new MetaClassImpl(InvokerHelper.getInstance()
042: .getMetaRegistry(), theClass));
043: }
044:
045: /* (non-Javadoc)
046: * @see groovy.lang.MetaClass#addNewInstanceMethod(java.lang.reflect.Method)
047: */
048: public void addNewInstanceMethod(Method method) {
049: delegate.addNewInstanceMethod(method);
050: }
051:
052: /* (non-Javadoc)
053: * @see groovy.lang.MetaClass#addNewStaticMethod(java.lang.reflect.Method)
054: */
055: public void addNewStaticMethod(Method method) {
056: delegate.addNewStaticMethod(method);
057: }
058:
059: /* (non-Javadoc)
060: * @see groovy.lang.MetaClass#initialize()
061: */
062: public void initialize() {
063: delegate.initialize();
064: }
065:
066: /* (non-Javadoc)
067: * @see groovy.lang.MetaClass#getAttribute(java.lang.Object, java.lang.String)
068: */
069: public Object getAttribute(Object object, String attribute) {
070: return delegate.getAttribute(object, attribute);
071: }
072:
073: /* (non-Javadoc)
074: * @see groovy.lang.MetaClass#getClassNode()
075: */
076: public ClassNode getClassNode() {
077: return delegate.getClassNode();
078: }
079:
080: /* (non-Javadoc)
081: * @see groovy.lang.MetaClass#getMetaMethods()
082: */
083: public List getMetaMethods() {
084: return delegate.getMetaMethods();
085: }
086:
087: /* (non-Javadoc)
088: * @see groovy.lang.MetaClass#getMethods()
089: */
090: public List getMethods() {
091: return delegate.getMethods();
092: }
093:
094: /* (non-Javadoc)
095: * @see groovy.lang.MetaClass#getProperties()
096: */
097: public List getProperties() {
098: return delegate.getProperties();
099: }
100:
101: /* (non-Javadoc)
102: * @see groovy.lang.MetaClass#getProperty(java.lang.Object, java.lang.String)
103: */
104: public Object getProperty(Object object, String property) {
105: return delegate.getProperty(object, property);
106: }
107:
108: /* (non-Javadoc)
109: * @see groovy.lang.MetaClass#invokeConstructor(java.lang.Object[])
110: */
111: public Object invokeConstructor(Object[] arguments) {
112: return delegate.invokeConstructor(arguments);
113: }
114:
115: /* (non-Javadoc)
116: * @see groovy.lang.MetaClass#invokeMethod(java.lang.Object, java.lang.String, java.lang.Object)
117: */
118: public Object invokeMethod(Object object, String methodName,
119: Object arguments) {
120: return delegate.invokeMethod(object, methodName, arguments);
121: }
122:
123: /* (non-Javadoc)
124: * @see groovy.lang.MetaClass#invokeMethod(java.lang.Object, java.lang.String, java.lang.Object[])
125: */
126: public Object invokeMethod(Object object, String methodName,
127: Object[] arguments) {
128: return delegate.invokeMethod(object, methodName, arguments);
129: }
130:
131: /* (non-Javadoc)
132: * @see groovy.lang.MetaClass#invokeStaticMethod(java.lang.Object, java.lang.String, java.lang.Object[])
133: */
134: public Object invokeStaticMethod(Object object, String methodName,
135: Object[] arguments) {
136: return delegate.invokeStaticMethod(object, methodName,
137: arguments);
138: }
139:
140: /* (non-Javadoc)
141: * @see groovy.lang.MetaClass#setAttribute(java.lang.Object, java.lang.String, java.lang.Object)
142: */
143: public void setAttribute(Object object, String attribute,
144: Object newValue) {
145: delegate.setAttribute(object, attribute, newValue);
146: }
147:
148: /* (non-Javadoc)
149: * @see groovy.lang.MetaClass#setProperty(java.lang.Object, java.lang.String, java.lang.Object)
150: */
151: public void setProperty(Object object, String property,
152: Object newValue) {
153: delegate.setProperty(object, property, newValue);
154: }
155:
156: /* (non-Javadoc)
157: * @see java.lang.Object#equals(java.lang.Object)
158: */
159: public boolean equals(Object obj) {
160: return delegate.equals(obj);
161: }
162:
163: /* (non-Javadoc)
164: * @see java.lang.Object#hashCode()
165: */
166: public int hashCode() {
167: return delegate.hashCode();
168: }
169:
170: /* (non-Javadoc)
171: * @see java.lang.Object#toString()
172: */
173: public String toString() {
174: return delegate.toString();
175: }
176:
177: /**
178: * @deprecated
179: */
180: public MetaMethod pickMethod(String methodName, Class[] arguments) {
181: return delegate.pickMethod(methodName, arguments);
182: }
183:
184: /**
185: * @deprecated
186: */
187: protected MetaMethod retrieveMethod(String methodName,
188: Class[] arguments) {
189: return delegate.retrieveMethod(methodName, arguments);
190: }
191: }
|