Skip to content

Commit

Permalink
MONDRIAN: Implement RANK with 3 arguments.
Browse files Browse the repository at this point in the history
   Add documentation to MemberFormatter.

[git-p4: depot-paths = "//open/mondrian/": change = 3754]
  • Loading branch information
julianhyde committed Jun 28, 2005
1 parent 97fde98 commit 4577dab
Show file tree
Hide file tree
Showing 6 changed files with 574 additions and 317 deletions.
53 changes: 43 additions & 10 deletions src/main/mondrian/olap/MemberFormatter.java
@@ -1,18 +1,51 @@
/*
//$Id$
//This software is subject to the terms of the Common Public License
//Agreement, available at the following URL:
//http://www.opensource.org/licenses/cpl.html.
//Copyright (C) 2004-2005 TONBELLER AG
//All Rights Reserved.
//You must accept the terms of that agreement to use this software.
// $Id$
// This software is subject to the terms of the Common Public License
// Agreement, available at the following URL:
// http://www.opensource.org/licenses/cpl.html.
// Copyright (C) 2004-2005 TONBELLER AG
// All Rights Reserved.
// You must accept the terms of that agreement to use this software.
*/
package mondrian.olap;

/**
* this interface provides a user exit to redefine
* the member caption beeing displayed.
* This interface provides an SPI to redefine the caption displayed
* for members.
*
* <p>For example, the following class displays members of the time
* dimension as "01-JAN-2005".
*
* <blockquote>
* <code>
* public class TimeMemberFormatter implements MemberFormatter {<br/>
* &nbsp;&nbsp;&nbsp;&nbsp;public String formatMember(Member member) {<br/>
* &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SimpleDateFormat inFormat =<br/>
* &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.S");<br/>
* &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SimpleDateFormat outFormat =<br/>
* &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;new SimpleDateFormat("dd-MMM-yyyy");<br/>
* &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;try {<br/>
* &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Date date = inFormat.parse(in.getName());<br/>
* &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return outFormat.format(data);<br/>
* &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} catch (ParseException e) {<br/>
* &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;e.printStackTrace();<br/>
* &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return "error";<br/>
* &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br/>
* &nbsp;&nbsp;&nbsp;&nbsp;}<br/>
* }<br/>
* </code>
* </blockquote>
*
* @author hhaas
* @since 6 October, 2004
* @version $Id$
*/
public interface MemberFormatter {
/**
* Returns the string to be displayed as a caption for a given member.
*/
String formatMember(Member m);
} // MemberFormatter
}

// End MemberFormatter.java

13 changes: 11 additions & 2 deletions src/main/mondrian/olap/Util.java
Expand Up @@ -107,7 +107,7 @@ public static String quoteMdxIdentifier(String[] ids) {
public static boolean equals(Object s, Object t) {
return (s == null) ? (t == null) : s.equals(t);
}

/**
* Returns true if two strings are equal, or are both null.
* Takes into account the case sensitive option.
Expand Down Expand Up @@ -520,10 +520,19 @@ public static boolean isEmpty(String s) {
* A <code>NullCellValue</code> is a placeholder value used when cells have
* a null value. It is a singleton.
*/
public static class NullCellValue {
public static class NullCellValue implements Comparable {
public String toString() {
return "#NULL";
}

public int compareTo(Object o) {
// Null is less than every other value.
if (o == this) {
return 0;
} else {
return -1;
}
}
};

public static class ErrorCellValue {
Expand Down

0 comments on commit 4577dab

Please sign in to comment.