001 /* 002 // $Id: //open/mondrian/src/main/mondrian/olap/ExpBase.java#25 $ 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) 1999-2002 Kana Software, Inc. 007 // Copyright (C) 2001-2006 Julian Hyde and others 008 // All Rights Reserved. 009 // You must accept the terms of that agreement to use this software. 010 // 011 // jhyde, 20 January, 1999 012 */ 013 014 package mondrian.olap; 015 import mondrian.calc.Calc; 016 import mondrian.calc.ExpCompiler; 017 018 import java.io.PrintWriter; 019 020 /** 021 * Skeleton implementation of {@link Exp} interface. 022 */ 023 public abstract class ExpBase 024 extends QueryPart 025 implements Exp { 026 027 028 protected static Exp[] cloneArray(Exp[] a) { 029 Exp[] a2 = new Exp[a.length]; 030 for (int i = 0; i < a.length; i++) { 031 a2[i] = a[i].clone(); 032 } 033 return a2; 034 } 035 036 protected ExpBase() { 037 } 038 039 public abstract Exp clone(); 040 041 public static void unparseList( 042 PrintWriter pw, 043 Exp[] exps, 044 String start, 045 String mid, 046 String end) 047 { 048 pw.print(start); 049 for (int i = 0; i < exps.length; i++) { 050 if (i > 0) { 051 pw.print(mid); 052 } 053 exps[i].unparse(pw); 054 } 055 pw.print(end); 056 } 057 058 public static int[] getTypes(Exp[] exps) { 059 int[] types = new int[exps.length]; 060 for (int i = 0; i < exps.length; i++) { 061 types[i] = exps[i].getCategory(); 062 } 063 return types; 064 } 065 066 public Calc accept(ExpCompiler compiler) { 067 throw new UnsupportedOperationException(this.toString()); 068 } 069 } 070 071 // End ExpBase.java