| 
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectnet.rim.device.api.util.NumberUtilities
public final class NumberUtilities
Utility methods for converting numeric values to their character/string digit equivalents.
| Method Summary | ||
|---|---|---|
static void | 
appendNumber(StringBuffer strBuf,
             byte num,
             int radix)
Appends digits for byte value to buffer.  | 
|
static void | 
appendNumber(StringBuffer strBuf,
             byte num,
             int radix,
             int minWidth)
Appends digits with padding for byte value to buffer.  | 
|
static void | 
appendNumber(StringBuffer strBuf,
             int num)
Appends digits for decimal integer value to buffer.  | 
|
static void | 
appendNumber(StringBuffer strBuf,
             int num,
             int radix)
Appends digits for integer value to buffer.  | 
|
static void | 
appendNumber(StringBuffer strBuf,
             int num,
             int radix,
             int minWidth)
Appends digits with padding for integer value to buffer.  | 
|
static void | 
appendNumber(StringBuffer strBuf,
             long num)
Appends digits for decimal long integer value to buffer.  | 
|
static void | 
appendNumber(StringBuffer strBuf,
             long num,
             int radix)
Appends digits for long integer value to buffer.  | 
|
static void | 
appendNumber(StringBuffer strBuf,
             long num,
             int radix,
             int minWidth)
Appends digits with padding for long integer value to buffer.  | 
|
static void | 
appendNumber(StringBuffer strBuf,
             short num,
             int radix)
Appends digits for short integer value to buffer.  | 
|
static void | 
appendNumber(StringBuffer strBuf,
             short num,
             int radix,
             int minWidth)
Appends digits with padding for short integer value to buffer.  | 
|
static int | 
hexDigitToInt(char dig)
Converts hex digit to integer value.  | 
|
static int | 
hexDigitToInt(char dig,
              int err_val)
Converts hex digit to integer value, using provided error value.  | 
|
static char | 
intToHexDigit(int value)
Converts integer value to hex digit.  | 
|
static char | 
intToUpperHexDigit(int value)
Converts integer value to upper case hex digit.  | 
|
static int | 
parseInt(String s,
         int fromIndex,
         int toIndex,
         int radix)
Parses the string argument as a signed integer in the radix specified by the second argument.  | 
|
static String | 
toString(byte num,
         int radix)
Retrieves digits for byte value.  | 
|
static String | 
toString(byte num,
         int radix,
         int minWidth)
Retrieves digits with padding for byte value.  | 
|
static String | 
toString(int num,
         int radix)
Retrieves digits for integer value.  | 
|
static String | 
toString(int num,
         int radix,
         int minWidth)
Retrieves digits with padding for integer value.  | 
|
static String | 
toString(long num,
         int radix)
Retrieves digits for long integer value.  | 
|
static String | 
toString(long num,
         int radix,
         int minWidth)
Retrieves digits with padding for long integer value.  | 
|
static String | 
toString(short num,
         int radix)
Retrieves digits for short integer value.  | 
|
static String | 
toString(short num,
         int radix,
         int minWidth)
Retrieves digits with padding for short integer value.  | 
|
| Methods inherited from class java.lang.Object | 
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
| Method Detail | 
|---|
public static final void appendNumber(StringBuffer strBuf,
                                      byte num,
                                      int radix)
strBuf - Buffer to contain result.num - Value to convert.radix - Radix for value.
public static final void appendNumber(StringBuffer strBuf,
                                      byte num,
                                      int radix,
                                      int minWidth)
strBuf - Buffer to contain result.num - Value to convert.radix - Radix for value.minWidth - Pads digits with leading zeros to meet this width.
public static final String toString(byte num,
                                    int radix)
num - Value to convert.radix - Radix for value.
public static final String toString(byte num,
                                    int radix,
                                    int minWidth)
num - Value to convert.radix - Radix for value.minWidth - Pads digits with leading zeros to meet this width.
public static final void appendNumber(StringBuffer strBuf,
                                      short num,
                                      int radix)
strBuf - Buffer to contain result.num - Value to convert.radix - Radix for value.
public static final void appendNumber(StringBuffer strBuf,
                                      short num,
                                      int radix,
                                      int minWidth)
