View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    * 
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   * 
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */ 
17  package org.apache.commons.betwixt.expression;
18  
19  /** <p><code>EmptyExpression</code> returns the same value as is passed in. </p>
20    * 
21    * <p> See {@link #evaluate}. </p>
22    *
23    * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
24    * @version $Revision: 438373 $
25    */
26  public class EmptyExpression implements Expression {
27      
28      /** Don't need more than one <code>EmptyExpression</code>*/
29      private static final EmptyExpression singleton = new EmptyExpression();
30      
31      /**
32       * Gets the singleton instance.
33       * @return the EmptyExpression singleton. 
34       */
35      public static EmptyExpression getInstance() {
36          return singleton;
37      }
38      
39      /** Should this be private?
40       */
41      public EmptyExpression() {
42      }
43      
44      /** Return the bean we're evaluating.
45       * @see org.apache.commons.betwixt.expression.Expression
46       */ 
47      public Object evaluate(Context context) {
48          return context.getBean();
49      }
50      
51      /** Do nothing
52       * @see org.apache.commons.betwixt.expression.Expression
53       */ 
54      public void update(Context context, String newValue) {
55          // do nothing
56      }
57      
58      /**
59       * Return something useful for logging.
60       * @return short name for this class
61       */
62      public String toString() {
63          return "EmptyExpression";
64      }
65      
66  }