001 /* 002 * Copyright 2006 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 org.codehaus.groovy.runtime.wrappers; 019 020 import groovy.lang.GroovyObject; 021 import groovy.lang.MetaClass; 022 023 /** 024 * @author John Wilson 025 * 026 */ 027 028 public class GroovyObjectWrapper extends Wrapper { 029 protected final GroovyObject wrapped; 030 031 public GroovyObjectWrapper(final GroovyObject wrapped, final Class constrainedType) { 032 super(constrainedType); 033 this.wrapped = wrapped; 034 } 035 036 public Object unwrap() { 037 return this.wrapped; 038 } 039 040 /** 041 * Note the rest of these method will only be used post 1.0 042 */ 043 044 /* (non-Javadoc) 045 * @see groovy.lang.GroovyObject#getProperty(java.lang.String) 046 */ 047 public Object getProperty(final String property) { 048 return this.wrapped.getProperty(property); 049 } 050 051 /* (non-Javadoc) 052 * @see groovy.lang.GroovyObject#invokeMethod(java.lang.String, java.lang.Object) 053 */ 054 public Object invokeMethod(final String name, final Object args) { 055 return this.wrapped.invokeMethod(name, args); 056 } 057 058 /* (non-Javadoc) 059 * @see groovy.lang.GroovyObject#setMetaClass(groovy.lang.MetaClass) 060 */ 061 public void setMetaClass(final MetaClass metaClass) { 062 this.wrapped.setMetaClass(metaClass); 063 } 064 065 /* (non-Javadoc) 066 * @see groovy.lang.GroovyObject#setProperty(java.lang.String, java.lang.Object) 067 */ 068 public void setProperty(final String property, final Object newValue) { 069 this.wrapped.setProperty(property, newValue); 070 } 071 072 protected Object getWrapped() { 073 return this.wrapped; 074 } 075 076 protected MetaClass getDelegatedMetaClass() { 077 return this.wrapped.getMetaClass(); 078 } 079 }