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