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     * &nbsp;&nbsp;&nbsp;&nbsp;public String formatMember(Member member) {<br/>
023     * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SimpleDateFormat inFormat =<br/>
024     * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.S");<br/>
025     * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SimpleDateFormat outFormat =<br/>
026     * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;new SimpleDateFormat("dd-MMM-yyyy");<br/>
027     * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;try {<br/>
028     * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Date date = inFormat.parse(in.getName());<br/>
029     * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return outFormat.format(data);<br/>
030     * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} catch (ParseException e) {<br/>
031     * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;e.printStackTrace();<br/>
032     * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return "error";<br/>
033     * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br/>
034     * &nbsp;&nbsp;&nbsp;&nbsp;}<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