FileDocCategorySizeDatePackage
JavaPlatform.javaAPI DocGlassfish v2 API6786Tue May 22 16:54:34 BST 2007oracle.toplink.essentials.internal.helper

JavaPlatform

public class JavaPlatform extends Object
INTERNAL: JavaPlatform abstracts the version of the JDK we are using. It allows any operation which is dependant on JDK version to be called from a single place and then delegates the call to its JDKPlatform
see
JDPlatform
author
Tom Ware

Fields Summary
private static JDKPlatform
platform
public static final int
FALSE
public static final int
TRUE
public static final int
UNDEFINED
Constructors Summary
Methods Summary
public static intconformLike(java.lang.Object left, java.lang.Object right)
INTERNAL: Conform an expression which uses the operator "like" for an in-memory query

return
int int FALSE = 0 - if the expression does not conform int TRUE = 1 - if the expression does conform int UNDEFINED = 2 - if it cannot be determined if the expression conforms

        return getPlatform().conformLike(left, right);
    
private static oracle.toplink.essentials.internal.helper.JDKPlatformgetPlatform()
INTERNAL: Get the version of JDK being used from the Version class.

return
JDKPlatform a platform appropriate for the version of JDK being used.


                                    
        
        if (platform == null) {
            if (Version.isJDK15()) {
                try {
                    Class platformClass = null;
                    // use class.forName() to avoid loading the JDK 1.5 class unless it is needed.
                    if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()){
                        try {
                            platformClass = (Class)AccessController.doPrivileged(new PrivilegedClassForName("oracle.toplink.essentials.internal.helper.JDK15Platform"));
                        } catch (PrivilegedActionException exception) {
                        }
                    } else {
                        platformClass = oracle.toplink.essentials.internal.security.PrivilegedAccessHelper.getClassForName("oracle.toplink.essentials.internal.helper.JDK15Platform");
                    }                  
                    if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()){
                        try {
                            platform = (JDKPlatform)AccessController.doPrivileged(new PrivilegedNewInstanceFromClass(platformClass));
                        } catch (PrivilegedActionException exception) {
                        }
                    } else {
                        platform = (JDKPlatform)PrivilegedAccessHelper.newInstanceFromClass(platformClass);
                    }      
                } catch (Exception exception) {
                }
            }
            if (platform == null) {
                platform = new JDK15Platform();
            }
        }
        return platform;
    
public static java.util.MapgetQueryCacheMap()
INTERNAL: Get the Map to store the query cache in

        return getPlatform().getQueryCacheMap();
    
public static longgetTimeInMillis(java.util.Calendar calendar)
INTERNAL: Get the milliseconds from a Calendar.

param
calendar the instance of calendar to get the millis from
return
long the number of millis

        return getPlatform().getTimeInMillis(calendar);
    
public static voidsetExceptionCause(java.lang.Throwable exception, java.lang.Throwable cause)
INTERNAL: Set the cause of an exception. This is useful for JDK 1.4 exception chaining

param
java.lang.Throwable the exception to set the cause for
param
java.lang.Throwable the cause of this exception

        getPlatform().setExceptionCause(exception, cause);
    
public static voidsetTimeInMillis(java.util.Calendar calendar, long millis)
INTERNAL: Set the milliseconds for a Calendar.

        getPlatform().setTimeInMillis(calendar, millis);
    
public static booleanshouldPrintInternalException()
INTERNAL return a boolean which determines where TopLink should include the TopLink-stored Internal exception in it's stack trace. For JDK 1.4 VMs with exception chaining the Internal exception can be redundant and confusing.

return
boolean

        return getPlatform().shouldPrintInternalException();