org.mortbay.util

Class TypeUtil

public class TypeUtil extends Object

TYPE Utilities. Provides various static utiltiy methods for manipulating types and their string representations.

Since: Jetty 4.1

Version: $Revision: 1.14 $

Author: Greg Wilkins (gregw)

Method Summary
static byteconvertHexDigit(byte b)
static voiddump(Class c)
static voiddump(ClassLoader cl)
static byte[]fromHexString(String s)
static ClassfromName(String name)
Class from a canonical name for a type.
static IntegernewInteger(int i)
Convert int to Integer using cache.
static byte[]parseBytes(String s, int base)
static intparseInt(String s, int offset, int length, int base)
Parse an int from a substring.
static chartoHexChar(int b)
static StringtoHexString(byte[] b)
static StringtoHexString(byte[] b, int offset, int length)
static StringtoName(Class type)
Canonical name for a type.
static StringtoString(int i)
Convert int to String using cache.
static StringtoString(byte[] bytes, int base)
static ObjectvalueOf(Class type, String value)
Convert String value to instance.
static ObjectvalueOf(String type, String value)
Convert String value to instance.

Method Detail

convertHexDigit

public static byte convertHexDigit(byte b)

Parameters: b An ASCII encoded character 0-9 a-f A-F

Returns: The byte value of the character 0-16.

dump

public static void dump(Class c)

dump

public static void dump(ClassLoader cl)

fromHexString

public static byte[] fromHexString(String s)

fromName

public static Class fromName(String name)
Class from a canonical name for a type.

Parameters: name A class or type name.

Returns: A class , which may be a primitive TYPE field..

newInteger

public static Integer newInteger(int i)
Convert int to Integer using cache.

parseBytes

public static byte[] parseBytes(String s, int base)

parseInt

public static int parseInt(String s, int offset, int length, int base)
Parse an int from a substring. Negative numbers are not handled.

Parameters: s String offset Offset within string length Length of integer or -1 for remainder of string base base of the integer

Throws: NumberFormatException

toHexChar

public static char toHexChar(int b)

toHexString

public static String toHexString(byte[] b)

toHexString

public static String toHexString(byte[] b, int offset, int length)

toName

public static String toName(Class type)
Canonical name for a type.

Parameters: type A class , which may be a primitive TYPE field.

Returns: Canonical name.

toString

public static String toString(int i)
Convert int to String using cache.

toString

public static String toString(byte[] bytes, int base)

valueOf

public static Object valueOf(Class type, String value)
Convert String value to instance.

Parameters: type The class of the instance, which may be a primitive TYPE field. value The value as a string.

Returns: The value as an Object.

valueOf

public static Object valueOf(String type, String value)
Convert String value to instance.

Parameters: type classname or type (eg int) value The value as a string.

Returns: The value as an Object.

Copyright © 2004 Mortbay Consulting Pty. Ltd. All Rights Reserved.