001    /*
002     * Licensed to the Apache Software Foundation (ASF) under one or more
003     * contributor license agreements.  See the NOTICE file distributed with
004     * this work for additional information regarding copyright ownership.
005     * The ASF licenses this file to You under the Apache License, Version 2.0
006     * (the "License"); you may not use this file except in compliance with
007     * the License.  You may obtain a copy of the License at
008     * 
009     *      http://www.apache.org/licenses/LICENSE-2.0
010     * 
011     * Unless required by applicable law or agreed to in writing, software
012     * distributed under the License is distributed on an "AS IS" BASIS,
013     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014     * See the License for the specific language governing permissions and
015     * limitations under the License.
016     */ 
017    package org.apache.commons.betwixt.expression;
018    
019    /** <p><code>EmptyExpression</code> returns the same value as is passed in. </p>
020      * 
021      * <p> See {@link #evaluate}. </p>
022      *
023      * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
024      * @version $Revision: 438373 $
025      */
026    public class EmptyExpression implements Expression {
027        
028        /** Don't need more than one <code>EmptyExpression</code>*/
029        private static final EmptyExpression singleton = new EmptyExpression();
030        
031        /**
032         * Gets the singleton instance.
033         * @return the EmptyExpression singleton. 
034         */
035        public static EmptyExpression getInstance() {
036            return singleton;
037        }
038        
039        /** Should this be private?
040         */
041        public EmptyExpression() {
042        }
043        
044        /** Return the bean we're evaluating.
045         * @see org.apache.commons.betwixt.expression.Expression
046         */ 
047        public Object evaluate(Context context) {
048            return context.getBean();
049        }
050        
051        /** Do nothing
052         * @see org.apache.commons.betwixt.expression.Expression
053         */ 
054        public void update(Context context, String newValue) {
055            // do nothing
056        }
057        
058        /**
059         * Return something useful for logging.
060         * @return short name for this class
061         */
062        public String toString() {
063            return "EmptyExpression";
064        }
065        
066    }