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) 2010-2010 Pentaho 008// All Rights Reserved. 009*/ 010package mondrian.olap; 011 012import java.io.PrintWriter; 013import java.util.List; 014 015/** 016 * Drill through statement. 017 * 018 * @author jhyde 019 */ 020public class DrillThrough extends QueryPart { 021 private final Query query; 022 private final int maxRowCount; 023 private final int firstRowOrdinal; 024 private final List<Exp> returnList; 025 026 /** 027 * Creates a DrillThrough. 028 * 029 * @param query Query 030 * @param maxRowCount Maximum number of rows to return, or -1 031 * @param firstRowOrdinal Ordinal of first row to return, or -1 032 * @param returnList List of columns to return 033 */ 034 DrillThrough( 035 Query query, 036 int maxRowCount, 037 int firstRowOrdinal, 038 List<Exp> returnList) 039 { 040 this.query = query; 041 this.maxRowCount = maxRowCount; 042 this.firstRowOrdinal = firstRowOrdinal; 043 this.returnList = returnList; 044 } 045 046 @Override 047 public void unparse(PrintWriter pw) { 048 pw.print("DRILLTHROUGH"); 049 if (maxRowCount >= 0) { 050 pw.print(" MAXROWS "); 051 pw.print(maxRowCount); 052 } 053 if (firstRowOrdinal >= 0) { 054 pw.print(" FIRSTROWSET "); 055 pw.print(firstRowOrdinal); 056 } 057 pw.print(" "); 058 query.unparse(pw); 059 if (returnList != null) { 060 ExpBase.unparseList( 061 pw, returnList.toArray(new Exp[returnList.size()]), 062 " RETURN ", ", ", ""); 063 } 064 } 065 066 @Override 067 public Object[] getChildren() { 068 return new Object[] {maxRowCount, firstRowOrdinal, query, returnList}; 069 } 070 071 public Query getQuery() { 072 return query; 073 } 074 075 public int getMaxRowCount() { 076 return maxRowCount; 077 } 078 079 public int getFirstRowOrdinal() { 080 return firstRowOrdinal; 081 } 082 083 public List<Exp> getReturnList() { 084 return returnList; 085 } 086} 087 088// End DrillThrough.java