001 /* 002 // $Id: //open/mondrian/src/main/mondrian/olap/MemberFormatter.java#4 $ 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 /** 013 * This interface provides an SPI to redefine the caption displayed 014 * for members. 015 * 016 * <p>For example, the following class displays members of the time 017 * dimension as "01-JAN-2005". 018 * 019 * <blockquote> 020 * <code> 021 * public class TimeMemberFormatter implements MemberFormatter {<br/> 022 * public String formatMember(Member member) {<br/> 023 * SimpleDateFormat inFormat =<br/> 024 * new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.S");<br/> 025 * SimpleDateFormat outFormat =<br/> 026 * new SimpleDateFormat("dd-MMM-yyyy");<br/> 027 * try {<br/> 028 * Date date = inFormat.parse(in.getName());<br/> 029 * return outFormat.format(data);<br/> 030 * } catch (ParseException e) {<br/> 031 * e.printStackTrace();<br/> 032 * return "error";<br/> 033 * }<br/> 034 * }<br/> 035 * }<br/> 036 * </code> 037 * </blockquote> 038 * 039 * @author hhaas 040 * @since 6 October, 2004 041 * @version $Id: //open/mondrian/src/main/mondrian/olap/MemberFormatter.java#4 $ 042 */ 043 public interface MemberFormatter { 044 /** 045 * Returns the string to be displayed as a caption for a given member. 046 */ 047 String formatMember(Member m); 048 } 049 050 // End MemberFormatter.java 051