View Javadoc

1   package org.apache.velocity.util.introspection;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import java.util.Iterator;
23  
24  /**
25   * Default implementation of a {@link ChainableUberspector chainable uberspector} that forwards all calls to the wrapped
26   * uberspector (when that is possible). It should be used as the base class for all chainable uberspectors.
27   * 
28   * @version $Id: $
29   * @since 1.6
30   * @see ChainableUberspector
31   */
32  public abstract class AbstractChainableUberspector extends UberspectImpl implements ChainableUberspector
33  {
34      /** The wrapped (decorated) uberspector. */
35      protected Uberspect inner;
36  
37      /**
38       * {@inheritDoc}
39       * 
40       * @see ChainableUberspector#wrap(org.apache.velocity.util.introspection.Uberspect)
41       * @see #inner
42       */
43      public void wrap(Uberspect inner)
44      {
45          this.inner = inner;
46      }
47  
48      /**
49       * init - the chainable uberspector is responsible for the initialization of the wrapped uberspector
50       * 
51       * @see org.apache.velocity.util.introspection.Uberspect#init()
52       */
53      //@Override
54      public void init()
55      {
56          if (this.inner != null) {
57              this.inner.init();
58          }
59      }
60  
61      /**
62       * {@inheritDoc}
63       * 
64       * @see org.apache.velocity.util.introspection.Uberspect#getIterator(java.lang.Object,
65       *      org.apache.velocity.util.introspection.Info)
66       */
67      //@SuppressWarnings("unchecked")
68      //@Override
69      public Iterator getIterator(Object obj, Info i) throws Exception
70      {
71          return (this.inner != null) ? this.inner.getIterator(obj, i) : null;
72      }
73  
74      /**
75       * {@inheritDoc}
76       * 
77       * @see org.apache.velocity.util.introspection.Uberspect#getMethod(java.lang.Object, java.lang.String,
78       *      java.lang.Object[], org.apache.velocity.util.introspection.Info)
79       */
80      //@Override
81      public VelMethod getMethod(Object obj, String methodName, Object[] args, Info i)
82          throws Exception
83      {
84          return (this.inner != null) ? this.inner.getMethod(obj, methodName, args, i) : null;
85      }
86  
87      /**
88       * {@inheritDoc}
89       * 
90       * @see org.apache.velocity.util.introspection.Uberspect#getPropertyGet(java.lang.Object, java.lang.String,
91       *      org.apache.velocity.util.introspection.Info)
92       */
93      //@Override
94      public VelPropertyGet getPropertyGet(Object obj, String identifier, Info i)
95          throws Exception
96      {
97          return (this.inner != null) ? this.inner.getPropertyGet(obj, identifier, i) : null;
98      }
99  
100     /**
101      * {@inheritDoc}
102      * 
103      * @see org.apache.velocity.util.introspection.Uberspect#getPropertySet(java.lang.Object, java.lang.String,
104      *      java.lang.Object, org.apache.velocity.util.introspection.Info)
105      */
106     //@Override
107     public VelPropertySet getPropertySet(Object obj, String identifier, Object arg, Info i)
108         throws Exception
109     {
110         return (this.inner != null) ? this.inner.getPropertySet(obj, identifier, arg, i) : null;
111     }
112 }