Class Compatibility

java.lang.Object
org.eclipse.swt.internal.Compatibility

public final class Compatibility extends Object
This class is a placeholder for utility methods commonly used on J2SE platforms but not supported on some J2ME profiles.

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.

  • Exceptions thrown may differ since J2ME's set of exceptions is a subset of J2SE's one.
  • The range of the mathematic functions is subject to change.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static int
    ceil(int p, int q)
    Answers the most negative (i.e. closest to negative infinity) integer value which is greater than or equal to the number obtained by dividing the first argument p by the second argument q.
    static void
    exec(String[] prog, String[] envp, String workingDir)
    Execute prog[0] in a separate platform process if the underlying platform supports this.
    static String
    Returns the NLS'ed message for the given argument.
    static String
    getMessage(String key, Object[] args)
     
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Compatibility

      public Compatibility()
  • Method Details

    • ceil

      public static int ceil(int p, int q)
      Answers the most negative (i.e. closest to negative infinity) integer value which is greater than or equal to the number obtained by dividing the first argument p by the second argument q.
      Parameters:
      p - numerator
      q - denominator (must be different from zero)
      Returns:
      the ceiling of the rational number p / q.
    • round

      public 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.

      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).

      Parameters:
      p - numerator
      q - denominator (must be different from zero)
      Returns:
      the closest integer to the rational number p / q
    • pow2

      public static int pow2(int n)
      Returns 2 raised to the power of the argument.
      Parameters:
      n - an int value between 0 and 30 (inclusive)
      Returns:
      2 raised to the power of the argument
      Throws:
      IllegalArgumentException -
      • ERROR_INVALID_RANGE - if the argument is not between 0 and 30 (inclusive)
    • exec

      public static void exec(String[] prog, String[] envp, String workingDir) throws IOException
      Execute prog[0] in a separate platform process if the underlying platform supports this.

      The new process inherits the environment of the caller.

      Parameters:
      prog - array containing the program to execute and its arguments
      envp - array of strings, each element of which has environment variable settings in the format name=value
      workingDir - the working directory of the new process, or null if the new process should inherit the working directory of the caller
      Throws:
      IOException - if the program cannot be executed
      SecurityException - if the current SecurityManager disallows program execution
      Since:
      3.6
    • getMessage

      public static String getMessage(String key)
      Returns the NLS'ed message for the given argument. This is only being called from SWT.
      Parameters:
      key - the key to look up
      Returns:
      the message for the given key
      See Also:
    • getMessage

      public static String getMessage(String key, Object[] args)