Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## waba.sys
Class Convert

    java.lang.Object
      |
      +--waba.sys.Convert

public final class Convert
extends Object

Convert is used to convert between objects and basic types.

Field Summary
`static CharacterConverter` | `charConverter` The bytes are converted to char and vice-versa using the CharacterConverter associated in this charConverter member.
`static long` | `MAX_LONG_VALUE`
`static long` | `MIN_LONG_VALUE`

Method Summary
`static int` | `chars2int(String fourChars)` Convert a creator id or a type to an int.
`static String[]` | `cloneStringArray(String[] strs)` Creates a copy of the given array
`static int` | `digitOf(char ch, int radix)` returns the value of the digit in the specified radix. this method is simplified to only handle the standard ascii table.
`static long` | `doubleToLongBits(double value)` Returns a representation of the specified floating-point value according to the IEEE 754 floating-point "double format" bit layout.
`static char` | `forDigit(int digit, int radix)` returns the digit in the corresponding radix.
`static String` | `insertLineBreak(int maxWidth, char separator, FontMetrics fm, String text)` This method is useful to insert line breaks into the text used in the MessageBox constructor.
`static double` | `longBitsToDouble(long bits)` Returns the double-float corresponding to a given bit represention.
`static void` | `qsort(Object[] items, int first, int last)` Applies the Quick Sort algorithm to the elements of the given array.
`static long` | `rol(long i, int n, int bits)` Do a rol of n bits in the given i(nt). n must be < `bits`.
`static long` | `ror(long i, int n, int bits)` Do a ror of n bits in the given i(nt). n must be < `bits`.
`static double` | `toDouble(String s)` Converts the String to a double.
`static float` | `toFloat(String s)` Converts the given String to a float.
`static float` | `toFloatBitwise(int i)` Converts the given IEEE 754 bit representation of a float to a float.
`static int` | `toInt(String s)` Converts the given String to an int.
`static int` | `toIntBitwise(float f)` Converts the given float to its bit representation in IEEE 754 format.
`static String[]` | `tokenizeString(String input, char delim)` Tokenize the given input string. if there's no delim chars in input, returns the input string
`static long` | `toLong(String s)` Converts the String to a long.
`static long` | `toLong(String s, int radix)` Converts the String to a long in the given radix.
`static char` | `toLowerCase(char c)` converts the char to lower case letter
`static String` | `toLowerCase(String s)` converts the string to lower case letters
`static String` | `toString(boolean b)` Converts the given boolean to a String.
`static String` | `toString(char c)` Converts the given char to a String.
`static String` | `toString(double d)` Converts the given double to a String, formatting it using scientific notation.
`static String` | `toString(double d, int precision)` Converts the given double to a String, formatting it with decimal places.
`static String` | `toString(float f)` Converts the given float to a String.
`static String` | `toString(float f, int d)` Converts the given float to a String, formatting it with d decimal places. added by guich
`static String` | `toString(int i)` Converts the given int to a String.
`static String` | `toString(long l)` Converts the long to a String at base 10.
`static String` | `toString(long i, int radix)` Converts the long to a String in the given radix.
`static String` | `toString(String doubleValue, int n)` formats a String as a double, rounding with n decimal places. if the number is invalid, "0" is returned.
`static String[]` | `toStringArray(Object[] objs)` Converts the given object array to a String array by calling toString in each object
`static char` | `toUpperCase(char c)` converts the char to upper case letter
`static String` | `toUpperCase(String s)` converts the string to upper case letters
`static String` | `unsigned2hex(int b, int places)` Returns a String with the convertion of the unsigned integer to hexadecimal, using the given number of places (up to 8).
`static String` | `zeroPad(String s, int size)` pads the string with zeroes at left

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, toString, wait, wait`

Field Detail

### charConverter

    public static CharacterConverter charConverter

  The bytes are converted to char and vice-versa using the CharacterConverter associated in this charConverter member.

### MIN_LONG_VALUE

    public static final long MIN_LONG_VALUE

### MAX_LONG_VALUE

    public static final long MAX_LONG_VALUE

Method Detail

### cloneStringArray

    public static String[] cloneStringArray(String[] strs)

  Creates a copy of the given array

### toStringArray

    public static String[] toStringArray(Object[] objs)

  Converts the given object array to a String array by calling toString in each object

### toInt

    public static int toInt(String s)

  Converts the given String to an int. If the string passed is not a valid integer, 0 is returned.

### toString

    public static String toString(boolean b)

  Converts the given boolean to a String.

### toString

    public static String toString(char c)

  Converts the given char to a String.

### toIntBitwise

    public static int toIntBitwise(float f)

  Converts the given float to its bit representation in IEEE 754 format.

### toFloatBitwise

    public static float toFloatBitwise(int i)

  Converts the given IEEE 754 bit representation of a float to a float.

### toString

    public static String toString(float f)

  Converts the given float to a String.

### toString

    public static String toString(int i)

  Converts the given int to a String.

### toString

    public static String toString(double d,
                                  int precision)

  Converts the given double to a String, formatting it with decimal places.
  Since:
    2.0

### toDouble

    public static double toDouble(String s)

  Converts the String to a double.
  Since:
    2.0

### toString

    public static String toString(float f,
                                  int d)

  Converts the given float to a String, formatting it with d decimal places. added by guich

### toFloat

    public static float toFloat(String s)

  Converts the given String to a float. If the string passed is not a valid float, 0 is returned.

### toString

    public static String toString(String doubleValue,
                                  int n)

  formats a String as a double, rounding with n decimal places. if the number is invalid, "0" is returned.

### doubleToLongBits

    public static long doubleToLongBits(double value)

  Returns a representation of the specified floating-point value according to the IEEE 754 floating-point "double format" bit layout.

  Bit 63 represents the sign of the floating-point number. Bits 62-52 represent the exponent. Bits 51-0 represent the significand (sometimes called the mantissa) of the floating-point number.

  If the argument is positive infinity, the result is `0x7ff0000000000000L`.

  If the argument is negative infinity, the result is `0xfff0000000000000L`.

  If the argument is NaN, the result is `0x7ff8000000000000L`.

  Parameters:
    `value` - a double precision floating-point number.
  Returns:
    the bits that represent the floating-point number.
  Since:
    SuperWaba2.0

### longBitsToDouble

    public static double longBitsToDouble(long bits)

  Returns the double-float corresponding to a given bit represention. The argument is considered to be a representation of a floating-point value according to the IEEE 754 floating-point "double precision" bit layout. That floating-point value is returned as the result.

  If the argument is `0x7f80000000000000L`, the result is positive infinity.

  If the argument is `0xff80000000000000L`, the result is negative infinity.

  If the argument is any value in the range `0x7ff0000000000001L` through `0x7fffffffffffffffL` or in the range `0xfff0000000000001L` through `0xffffffffffffffffL`, the result is NaN. All IEEE 754 NaN values are, in effect, lumped together by the Java language into a single value.

  Parameters:
    `bits` - any `long` integer.
  Returns:
    the `double` floating-point value with the same bit pattern.
  Since:
    SuperWaba2.0

### digitOf

    public static int digitOf(char ch,
                              int radix)

  returns the value of the digit in the specified radix. this method is simplified to only handle the standard ascii table.
  Since:
    2.0

### forDigit

    public static char forDigit(int digit,
                                int radix)

  returns the digit in the corresponding radix.
  Since:
    2.0

### toString

    public static String toString(long l)

  Converts the long to a String at base 10.
  Since:
    2.0

### toString

    public static String toString(long i,
                                  int radix)

  Converts the long to a String in the given radix. Radix can be from 2 to 16.
  Since:
    2.0

### toLong

    public static long toLong(String s)

  Converts the String to a long.
  Since:
    2.0

### toLong

    public static long toLong(String s,
                              int radix)

  Converts the String to a long in the given radix. Radix can be from 2 to 16. At any error, 0 is returned. The hex digits are in lowercase.
  Since:
    2.0

### toString

    public static String toString(double d)

  Converts the given double to a String, formatting it using scientific notation.
  Since:
    2.0

### toUpperCase

    public static String toUpperCase(String s)

  converts the string to upper case letters

### toLowerCase

    public static String toLowerCase(String s)

  converts the string to lower case letters

### toLowerCase

    public static char toLowerCase(char c)

  converts the char to lower case letter

### toUpperCase

    public static char toUpperCase(char c)

  converts the char to upper case letter

### zeroPad

    public static String zeroPad(String s,
                                 int size)

  pads the string with zeroes at left

### tokenizeString

    public static String[] tokenizeString(String input,
                                          char delim)

  Tokenize the given input string. if there's no delim chars in input, returns the input string

### insertLineBreak

    public static String insertLineBreak(int maxWidth,
                                         char separator,
                                         FontMetrics fm,
                                         String text)

  This method is useful to insert line breaks into the text used in the MessageBox constructor. It receives a String and returns the parsed String. Here is an example of use: `Convert.insertLineBreak(154,'|',getFontMetrics(getFont()),"This is a very long text and i dont want to waste my time parsing it to be fit in the MessageBox!");`
  Parameters:
    `maxWidth` - the maximum width that is permitted for each line. For a text used in the MessageBox class, use `Settings.screenWidth-6` or a lower number.
    `separator` - the separator that will divide each line. The MessageBox class uses '|' as the separator
    `fm` - the FontMetrics of the font you will use to display the text
    `text` - the text to be parsed
  Returns:
    the parsed text

### qsort

    public static void qsort(Object[] items,
                             int first,
                             int last)

  Applies the Quick Sort algorithm to the elements of the given array. If they are Strings, the sort will be much faster because a direct cast to String is done; otherwise, if they are not strings, the toString() method is used to return the string that will be used for comparision. You may call this way: Convert.qsort(items,0,items.length-1). You can sort subportions of the array as well.

### unsigned2hex

    public static String unsigned2hex(int b,
                                      int places)

  Returns a String with the convertion of the unsigned integer to hexadecimal, using the given number of places (up to 8). This routine is 10 times faster than toString(long, int). The hex digits are in upper case.
  Since:
    SuperWaba 3.0

### rol

    public static long rol(long i,
                           int n,
                           int bits)

  Do a rol of n bits in the given i(nt). n must be < `bits`. This differs from the shift left operator (<<) in that the bits are not lost, they are reinserted in order at the right. Bits may be 4,8,16 or 32.

### ror

    public static long ror(long i,
                           int n,
                           int bits)

  Do a ror of n bits in the given i(nt). n must be < `bits`. This differs from the shift right operator (>>) in that the bits are not lost, they are reinserted in order at the left. Bits may be 4,8,16 or 32.

### chars2int

    public static int chars2int(String fourChars)

  Convert a creator id or a type to an int.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD