Class Compatibility


  • public final class Compatibility
    extends java.lang.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
      Compatibility()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static int ceil​(int p, int q)
      Answers the most negative (i.e.
      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 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 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 Detail

      • Compatibility

        public Compatibility()
    • Method Detail

      • 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:
        java.lang.IllegalArgumentException -
        • ERROR_INVALID_RANGE - if the argument is not between 0 and 30 (inclusive)
      • exec

        public static void exec​(java.lang.String[] prog,
                                java.lang.String[] envp,
                                java.lang.String workingDir)
                         throws java.io.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:
        java.io.IOException - if the program cannot be executed
        java.lang.SecurityException - if the current SecurityManager disallows program execution
        Since:
        3.6
      • getMessage

        public static java.lang.String getMessage​(java.lang.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:
        SWT.getMessage(String)
      • getMessage

        public static java.lang.String getMessage​(java.lang.String key,
                                                  java.lang.Object[] args)