1 /***
2 * ConstantOperator.java
3 *
4 * $Author: mballesteros $
5 * $Date: 2003/11/28 19:18:03 $
6 * $Revision: 1.1 $
7 */
8 package net.sf.jec;
9
10 /*** ConstantOperator always returns a constant value (any object), given as a
11 * constructor's parameter.
12 * @author mballesteros
13 */
14 public class ConstantOperator extends Operator {
15
16 private Object constant;
17
18 /*** Builds a ConstantOperator given a "constant" object
19 * @param constant The constant object returned by this operator
20 */
21 public ConstantOperator(Object constant) {
22 this.constant = constant;
23 }
24
25 /*** Returns a function representation String for this operator
26 */
27 public String toFunctionString() {
28 return constant.toString();
29 }
30
31 /*** Returns an expression String representation for this operator
32 */
33 public String toExpressionString() {
34 return constant.toString();
35 }
36
37 /*** Returns the associated value to the given context and root context
38 * @param rootCtx The root context, needed for operators that require
39 * expression evaluation from root point. Example: Indexer operators
40 * @param ctx The current context where the operator will work over
41 */
42 protected final Object directMap(Object rootCtx, Object ctx) throws EvaluationException {
43 return this.constant;
44 }
45
46 }
This page was automatically generated by Maven