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

## org.jasig.portal.lang
Class TypeConverter

    java.lang.Object
      org.jasig.portal.lang.TypeConverter

    public final class TypeConverter

extends java.lang.Object

The `TypeConverter` class provides efficient and consistent static type converter utilities for the basic types.

Version:
  $Revision: 1.3 $
Author:
  Jan Nielsen

Field Summary
`private static char[]` | `DIGITS` Hexidecimal digits.
`static java.lang.String` | `FALSE` Canonical string representation of `false`.
`static java.lang.String` | `TRUE` Canonical string representation of `true`.

Constructor Summary
`private` | `TypeConverter()` Private constructor.

Method Summary
`static boolean` | `isInt(java.lang.String value)` Returns `true` if the value can be parsed to an `int`.
`static boolean` | `toBoolean(java.lang.String value)` Returns the `boolean` value represented by the specified string, ignoring case.
`static byte` | `toByte(java.lang.String value)` Returns a signed decimal `byte` value.
`static char` | `toChar(java.lang.String value)` Returns the first character of the string.
`static double` | `toDouble(java.lang.String value)` Returns a new double initialized to the value represented by the specified String, as performed by the valueOf method of class Double.
`static float` | `toFloat(java.lang.String value)` Returns a new float initialized to the value represented by the specified String, as performed by the valueOf method of class Double.
`static java.lang.String` | `toHexString(byte[] values)` Returns a hexidecimal string representation of the specified byte array.
`static java.lang.String` | `toHexString(long value)` Converts a long value to a hexidecimal string.
`static int` | `toInt(java.lang.String value)` Parses the string argument as a signed decimal integer.
`static long` | `toLong(java.lang.String value)` Parses the string argument as a signed long in the radix specified by the second argument.
`static short` | `toShort(java.lang.String value)` Returns the `short` representation of the specified string.
`static java.lang.String` | `toString(boolean value)` Returns a canonical `String` object representing the specified `boolean`.
`static java.lang.String` | `toString(byte value)` Returns a string representation of the argument of radix 10.
`static java.lang.String` | `toString(char value)` Returns a string representation of the argument.
`static java.lang.String` | `toString(double value)` Returns a string representation of the specified `double`.
`static java.lang.String` | `toString(float value)` Returns a string representation of the specified `float`.
`static java.lang.String` | `toString(int value)` Returns a string representation of the specified `int`.
`static java.lang.String` | `toString(long value)` Returns a string representation of the specified `long`.
`static java.lang.String` | `toString(short value)` Returns a string representation of the specified `short` value of radix 10.

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

Field Detail

### TRUE

    public static final java.lang.String TRUE

  Canonical string representation of `true`.

  See Also:
    Constant Field Values

### FALSE

    public static final java.lang.String FALSE

  Canonical string representation of `false`.

  See Also:
    Constant Field Values

### DIGITS

    private static final char[] DIGITS

  Hexidecimal digits.

Constructor Detail

### TypeConverter

    private TypeConverter()

  Private constructor.

Method Detail

### toString

    public static final java.lang.String toString(boolean value)

  Returns a canonical `String` object representing the specified `boolean`. If the value is `true`, the string `"true"` will be returned; if the value is `false`, the string `"false"`.

  Parameters:
    `value` - `boolean` value to be converted
  Returns:
    canonical string representation of the `boolean` value

### toBoolean

    public static final boolean toBoolean(java.lang.String value)

  Returns the `boolean` value represented by the specified string, ignoring case. If the value is neither `"true"`, nor `"false"` (ignoring case), an `IllegalArgumentException` is thrown.

  Note: This implementation is different than the `java.lang.Boolean` implementation. The `java.lang.Boolean` treats `null` and any non-`"true"` value (ignoring case) as `false`, i.e., there is no validation of `false` values.

  Parameters:
    `value` - string representation of a boolean value
  Returns:
    `boolean` value represented by the argument
  Throws:
    `java.lang.IllegalArgumentException` - if value is (ignoring case) neither `"true"`, nor `"false"`

### toString

    public static final java.lang.String toString(byte value)

  Returns a string representation of the argument of radix 10.

  Parameters:
    `value` - `byte` value to be converted
  Returns:
    string respresentation of the argument

### toByte

    public static final byte toByte(java.lang.String value)

  Returns a signed decimal `byte` value. The characters in the string must all be decimal digits, except that the first character may be an ASCII minus sign '-' ('-') to indicate a negative value.

  Parameters:
    `value` - string representation of a `byte` value
  Returns:
    `byte` value represented by the argument
  Throws:
    `java.lang.IllegalArgumentException` - if argument is not a parseable `byte`

