1 /* 2 // $Id: //open/mondrian/src/main/mondrian/olap/Exp.java#19 $ 3 // This software is subject to the terms of the Common Public License 4 // Agreement, available at the following URL: 5 // http://www.opensource.org/licenses/cpl.html. 6 // Copyright (C) 1999-2002 Kana Software, Inc. 7 // Copyright (C) 2001-2006 Julian Hyde and others 8 // All Rights Reserved. 9 // You must accept the terms of that agreement to use this software. 10 // 11 // jhyde, 20 January, 1999 12 */ 13 14 package mondrian.olap; 15 16 import mondrian.olap.type.Type; 17 import mondrian.calc.Calc; 18 import mondrian.calc.ExpCompiler; 19 import mondrian.mdx.MdxVisitorImpl; 20 import mondrian.mdx.MdxVisitor; 21 22 import java.io.PrintWriter; 23 24 /** 25 * An <code>Exp</code> is an MDX expression. 26 * 27 * @author jhyde 28 * @since 1.0 29 * @version $Id: //open/mondrian/src/main/mondrian/olap/Exp.java#19 $ 30 */ 31 public interface Exp { 32 33 Exp clone(); 34 35 /** 36 * Returns the {@link Category} of the expression. 37 * 38 * @post Category.instance().isValid(return) 39 */ 40 int getCategory(); 41 42 /** 43 * Returns the type of this expression. Never null. 44 */ 45 Type getType(); 46 47 /** 48 * Writes the MDX representation of this expression to a print writer. 49 * Sub-expressions are invoked recursively. 50 * 51 * @param pw PrintWriter 52 */ 53 void unparse(PrintWriter pw); 54 55 /** 56 * Validates this expression. 57 * 58 * The validator acts in the role of 'visitor' (see Gang of Four 59 * 'visitor pattern'), and an expression in the role of 'visitee'. 60 * 61 * @param validator Validator contains validation context 62 * 63 * @return The validated expression; often but not always the same as 64 * this expression 65 */ 66 Exp accept(Validator validator); 67 68 /** 69 * Converts this expression into an a tree of expressions which can be 70 * efficiently evaluated. 71 * 72 * @param compiler 73 * @return A compiled expression 74 */ 75 Calc accept(ExpCompiler compiler); 76 77 /** 78 * Accepts a visitor to this Exp. 79 * The implementation should generally dispatches to the 80 * {@link MdxVisitor#visit} method appropriate to the type of expression. 81 * 82 * @param visitor Visitor 83 */ 84 Object accept(MdxVisitor visitor); 85 } 86 87 // End Exp.java 88