001/* 002// This software is subject to the terms of the Eclipse Public License v1.0 003// Agreement, available at the following URL: 004// http://www.eclipse.org/legal/epl-v10.html. 005// You must accept the terms of that agreement to use this software. 006// 007// Copyright (C) 2004-2005 TONBELLER AG 008// Copyright (C) 2006-2011 Pentaho and others 009// All Rights Reserved. 010*/ 011package mondrian.olap; 012 013import mondrian.calc.ResultStyle; 014 015import java.util.List; 016 017/** 018 * Exception that indicates a compiler could not implement an expression in any 019 * of the result styles requested by the client. 020 * 021 * @author Richard Emberson 022 */ 023public 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 StringBuilder buf = new StringBuilder(); 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 return new ResultStyleException(buf.toString()); 067 } 068 069 public ResultStyleException(String message) { 070 super(message); 071 } 072} 073 074// End ResultStyleException.java