org.apache.tomcat.util.compat

Class JdkCompat

Known Direct Subclasses:
Jdk14Compat

public class JdkCompat
extends java.lang.Object

General-purpose utility to provide backward-compatibility and JDK independence. This allow use of JDK1.3 ( or higher ) facilities if available, while maintaining the code compatible with older VMs. The goal is to make backward-compatiblity reasonably easy. The base class supports JDK1.3 behavior.

Author:
Tim Funk

Field Summary

static String
JAVA_1_0
static String
JAVA_1_1
static String
JAVA_1_2
static String
JAVA_1_3
static String
JAVA_1_4
static String
JAVA_1_5

Constructor Summary

JdkCompat()
Default no-arg constructor

Method Summary

void
chainException(Throwable wrapper, Throwable wrapped)
Chains the wrapped throwable to the wrapper throwable.
static String
getJavaVersion()
Return java version as a string
static JdkCompat
getJdkCompat()
Get a compatibiliy helper class.
long
getMaxMemory()
Return the maximum amount of memory the JVM will attempt to use.
String
getPartialServletStackTrace(Throwable t)
Print out a partial servlet stack trace (truncating at the last occurrence of javax.servlet.).
URL
getURI(File file)
Return the URI for the given file.
static boolean
isJava14()
static boolean
isJava15()
static boolean
isJava2()
String[]
split(String path, String pat)
Splits a string into it's components.

Field Details

JAVA_1_0

public static final String JAVA_1_0


JAVA_1_1

public static final String JAVA_1_1


JAVA_1_2

public static final String JAVA_1_2


JAVA_1_3

public static final String JAVA_1_3


JAVA_1_4

public static final String JAVA_1_4


JAVA_1_5

public static final String JAVA_1_5

Constructor Details

JdkCompat

protected JdkCompat()
Default no-arg constructor

Method Details

chainException

public void chainException(Throwable wrapper,
                           Throwable wrapped)
Chains the wrapped throwable to the wrapper throwable.

Parameters:
wrapper - The wrapper throwable
wrapped - The throwable to be wrapped


getJavaVersion

public static String getJavaVersion()
Return java version as a string


getJdkCompat

public static JdkCompat getJdkCompat()
Get a compatibiliy helper class.


getMaxMemory

public long getMaxMemory()
Return the maximum amount of memory the JVM will attempt to use.


getPartialServletStackTrace

public String getPartialServletStackTrace(Throwable t)
Print out a partial servlet stack trace (truncating at the last occurrence of javax.servlet.).


getURI

public URL getURI(File file)
            throws MalformedURLException
Return the URI for the given file. Originally created for o.a.c.loader.WebappClassLoader

Parameters:

Returns:
A URI as a URL


isJava14

public static boolean isJava14()


isJava15

public static boolean isJava15()


isJava2

public static boolean isJava2()


split

public String[] split(String path,
                      String pat)
Splits a string into it's components.

Parameters:
path - String to split
pat - Pattern to split at

Returns:
the components of the path


Copyright B) 2000-2003 Apache Software Foundation. All Rights Reserved.