KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > mondrian > olap > ExpBase


1 /*
2 // $Id: //open/mondrian/src/main/mondrian/olap/ExpBase.java#25 $
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 import mondrian.calc.Calc;
16 import mondrian.calc.ExpCompiler;
17
18 import java.io.PrintWriter JavaDoc;
19
20 /**
21  * Skeleton implementation of {@link Exp} interface.
22  */

23 public abstract class ExpBase
24     extends QueryPart
25     implements Exp {
26
27
28     protected static Exp[] cloneArray(Exp[] a) {
29         Exp[] a2 = new Exp[a.length];
30         for (int i = 0; i < a.length; i++) {
31             a2[i] = a[i].clone();
32         }
33         return a2;
34     }
35
36     protected ExpBase() {
37     }
38
39     public abstract Exp clone();
40
41     public static void unparseList(
42         PrintWriter JavaDoc pw,
43         Exp[] exps,
44         String JavaDoc start,
45         String JavaDoc mid,
46         String JavaDoc end)
47     {
48         pw.print(start);
49         for (int i = 0; i < exps.length; i++) {
50             if (i > 0) {
51                 pw.print(mid);
52             }
53             exps[i].unparse(pw);
54         }
55         pw.print(end);
56     }
57
58     public static int[] getTypes(Exp[] exps) {
59         int[] types = new int[exps.length];
60         for (int i = 0; i < exps.length; i++) {
61             types[i] = exps[i].getCategory();
62         }
63         return types;
64     }
65
66     public Calc accept(ExpCompiler compiler) {
67         throw new UnsupportedOperationException JavaDoc(this.toString());
68     }
69 }
70
71 // End ExpBase.java
72
Popular Tags