KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > mondrian > olap > ResultStyleException


1 /*
2 // $Id: //open/mondrian/src/main/mondrian/olap/ResultStyleException.java#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) 2004-2005 TONBELLER AG
7 // All Rights Reserved.
8 // You must accept the terms of that agreement to use this software.
9 */

10 package mondrian.olap;
11
12 import mondrian.calc.ExpCompiler.ResultStyle;
13 /**
14  * Exception which indicates some resource limit was exceeded.
15  *
16  * @version $Id: //open/mondrian/src/main/mondrian/olap/ResultStyleException.java#2 $
17  */

18 public class ResultStyleException extends MondrianException {
19     public static ResultStyleException generate(ResultStyle[] producer,
20             ResultStyle[] consumer) {
21         StringBuffer JavaDoc buf = new StringBuffer JavaDoc();
22         buf.append("Producer expected ResultStyles: ");
23         buf.append('{');
24         for (int i = 0; i < producer.length; i++) {
25             if (i > 0) {
26                 buf.append(',');
27             }
28             buf.append(producer[i]);
29         }
30         buf.append('}');
31         buf.append(" but Consumer wanted: ");
32         buf.append('{');
33         for (int i = 0; i < consumer.length; i++) {
34             if (i > 0) {
35                 buf.append(',');
36             }
37             buf.append(consumer[i]);
38         }
39         buf.append('}');
40         throw new ResultStyleException(buf.toString());
41     }
42     public static ResultStyleException generateBadType(ResultStyle[] wanted,
43             ResultStyle got) {
44         StringBuffer JavaDoc buf = new StringBuffer JavaDoc();
45         buf.append("Wanted ResultStyles: ");
46         buf.append('{');
47         for (int i = 0; i < wanted.length; i++) {
48             if (i > 0) {
49                 buf.append(',');
50             }
51             buf.append(wanted[i]);
52         }
53         buf.append('}');
54         buf.append(" but got: ");
55         buf.append(got);
56         throw new ResultStyleException(buf.toString());
57     }
58
59     public ResultStyleException(String JavaDoc message) {
60         super(message);
61     }
62 }
63
64 // End ResultStyleException.java
65
Popular Tags