### toString

    public static final java.lang.String toString(char value)

  Returns a string representation of the argument. The result string of length 1 consisting solely of the specified char.

  Parameters:
    `value` - `char` value to be converted
  Returns:
    string representation of the argument

### toChar

    public static final char toChar(java.lang.String value)

  Returns the first character of the string.

  Parameters:
    `value` - string representation of the `char`
  Returns:
    `char` representation of the argument
  Throws:
    `java.lang.IllegalArgumentException` - if `value` is `null` or of zero length

### toString

    public static final java.lang.String toString(short value)

  Returns a string representation of the specified `short` value of radix 10.

  Parameters:
    `value` - `short` value to be converted
  Returns:
    string representation of the argument

### toShort

    public static final short toShort(java.lang.String value)

  Returns the `short` representation of the specified string. The characters in the string must all be decimal digits, except that the first character may be an ASCII minus sign '-' ('-') to indicate a negative value.

  Parameters:
    `value` - string representation of the `short`
  Returns:
    `short` representation of the argument
  Throws:
    `java.lang.IllegalArgumentException` - if argument is not a parseable `short`

### toString

    public static final java.lang.String toString(int value)

  Returns a string representation of the specified `int`.

  Parameters:
    `value` - `int` >value to be converted
  Returns:
    string representation of the argument

### toInt

    public static final int toInt(java.lang.String value)

  Parses the string argument as a signed decimal integer. The characters in the string must all be decimal digits, except that the first character may be an ASCII minus sign '-' ('-') to indicate a negative value.

  Parameters:
    `value` - string representation of the `int`
  Returns:
    `int` representation of the argument
  Throws:
    `java.lang.IllegalArgumentException` - if string does not contain a parseable `int`

### isInt

    public static final boolean isInt(java.lang.String value)

  Returns `true` if the value can be parsed to an `int`.

  Parameters:
    `value` - string representation of the `int`
  Returns:
    `true` if argument is an `int`; otherwise `false`

### toString

    public static final java.lang.String toString(long value)

  Returns a string representation of the specified `long`.

  Parameters:
    `value` - `long` value to be converted
  Returns:
    string representation of the argument

### toLong

    public static final long toLong(java.lang.String value)

  Parses the string argument as a signed long in the radix specified by the second argument. The characters in the string must all be digits of the specified radix (as determined by whether Character.digit returns a nonnegative value), except that the first character may be an ASCII minus sign '-' ('-' to indicate a negative value. The resulting long value is returned. Note that neither L nor l is permitted to appear at the end of the string as a type indicator, as would be permitted in Java programming language source code.

  Parameters:
    `value` - string representation of the `long`
  Returns:
    `long` representation of the argument
  Throws:
    `java.lang.IllegalArgumentException` - if string does not contain a parseable `long`

### toString

    public static final java.lang.String toString(float value)

  Returns a string representation of the specified `float`.

  Parameters:
    `value` - `float` value to be converted
  Returns:
    string representation of the argument

### toFloat

    public static final float toFloat(java.lang.String value)

  Returns a new float initialized to the value represented by the specified String, as performed by the valueOf method of class Double.

  Parameters:
    `value` - string representation of the `long`
  Returns:
    `long` representation of the argument
  Throws:
    `java.lang.IllegalArgumentException` - if string does not contain a parseable `long`

### toString

    public static final java.lang.String toString(double value)

  Returns a string representation of the specified `double`.

  Parameters:
    `value` - `double` value to be converted
  Returns:
    string representation of the argument

### toDouble

    public static final double toDouble(java.lang.String value)

  Returns a new double initialized to the value represented by the specified String, as performed by the valueOf method of class Double.

  Parameters:
    `value` - string representation of the `long`
  Returns:
    `long` representation of the argument
  Throws:
    `java.lang.IllegalArgumentException` - if string does not contain a parseable `long`

### toHexString

    public static final java.lang.String toHexString(byte[] values)

  Returns a hexidecimal string representation of the specified byte array.

  Parameters:
    `values` - `byte` array to be converted
  Returns:
    hexidecimal string representation of argument

### toHexString

    public static final java.lang.String toHexString(long value)

  Converts a long value to a hexidecimal string.

  Parameters:
    `value` - long to be converted
  Returns:
    string representation of the long value

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