001/* 002// Licensed to Julian Hyde under one or more contributor license 003// agreements. See the NOTICE file distributed with this work for 004// additional information regarding copyright ownership. 005// 006// Julian Hyde licenses this file to you under the Apache License, 007// Version 2.0 (the "License"); you may not use this file except in 008// compliance with the License. You may obtain a copy of the License at: 009// 010// http://www.apache.org/licenses/LICENSE-2.0 011// 012// Unless required by applicable law or agreed to in writing, software 013// distributed under the License is distributed on an "AS IS" BASIS, 014// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015// See the License for the specific language governing permissions and 016// limitations under the License. 017*/ 018package org.olap4j.mdx; 019 020/** 021 * Interface for a visitor to an MDX parse tree. 022 * 023 * <p>Together with the 024 * {@link org.olap4j.mdx.ParseTreeNode#accept(ParseTreeVisitor)} method, an 025 * class implementing this interface implements a visitor pattern, to allow 026 * an algorithm to efficiently traverse a parse tree and perform an action at 027 * each node dependent upon the type of each node. 028 * 029 * @author jhyde 030 * @since Jul 21, 2006 031 */ 032public interface ParseTreeVisitor<T> { 033 /** 034 * Visits a select statement. 035 * 036 * @param selectNode Node representing a select statement 037 * 038 * @return value yielded by visiting the node 039 * 040 * @see SelectNode#accept(ParseTreeVisitor) 041 */ 042 T visit(SelectNode selectNode); 043 044 /** 045 * Visits an axis of a select statement. 046 * 047 * @param axis Node representing an axis 048 * 049 * @return value yielded by visiting the node 050 * 051 * @see AxisNode#accept(ParseTreeVisitor) 052 */ 053 T visit(AxisNode axis); 054 055 /** 056 * Visits a member declaration. 057 * 058 * @param calcMemberNode Node representing a member declaration 059 * 060 * @return value yielded by visiting the node 061 * 062 * @see WithMemberNode#accept(ParseTreeVisitor) 063 */ 064 T visit(WithMemberNode calcMemberNode); 065 066 /** 067 * Visits a set declaration. 068 * 069 * @param calcSetNode Node representing a set declaration 070 * 071 * @return value yielded by visiting the node 072 * 073 * @see WithSetNode#accept(ParseTreeVisitor) 074 */ 075 T visit(WithSetNode calcSetNode); 076 077 /** 078 * Visits a call to an operator or function. 079 * 080 * @param call Node representing a call to an operator or function 081 * 082 * @see CallNode#accept(ParseTreeVisitor) 083 * 084 * @return value yielded by visiting the node 085 */ 086 T visit(CallNode call); 087 088 /** 089 * Visits an identifier. 090 * 091 * @param id Node representing an identifier 092 * 093 * @return value yielded by visiting the node 094 * 095 * @see IdentifierNode#accept(ParseTreeVisitor) 096 */ 097 T visit(IdentifierNode id); 098 099 /** 100 * Visits a parameter. 101 * 102 * @param parameterNode Node representing use of a parameter 103 * 104 * @return value yielded by visiting the node 105 * 106 * @see ParameterNode#accept(ParseTreeVisitor) 107 */ 108 T visit(ParameterNode parameterNode); 109 110 /** 111 * Visits a use of a {@link org.olap4j.metadata.Cube} 112 * in a select statement. 113 * 114 * @param cubeNode Node representing a use of a Cube 115 * 116 * @return value yielded by visiting the node 117 * 118 * @see CubeNode#accept(ParseTreeVisitor) 119 */ 120 T visit(CubeNode cubeNode); 121 122 /** 123 * Visits a use of a {@link org.olap4j.metadata.Dimension} 124 * in a select statement. 125 * 126 * @param dimensionNode Node representing a use of a Dimension 127 * 128 * @return value yielded by visiting the node 129 * 130 * @see DimensionNode#accept(ParseTreeVisitor) 131 */ 132 T visit(DimensionNode dimensionNode); 133 134 /** 135 * Visits a use of a {@link org.olap4j.metadata.Hierarchy} 136 * in a select statement. 137 * 138 * @param hierarchyNode Node representing a use of a Hierarchy 139 * 140 * @return value yielded by visiting the node 141 * 142 * @see HierarchyNode#accept(ParseTreeVisitor) 143 */ 144 T visit(HierarchyNode hierarchyNode); 145 146 /** 147 * Visits a use of a {@link org.olap4j.metadata.Level} 148 * in a select statement. 149 * 150 * @param levelNode Node representing a use of a Level 151 * 152 * @return value yielded by visiting the node 153 * 154 * @see LevelNode#accept(ParseTreeVisitor) 155 */ 156 T visit(LevelNode levelNode); 157 158 /** 159 * Visits a use of a {@link org.olap4j.metadata.Member} 160 * in a select statement. 161 * 162 * @param memberNode Node representing a use of a Member 163 * 164 * @return value yielded by visiting the node 165 * 166 * @see MemberNode#accept(ParseTreeVisitor) 167 */ 168 T visit(MemberNode memberNode); 169 170 /** 171 * Visits a literal. 172 * 173 * @param literalNode Node representing a Literal 174 * 175 * @return value yielded by visiting the node 176 * 177 * @see LiteralNode#accept(ParseTreeVisitor) 178 */ 179 T visit(LiteralNode literalNode); 180 181 /** 182 * Visits a property-value pair. 183 * 184 * @param propertyValueNode Node representing a property-value pair 185 * 186 * @return value yielded by visiting the node 187 * 188 * @see PropertyValueNode#accept(ParseTreeVisitor) 189 */ 190 T visit(PropertyValueNode propertyValueNode); 191 192 /** 193 * Visits a property-value pair. 194 * 195 * @param drillThroughNode Node representing a drill-through statement 196 * 197 * @return value yielded by visiting the node 198 * 199 * @see DrillThroughNode#accept(ParseTreeVisitor) 200 */ 201 T visit(DrillThroughNode drillThroughNode); 202} 203 204// End ParseTreeVisitor.java