KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tonbeller > jpivot > olap > mdxparse > QueryAxis


1 /*
2  * ====================================================================
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) 2003-2004 TONBELLER AG.
7  * All Rights Reserved.
8  * You must accept the terms of that agreement to use this software.
9  * ====================================================================
10  *
11  *
12  */

13 package com.tonbeller.jpivot.olap.mdxparse;
14
15 import java.util.List JavaDoc;
16
17 /**
18  * MDX query axis
19  */

20 public class QueryAxis implements Exp {
21
22   private String JavaDoc name;
23   private boolean nonEmpty;
24   private Exp exp;
25   private List JavaDoc dimProps; // DIMENSION PROPERTIES
26

27   /**
28    * c'tor
29    * @see java.lang.Object#Object()
30    */

31   public QueryAxis(boolean nonEmpty, Exp exp, String JavaDoc name) {
32     this.nonEmpty = nonEmpty;
33     this.exp = exp;
34     this.name = name;
35   }
36
37   /**
38    * Returns the exp.
39    * @return Exp
40    */

41   public Exp getExp() {
42     return exp;
43   }
44
45   /**
46    * Returns the name.
47    * @return String
48    */

49   public String JavaDoc getName() {
50     return name;
51   }
52
53   /**
54    * Returns the nonEmpty.
55    * @return boolean
56    */

57   public boolean isNonEmpty() {
58     return nonEmpty;
59   }
60
61   /**
62    * Sets the exp.
63    * @param exp The exp to set
64    */

65   public void setExp(Exp exp) {
66     this.exp = exp;
67   }
68
69   /**
70    * Sets the name.
71    * @param name The name to set
72    */

73   public void setName(String JavaDoc name) {
74     this.name = name;
75   }
76
77   /**
78    * Sets the nonEmpty.
79    * @param nonEmpty The nonEmpty to set
80    */

81   public void setNonEmpty(boolean nonEmpty) {
82     this.nonEmpty = nonEmpty;
83   }
84
85   /**
86    * format to MDX
87    */

88   public String JavaDoc toMdx() {
89     StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
90     if (nonEmpty) {
91       sb.append("NON EMPTY ");
92     }
93     sb.append(exp.toMdx());
94     if (dimProps != null && dimProps.size() > 0) {
95       sb.append(" DIMENSION PROPERTIES ");
96       for (int i = 0; i < dimProps.size(); i++) {
97         if (i > 0)
98           sb.append(',');
99         sb.append(((CompoundId) dimProps.get(i)).toMdx());
100       }
101     }
102     sb.append(" ON ");
103     sb.append(name);
104     return sb.toString();
105   }
106
107   /**
108    *
109    * @see java.lang.Object#clone()
110    */

111   public Object JavaDoc clone() {
112     QueryAxis qa = new QueryAxis(nonEmpty, (Exp) exp.clone(), name);
113     qa.setDimProps(dimProps);
114     return qa;
115   }
116
117   /**
118    * @return
119    */

120   public List JavaDoc getDimProps() {
121     return dimProps;
122   }
123
124   /**
125    * @param dimProps
126    */

127   public void setDimProps(List JavaDoc dimProps) {
128     this.dimProps = dimProps;
129   }
130
131   /**
132    * @see com.tonbeller.jpivot.olap.mdxparse.Exp#accept
133    */

134   public void accept(ExpVisitor visitor) {
135     visitor.visitQueryAxis(this);
136   }
137
138 } // End QueryAxis
139
Popular Tags