public final class Compatibility
extends java.lang.Object
It is part of our effort to provide support for both J2SE and J2ME platforms.
IMPORTANT: some of the methods have been modified from their J2SE parents. Refer to the description of each method for specific changes.
Modifier and Type | Field and Description |
---|---|
private static java.util.ResourceBundle |
msgs |
static double |
PI
Returns the PI constant as a double.
|
(package private) static double |
toRadians |
Constructor and Description |
---|
Compatibility() |
Modifier and Type | Method and Description |
---|---|
static int |
ceil(int p,
int q)
Answers the most negative (i.e. closest to negative infinity)
integer value which is greater than the number obtained by dividing
the first argument p by the second argument q.
|
static int |
cos(int angle,
int length)
Answers the length of the side adjacent to the given angle
of a right triangle.
|
static boolean |
equalsIgnoreCase(java.lang.String s1,
java.lang.String s2)
Compares two instances of class String ignoring the case of the
characters and answers if they are equal.
|
static void |
exec(java.lang.String prog)
Execute a program in a separate platform process if the
underlying platform support this.
|
static void |
exec(java.lang.String[] progArray)
Execute progArray[0] in a separate platform process if the
underlying platform support this.
|
static void |
exec(java.lang.String[] prog,
java.lang.String[] envp,
java.lang.String workingDir)
Execute prog[0] in a separate platform process if the
underlying platform supports this.
|
static boolean |
fileExists(java.lang.String parent,
java.lang.String child)
Answers whether the indicated file exists or not.
|
static int |
floor(int p,
int q)
Answers the most positive (i.e. closest to positive infinity)
integer value which is less than the number obtained by dividing
the first argument p by the second argument q.
|
static java.lang.String |
getMessage(java.lang.String key)
Returns the NLS'ed message for the given argument.
|
static java.lang.String |
getMessage(java.lang.String key,
java.lang.Object[] args) |
static void |
interrupt()
Interrupt the current thread.
|
static boolean |
isLetter(char c)
Answers whether the character is a letter.
|
static boolean |
isLetterOrDigit(char c)
Answers whether the character is a letter or a digit.
|
static boolean |
isSpaceChar(char c)
Answers whether the character is a Unicode space character.
|
static boolean |
isWhitespace(char c)
Answers whether the character is a whitespace character.
|
static java.io.OutputStream |
newDeflaterOutputStream(java.io.OutputStream stream,
int level)
Create a DeflaterOutputStream if such things are supported.
|
static java.io.InputStream |
newFileInputStream(java.lang.String filename)
Open a file if such things are supported.
|
static java.io.OutputStream |
newFileOutputStream(java.lang.String filename)
Open a file if such things are supported.
|
static java.io.InputStream |
newInflaterInputStream(java.io.InputStream stream)
Create an InflaterInputStream if such things are supported.
|
static int |
pow2(int n)
Returns 2 raised to the power of the argument.
|
static int |
round(int p,
int q)
Answers the result of rounding to the closest integer the number obtained
by dividing the first argument p by the second argument q.
|
static int |
sin(int angle,
int length)
Answers the length of the side opposite to the given angle
of a right triangle.
|
public static double PI
static double toRadians
private static java.util.ResourceBundle msgs
public static int cos(int angle, int length)
IMPORTANT: the j2me version has an additional restriction on the argument. length must be between -32767 and 32767 (inclusive).
angle
- the angle in degreeslength
- the length of the triangle's hypotenusepublic static int sin(int angle, int length)
IMPORTANT: the j2me version has an additional restriction on the argument. length must be between -32767 and 32767 (inclusive).
angle
- the angle in degreeslength
- the length of the triangle's hypotenusepublic static int ceil(int p, int q)
p
- numeratorq
- denominator (must be different from zero)public static boolean fileExists(java.lang.String parent, java.lang.String child)
parent
- the file's parent directorychild
- the file's namepublic static int floor(int p, int q)
p
- numeratorq
- denominator (must be different from zero)public static int round(int p, int q)
IMPORTANT: the j2me version has an additional restriction on the arguments. p must be within the range 0 - 32767 (inclusive). q must be within the range 1 - 32767 (inclusive).
p
- numeratorq
- denominator (must be different from zero)public static int pow2(int n)
n
- an int value between 0 and 30 (inclusive)java.lang.IllegalArgumentException
- public static java.io.OutputStream newDeflaterOutputStream(java.io.OutputStream stream, int level) throws java.io.IOException
stream
- the output streamnull
java.io.IOException
public static java.io.InputStream newFileInputStream(java.lang.String filename) throws java.io.IOException
filename
- the name of the file to openjava.io.IOException
public static java.io.OutputStream newFileOutputStream(java.lang.String filename) throws java.io.IOException
filename
- the name of the file to openjava.io.IOException
public static java.io.InputStream newInflaterInputStream(java.io.InputStream stream) throws java.io.IOException
stream
- the input streamnull
java.io.IOException
public static boolean isLetter(char c)
c
- the characterpublic static boolean isLetterOrDigit(char c)
c
- the characterpublic static boolean isSpaceChar(char c)
c
- the characterpublic static boolean isWhitespace(char c)
c
- the character to testpublic static void exec(java.lang.String prog) throws java.io.IOException
The new process inherits the environment of the caller.
prog
- the name of the program to executejava.io.IOException
- if the program cannot be executedjava.lang.SecurityException
- if the current SecurityManager disallows program executionpublic static void exec(java.lang.String[] progArray) throws java.io.IOException
The new process inherits the environment of the caller.
progArray
- array containing the program to execute and its argumentsjava.io.IOException
- if the program cannot be executedjava.lang.SecurityException
- if the current SecurityManager disallows program executionpublic static void exec(java.lang.String[] prog, java.lang.String[] envp, java.lang.String workingDir) throws java.io.IOException
The new process inherits the environment of the caller.
prog
- array containing the program to execute and its argumentsenvp
- array of strings, each element of which has environment
variable settings in the format name=valueworkingDir
- the working directory of the new process, or null if the new
process should inherit the working directory of the callerjava.io.IOException
- if the program cannot be executedjava.lang.SecurityException
- if the current SecurityManager disallows program executionpublic static java.lang.String getMessage(java.lang.String key)
key
- the key to look upSWT.getMessage(String)
public static java.lang.String getMessage(java.lang.String key, java.lang.Object[] args)
public static void interrupt()
Note that this is not available on CLDC.
public static boolean equalsIgnoreCase(java.lang.String s1, java.lang.String s2)
s1
- strings2
- string