001    /*
002    // $Id: //open/mondrian/src/main/mondrian/calc/impl/DelegatingExpCompiler.java#10 $
003    // This software is subject to the terms of the Common Public License
004    // Agreement, available at the following URL:
005    // http://www.opensource.org/licenses/cpl.html.
006    // Copyright (C) 2006-2007 Julian Hyde
007    // All Rights Reserved.
008    // You must accept the terms of that agreement to use this software.
009    */
010    package mondrian.calc.impl;
011    
012    import mondrian.olap.*;
013    import mondrian.olap.type.Type;
014    import mondrian.calc.*;
015    
016    import java.util.List;
017    
018    /**
019     * Abstract implementation of {@link mondrian.calc.ExpCompiler}
020     *
021     * @author jhyde
022     * @version $Id: //open/mondrian/src/main/mondrian/calc/impl/DelegatingExpCompiler.java#10 $
023     * @since Jan 2, 2006
024     */
025    public class DelegatingExpCompiler implements ExpCompiler {
026        private final ExpCompiler parent;
027    
028        protected DelegatingExpCompiler(ExpCompiler parent) {
029            this.parent = parent;
030        }
031    
032        /**
033         * Hook for post-processing.
034         *
035         * @param exp Expression to compile
036         * @param calc Calculator created by compiler
037         * @param mutable Whether the result is mutuable
038         * @return Calculator after post-processing
039         */
040        protected Calc afterCompile(Exp exp, Calc calc, boolean mutable) {
041            return calc;
042        }
043    
044        public Evaluator getEvaluator() {
045            return parent.getEvaluator();
046        }
047    
048        public Validator getValidator() {
049            return parent.getValidator();
050        }
051    
052        public Calc compile(Exp exp) {
053            return parent.compile(exp);
054        }
055    
056        public Calc compileAs(
057            Exp exp,
058            Type resultType,
059            List<ResultStyle> preferredResultTypes)
060        {
061            return parent.compileAs(exp, resultType, preferredResultTypes);
062        }
063    
064        public MemberCalc compileMember(Exp exp) {
065            MemberCalc calc = parent.compileMember(exp);
066            return (MemberCalc) afterCompile(exp, calc, false);
067        }
068    
069        public LevelCalc compileLevel(Exp exp) {
070            final LevelCalc calc = parent.compileLevel(exp);
071            return (LevelCalc) afterCompile(exp, calc, false);
072        }
073    
074        public DimensionCalc compileDimension(Exp exp) {
075            final DimensionCalc calc = parent.compileDimension(exp);
076            return (DimensionCalc) afterCompile(exp, calc, false);
077        }
078    
079        public HierarchyCalc compileHierarchy(Exp exp) {
080            final HierarchyCalc calc = parent.compileHierarchy(exp);
081            return (HierarchyCalc) afterCompile(exp, calc, false);
082        }
083    
084        public IntegerCalc compileInteger(Exp exp) {
085            final IntegerCalc calc = parent.compileInteger(exp);
086            return (IntegerCalc) afterCompile(exp, calc, false);
087        }
088    
089        public StringCalc compileString(Exp exp) {
090            final StringCalc calc = parent.compileString(exp);
091            return (StringCalc) afterCompile(exp, calc, false);
092        }
093    
094        public DateTimeCalc compileDateTime(Exp exp) {
095            final DateTimeCalc calc = parent.compileDateTime(exp);
096            return (DateTimeCalc) afterCompile(exp, calc, false);
097        }
098    
099        public ListCalc compileList(Exp exp) {
100            return compileList(exp, false);
101        }
102    
103        public ListCalc compileList(Exp exp, boolean mutable) {
104            final ListCalc calc = parent.compileList(exp, mutable);
105            return (ListCalc) afterCompile(exp, calc, mutable);
106        }
107    
108        public IterCalc compileIter(Exp exp) {
109            final IterCalc calc = parent.compileIter(exp);
110            return (IterCalc) afterCompile(exp, calc, false);
111        }
112    
113        public BooleanCalc compileBoolean(Exp exp) {
114            final BooleanCalc calc = parent.compileBoolean(exp);
115            return (BooleanCalc) afterCompile(exp, calc, false);
116        }
117    
118        public DoubleCalc compileDouble(Exp exp) {
119            final DoubleCalc calc = parent.compileDouble(exp);
120            return (DoubleCalc) afterCompile(exp, calc, false);
121        }
122    
123        public TupleCalc compileTuple(Exp exp) {
124            final TupleCalc calc = parent.compileTuple(exp);
125            return (TupleCalc) afterCompile(exp, calc, false);
126        }
127    
128        public Calc compileScalar(Exp exp, boolean scalar) {
129            final Calc calc = parent.compileScalar(exp, scalar);
130            return afterCompile(exp, calc, false);
131        }
132    
133        public ParameterSlot registerParameter(Parameter parameter) {
134            return parent.registerParameter(parameter);
135        }
136    
137        public List<ResultStyle> getAcceptableResultStyles() {
138            return parent.getAcceptableResultStyles();
139        }
140    }
141    
142    // End DelegatingExpCompiler.java