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