Documentation of 'visad.browser.Convert' Java class
Convert
visad.browser

Class Convert



  • public class Convert
    extends java.lang.Object
    Utility methods for various conversions between primitive data types.
    • Field Summary

      Fields 
      Modifier and Type Field and Description
      static int PLACES
      Number of significant digits after the decimal point.
      static int ROUND_DOWN
      Mode where shortString rounds to the lower value.
      static int ROUND_NEAREST
      Mode where shortString rounds to the nearest value.
      static int ROUND_UP
      Mode where shortString rounds to the higher value.
    • Constructor Summary

      Constructors 
      Constructor and Description
      Convert() 
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method and Description
      static int[] bytesToInt(byte[] bytes)
      Converts an array of bytes to an array of ints.
      static int[] decodeRLE(int[] array)
      Decodes the given array of ints from a run-length encoding.
      static int[] encodeRLE(int[] array)
      Encodes the given array of ints using a run-length scheme.
      static boolean getBoolean(java.lang.String s)
      Extracts a boolean from a string.
      static double getDouble(java.lang.String s)
      Extracts a double from a string.
      static float getFloat(java.lang.String s)
      Extracts a float from a string.
      static int getInt(java.lang.String s)
      Extracts an integer from a string.
      static byte[] intToBytes(int[] ints)
      Converts an array of ints to an array of bytes.
      static java.lang.String shortString(double val)
      Gets a reasonably short string representation of a double for use in a graphical user interface.
      static java.lang.String shortString(double val, int mode)
      Gets a reasonably short string representation of a double for use in a graphical user interface.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • PLACES

        public static final int PLACES
        Number of significant digits after the decimal point.
        See Also:
        Constant Field Values
      • ROUND_NEAREST

        public static final int ROUND_NEAREST
        Mode where shortString rounds to the nearest value.
        See Also:
        Constant Field Values
      • ROUND_DOWN

        public static final int ROUND_DOWN
        Mode where shortString rounds to the lower value.
        See Also:
        Constant Field Values
      • ROUND_UP

        public static final int ROUND_UP
        Mode where shortString rounds to the higher value.
        See Also:
        Constant Field Values
    • Constructor Detail

      • Convert

        public Convert()
    • Method Detail

      • intToBytes

        public static byte[] intToBytes(int[] ints)
        Converts an array of ints to an array of bytes. Each integer is cut into four byte-size pieces, making the resulting byte array four times the length of the input int array.
        Parameters:
        ints - The array of ints to be converted to a byte array
        Returns:
        An array of bytes corresponding to the original int array.
      • bytesToInt

        public static int[] bytesToInt(byte[] bytes)
        Converts an array of bytes to an array of ints. Each group of four bytes form a single int, making the resulting int array one fourth the length of the input byte array. Note that trailing elements of the bytes array will be ignored.
        Parameters:
        bytes - The array of bytes to be converted to an int array
        Returns:
        An array of ints corresponding to the original byte array.
      • encodeRLE

        public static int[] encodeRLE(int[] array)
        Encodes the given array of ints using a run-length scheme.
        Parameters:
        array - The array of ints to RLE-encode
        Returns:
        An RLE-encoded array of ints.
      • decodeRLE

        public static int[] decodeRLE(int[] array)
        Decodes the given array of ints from a run-length encoding.
        Parameters:
        array - The RLE-encoded array of ints to decode
        Returns:
        A decoded array of ints.
      • getDouble

        public static double getDouble(java.lang.String s)
        Extracts a double from a string.
      • getFloat

        public static float getFloat(java.lang.String s)
        Extracts a float from a string.
      • getBoolean

        public static boolean getBoolean(java.lang.String s)
        Extracts a boolean from a string.
      • getInt

        public static int getInt(java.lang.String s)
        Extracts an integer from a string.
      • shortString

        public static java.lang.String shortString(double val)
        Gets a reasonably short string representation of a double for use in a graphical user interface. The number will be rounded to the nearest integer.
      • shortString

        public static java.lang.String shortString(double val,
                                                   int mode)
        Gets a reasonably short string representation of a double for use in a graphical user interface. Mode indicates the method used to deal insignificant digits: ROUND_NEAREST, ROUND_UP or ROUND_DOWN.

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.