001/* 002// This software is subject to the terms of the Eclipse Public License v1.0 003// Agreement, available at the following URL: 004// http://www.eclipse.org/legal/epl-v10.html. 005// You must accept the terms of that agreement to use this software. 006// 007// Copyright (C) 2006-2009 Pentaho 008// All Rights Reserved. 009*/ 010package mondrian.mdx; 011 012import mondrian.olap.*; 013 014/** 015 * Default implementation of the visitor interface, {@link MdxVisitor}. 016 * 017 * <p>The method implementations just ask the child nodes to 018 * {@link Exp#accept(MdxVisitor)} this visitor. 019 * 020 * @author jhyde 021 * @since Jul 21, 2006 022 */ 023public class MdxVisitorImpl implements MdxVisitor { 024 private boolean shouldVisitChildren = true; 025 026 public boolean shouldVisitChildren() { 027 boolean returnValue = shouldVisitChildren; 028 turnOnVisitChildren(); 029 return returnValue; 030 } 031 032 public void turnOnVisitChildren() { 033 shouldVisitChildren = true; 034 } 035 036 public void turnOffVisitChildren() { 037 shouldVisitChildren = false; 038 } 039 040 public Object visit(Query query) { 041 return null; 042 } 043 044 public Object visit(QueryAxis queryAxis) { 045 return null; 046 } 047 048 public Object visit(Formula formula) { 049 return null; 050 } 051 052 public Object visit(UnresolvedFunCall call) { 053 return null; 054 } 055 056 public Object visit(ResolvedFunCall call) { 057 return null; 058 } 059 060 public Object visit(Id id) { 061 return null; 062 } 063 064 public Object visit(ParameterExpr parameterExpr) { 065 return null; 066 } 067 068 public Object visit(DimensionExpr dimensionExpr) { 069 // do nothing 070 return null; 071 } 072 073 public Object visit(HierarchyExpr hierarchyExpr) { 074 // do nothing 075 return null; 076 } 077 078 public Object visit(LevelExpr levelExpr) { 079 // do nothing 080 return null; 081 } 082 083 public Object visit(MemberExpr memberExpr) { 084 // do nothing 085 return null; 086 } 087 088 public Object visit(NamedSetExpr namedSetExpr) { 089 // do nothing 090 return null; 091 } 092 093 public Object visit(Literal literal) { 094 // do nothing 095 return null; 096 } 097 098 /** 099 * Visits an array of expressions. Returns the same array if none of the 100 * expressions are changed, otherwise a new array. 101 * 102 * @param args Array of expressions 103 * @return Array of visited expressions; same as {@code args} iff none of 104 * the expressions are changed. 105 */ 106 protected Exp[] visitArray(Exp[] args) { 107 Exp[] newArgs = args; 108 for (int i = 0; i < args.length; i++) { 109 Exp arg = args[i]; 110 Exp newArg = (Exp) arg.accept(this); 111 if (newArg != arg) { 112 if (newArgs == args) { 113 newArgs = args.clone(); 114 } 115 newArgs[i] = newArg; 116 } 117 } 118 return newArgs; 119 } 120} 121 122// End MdxVisitorImpl.java