KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > mondrian > olap > MemberFormatter


1 /*
2 // $Id: //open/mondrian/src/main/mondrian/olap/MemberFormatter.java#4 $
3 // This software is subject to the terms of the Common Public License
4 // Agreement, available at the following URL:
5 // http://www.opensource.org/licenses/cpl.html.
6 // Copyright (C) 2004-2005 TONBELLER AG
7 // All Rights Reserved.
8 // You must accept the terms of that agreement to use this software.
9 */

10 package mondrian.olap;
11
12 /**
13  * This interface provides an SPI to redefine the caption displayed
14  * for members.
15  *
16  * <p>For example, the following class displays members of the time
17  * dimension as "01-JAN-2005".
18  *
19  * <blockquote>
20  * <code>
21  * public class TimeMemberFormatter implements MemberFormatter {<br/>
22  * &nbsp;&nbsp;&nbsp;&nbsp;public String formatMember(Member member) {<br/>
23  * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SimpleDateFormat inFormat =<br/>
24  * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.S");<br/>
25  * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SimpleDateFormat outFormat =<br/>
26  * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;new SimpleDateFormat("dd-MMM-yyyy");<br/>
27  * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;try {<br/>
28  * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Date date = inFormat.parse(in.getName());<br/>
29  * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return outFormat.format(data);<br/>
30  * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} catch (ParseException e) {<br/>
31  * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;e.printStackTrace();<br/>
32  * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return "error";<br/>
33  * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br/>
34  * &nbsp;&nbsp;&nbsp;&nbsp;}<br/>
35  * }<br/>
36  * </code>
37  * </blockquote>
38  *
39  * @author hhaas
40  * @since 6 October, 2004
41  * @version $Id: //open/mondrian/src/main/mondrian/olap/MemberFormatter.java#4 $
42  */

43 public interface MemberFormatter {
44     /**
45      * Returns the string to be displayed as a caption for a given member.
46      */

47     String JavaDoc formatMember(Member m);
48 }
49
50 // End MemberFormatter.java
51

52
Popular Tags