001 /* 002 // $Id: //open/mondrian/src/main/mondrian/olap/ResultStyleException.java#3 $ 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) 2004-2005 TONBELLER AG 007 // All Rights Reserved. 008 // You must accept the terms of that agreement to use this software. 009 */ 010 package mondrian.olap; 011 012 import mondrian.calc.ResultStyle; 013 014 import java.util.List; 015 016 /** 017 * Exception that indicates a compiler could not implement an expression in any 018 * of the result styles requested by the client. 019 * 020 * @version $Id: //open/mondrian/src/main/mondrian/olap/ResultStyleException.java#3 $ 021 * @author Richard Emberson 022 */ 023 public class ResultStyleException extends MondrianException { 024 public static ResultStyleException generate( 025 List<ResultStyle> producer, 026 List<ResultStyle> consumer) 027 { 028 StringBuilder buf = new StringBuilder(); 029 buf.append("Producer expected ResultStyles: "); 030 buf.append('{'); 031 for (int i = 0; i < producer.size(); i++) { 032 if (i > 0) { 033 buf.append(','); 034 } 035 buf.append(producer.get(i)); 036 } 037 buf.append('}'); 038 buf.append(" but Consumer wanted: "); 039 buf.append('{'); 040 for (int i = 0; i < consumer.size(); i++) { 041 if (i > 0) { 042 buf.append(','); 043 } 044 buf.append(consumer.get(i)); 045 } 046 buf.append('}'); 047 throw new ResultStyleException(buf.toString()); 048 } 049 050 public static ResultStyleException generateBadType( 051 List<ResultStyle> wanted, 052 ResultStyle got) 053 { 054 StringBuffer buf = new StringBuffer(); 055 buf.append("Wanted ResultStyles: "); 056 buf.append('{'); 057 for (int i = 0; i < wanted.size(); i++) { 058 if (i > 0) { 059 buf.append(','); 060 } 061 buf.append(wanted.get(i)); 062 } 063 buf.append('}'); 064 buf.append(" but got: "); 065 buf.append(got); 066 throw new ResultStyleException(buf.toString()); 067 } 068 069 public ResultStyleException(String message) { 070 super(message); 071 } 072 } 073 074 // End ResultStyleException.java