KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > mondrian > olap > MemberProperty


1 /*
2 // $Id: //open/mondrian/src/main/mondrian/olap/MemberProperty.java#19 $
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) 2000-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, 1 March, 2000
12 */

13
14 package mondrian.olap;
15 import java.io.PrintWriter JavaDoc;
16
17 /**
18  * Member property or solve order specification.
19  */

20 public class MemberProperty extends QueryPart {
21
22     private final String JavaDoc name;
23     private Exp exp;
24
25     public MemberProperty(String JavaDoc name, Exp exp) {
26         this.name = name;
27         this.exp = exp;
28     }
29
30     protected Object JavaDoc clone() {
31         return new MemberProperty(name, (Exp) exp.clone());
32     }
33
34     static MemberProperty[] cloneArray(MemberProperty[] x) {
35         MemberProperty[] x2 = new MemberProperty[x.length];
36         for (int i = 0; i < x.length; i++) {
37             x2[i] = (MemberProperty) x[i].clone();
38         }
39         return x2;
40     }
41
42     void resolve(Validator validator) {
43         exp = validator.validate(exp, false);
44     }
45
46     public Exp getExp() {
47         return exp;
48     }
49
50     public String JavaDoc getName() {
51         return name;
52     }
53
54     public Object JavaDoc[] getChildren() {
55         return new Exp[] {exp};
56     }
57
58     public void unparse(PrintWriter JavaDoc pw) {
59         pw.print(name + " = ");
60         exp.unparse(pw);
61     }
62
63     /**
64      * Retrieves a property by name from an array.
65      */

66     static Exp get(MemberProperty[] a, String JavaDoc name) {
67         // TODO: Linear search may be a performance problem.
68
for (int i = 0; i < a.length; i++) {
69             if (Util.equalName(a[i].name, name)) {
70                 return a[i].exp;
71             }
72         }
73         return null;
74     }
75 }
76
77
78 // End MemberProperty.java
79
Popular Tags