mondrian.util
Class UtilCompatibleJdk15

java.lang.Object
  extended by mondrian.util.UtilCompatibleJdk15
All Implemented Interfaces:
UtilCompatible
Direct Known Subclasses:
UtilCompatibleJdk16

public class UtilCompatibleJdk15
extends Object
implements UtilCompatible

Implementation of UtilCompatible which runs in JDK 1.5.

Prior to JDK 1.5, this class should never be loaded. Applications should instantiate this class via Class.forName(String) or better, use methods in Util, and not instantiate it at all.

Since:
Feb 5, 2007
Author:
jhyde

Constructor Summary
UtilCompatibleJdk15()
           
 
Method Summary
<T extends Comparable<T>>
int
binarySearch(T[] ts, int start, int end, T t)
          As Arrays.binarySearch(Object[], int, int, Object), but available pre-JDK 1.6.
 void cancelAndCloseStatement(Statement stmt)
          Cancels and closes a SQL Statement object.
<T> T
compileScript(Class<T> iface, String script, String engineName)
          Compiles a script to yield a Java interface.
 String generateUuidString()
           
<T> T
getAnnotation(Method method, String annotationClassName, T defaultValue)
           
 Util.MemoryInfo getMemoryInfo()
          Creates an object from which to get information about system memory use.
 BigDecimal makeBigDecimalFromDouble(double d)
          This generates a BigDecimal with a precision reflecting the precision of the input double.
<T> Set<T>
newIdentityHashSet()
          Creates a hash set that, like IdentityHashMap, compares keys using identity.
 Timer newTimer(String name, boolean isDaemon)
          Equivalent to Timer.Timer(String, boolean).
 String quotePattern(String s)
           
<T> void
threadLocalRemove(ThreadLocal<T> threadLocal)
          Removes a thread local from the current thread.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UtilCompatibleJdk15

public UtilCompatibleJdk15()
Method Detail

makeBigDecimalFromDouble

public BigDecimal makeBigDecimalFromDouble(double d)
This generates a BigDecimal with a precision reflecting the precision of the input double.

Specified by:
makeBigDecimalFromDouble in interface UtilCompatible
Parameters:
d - input double
Returns:
BigDecimal

quotePattern

public String quotePattern(String s)
Specified by:
quotePattern in interface UtilCompatible

getAnnotation

public <T> T getAnnotation(Method method,
                           String annotationClassName,
                           T defaultValue)
Specified by:
getAnnotation in interface UtilCompatible

generateUuidString

public String generateUuidString()
Specified by:
generateUuidString in interface UtilCompatible

compileScript

public <T> T compileScript(Class<T> iface,
                           String script,
                           String engineName)
Description copied from interface: UtilCompatible
Compiles a script to yield a Java interface.

Specified by:
compileScript in interface UtilCompatible
Type Parameters:
T - Interface
Parameters:
iface - Interface script should implement
script - Script code
engineName - Name of engine (e.g. "JavaScript")
Returns:
Object that implements given interface

threadLocalRemove

public <T> void threadLocalRemove(ThreadLocal<T> threadLocal)
Description copied from interface: UtilCompatible
Removes a thread local from the current thread.

From JDK 1.5 onwards, calls ThreadLocal.remove(); before that, no-ops.

Specified by:
threadLocalRemove in interface UtilCompatible
Type Parameters:
T - Type
Parameters:
threadLocal - Thread local

getMemoryInfo

public Util.MemoryInfo getMemoryInfo()
Description copied from interface: UtilCompatible
Creates an object from which to get information about system memory use. From JDK 1.5 onwards, uses MemoryPoolMXBean.

Specified by:
getMemoryInfo in interface UtilCompatible
Returns:
Memory info

newTimer

public Timer newTimer(String name,
                      boolean isDaemon)
Description copied from interface: UtilCompatible
Equivalent to Timer.Timer(String, boolean). (Introduced in JDK 1.5.)

Specified by:
newTimer in interface UtilCompatible
Parameters:
name - the name of the associated thread
isDaemon - true if the associated thread should run as a daemon
Returns:
timer

cancelAndCloseStatement

public void cancelAndCloseStatement(Statement stmt)
Description copied from interface: UtilCompatible
Cancels and closes a SQL Statement object. If errors are encountered, they should be logged under Util.

Specified by:
cancelAndCloseStatement in interface UtilCompatible
Parameters:
stmt - The statement to close.

newIdentityHashSet

public <T> Set<T> newIdentityHashSet()
Description copied from interface: UtilCompatible
Creates a hash set that, like IdentityHashMap, compares keys using identity.

Specified by:
newIdentityHashSet in interface UtilCompatible
Type Parameters:
T - Element type
Returns:
Set

binarySearch

public <T extends Comparable<T>> int binarySearch(T[] ts,
                                                  int start,
                                                  int end,
                                                  T t)
Description copied from interface: UtilCompatible
As Arrays.binarySearch(Object[], int, int, Object), but available pre-JDK 1.6.

Specified by:
binarySearch in interface UtilCompatible

Get Mondrian at SourceForge.net. Fast, secure and free Open Source software downloads