strBuf - Buffer to contain result.num - Value to convert.radix - Radix for value.minWidth - Pads digits with leading zeros to meet this width.
public static final String toString(short num,
                                    int radix)
num - Value to convert.radix - Radix for value.
public static final String toString(short num,
                                    int radix,
                                    int minWidth)
num - Value to convert.radix - Radix for value.minWidth - Pads digits with leading zeros to meet this width.
public static final void appendNumber(StringBuffer strBuf,
                                      int num)
strBuf - Buffer to contain result.num - Value to convert.
public static final void appendNumber(StringBuffer strBuf,
                                      int num,
                                      int radix)
strBuf - Buffer to contain result.num - Value to convert.radix - Radix for value.
public static final void appendNumber(StringBuffer strBuf,
                                      int num,
                                      int radix,
                                      int minWidth)
strBuf - Buffer to contain result.num - Value to convert.radix - Radix for value.minWidth - Pads digits with leading zeros to meet this width.
public static final String toString(int num,
                                    int radix)
num - Value to convert.radix - Radix for value.
public static final String toString(int num,
                                    int radix,
                                    int minWidth)
num - Value to convert.radix - Radix for value.minWidth - Pads digits with leading zeros to meet this width.
public static final void appendNumber(StringBuffer strBuf,
                                      long num)
strBuf - Buffer to contain result.num - Value to convert.
public static final void appendNumber(StringBuffer strBuf,
                                      long num,
                                      int radix)
strBuf - Buffer to contain result.num - Value to convert.radix - Radix for value.
public static final void appendNumber(StringBuffer strBuf,
                                      long num,
                                      int radix,
                                      int minWidth)
strBuf - Buffer to contain result.num - Value to convert.radix - Radix for value.minWidth - Pads digits with leading zeros to meet this width.
public static final String toString(long num,
                                    int radix)
num - Value to convert.radix - Radix for value.
public static final String toString(long num,
                                    int radix,
                                    int minWidth)
num - Value to convert.radix - Radix for value.minWidth - Pads digits with leading zeros to meet this width.
public static char intToHexDigit(int value)
value - Lowest 4 bits of this value used to create the hex digit.
public static char intToUpperHexDigit(int value)
value - Lowest 4 bits of this value used to create the upper-case
 hex digit.
public static int hexDigitToInt(char dig)
                         throws NumberFormatException
dig - Single hex digit (can be lower or upper-case).
NumberFormatException - If provided digit isn't valid hex digit.
public static int hexDigitToInt(char dig,
                                int err_val)
dig - Single hex digit (can be lower or upper-case).err_val - Error value to return if provided digit isn't a valid hex
 digit.
public static int parseInt(String s,
                           int fromIndex,
                           int toIndex,
                           int radix)
                    throws NumberFormatException
Character.digit(char, int) returns a
 nonnegative value), except that the first character may be an
 ASCII minus sign '-' ('\u002d') to
 indicate a negative value. The resulting integer value is returned.
 An exception of type NumberFormatException is thrown if any of the following situations occurs:
Character.MIN_RADIX or
 larger than Character.MAX_RADIX.
 Examples:
 parseInt("0", 10) returns 0
 parseInt("473", 10) returns 473
 parseInt("-0", 10) returns 0
 parseInt("-FF", 16) returns -255
 parseInt("1100110", 2) returns 102
 parseInt("2147483647", 10) returns 2147483647
 parseInt("-2147483648", 10) returns -2147483648
 parseInt("2147483648", 10) throws a NumberFormatException
 parseInt("99", 8) throws a NumberFormatException
 parseInt("Kona", 10) throws a NumberFormatException
 parseInt("Kona", 27) returns 411787
 
s - the String containing the integer.fromIndex - the index in the string to start parsing at.toIndex - the index in the string to end parsing at.radix - the radix to be used.
NumberFormatException - if the string does not contain a
               parsable integer.
  | 
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
Copyright 1999-2011 Research In Motion Limited.  295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8.  All Rights Reserved.
Java is a trademark of Oracle America Inc. in the US and other countries.
Legal