org.mortbay.util
Class TypeUtil

java.lang.Object
  extended by org.mortbay.util.TypeUtil

public class TypeUtil
extends java.lang.Object

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

Since:
Jetty 4.1
Author:
Greg Wilkins (gregw)

Field Summary
static int CR
           
static int LF
           
 
Constructor Summary
TypeUtil()
           
 
Method Summary
static byte convertHexDigit(byte b)
           
static void dump(java.lang.Class c)
           
static void dump(java.lang.ClassLoader cl)
           
static byte[] fromHexString(java.lang.String s)
           
static java.lang.Class fromName(java.lang.String name)
          Class from a canonical name for a type.
static java.net.URL jarFor(java.lang.String className)
           
static java.lang.Integer newInteger(int i)
          Convert int to Integer using cache.
static java.lang.Long newLong(long i)
          Convert int to Integer using cache.
static byte[] parseBytes(java.lang.String s, int base)
           
static int parseInt(byte[] b, int offset, int length, int base)
          Parse an int from a byte array of ascii characters.
static int parseInt(java.lang.String s, int offset, int length, int base)
          Parse an int from a substring.
static byte[] readLine(java.io.InputStream in)
           
static java.lang.String toHexString(byte[] b)
           
static java.lang.String toHexString(byte[] b, int offset, int length)
           
static java.lang.String toName(java.lang.Class type)
          Canonical name for a type.
static java.lang.String toString(byte[] bytes, int base)
           
static java.lang.String toString(int i)
          Convert int to String using cache.
static java.lang.String toString(long i)
          Convert long to String using cache.
static java.lang.Object valueOf(java.lang.Class type, java.lang.String value)
          Convert String value to instance.
static java.lang.Object valueOf(java.lang.String type, java.lang.String value)
          Convert String value to instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CR

public static int CR

LF

public static int LF
Constructor Detail

TypeUtil

public TypeUtil()
Method Detail

fromName

public static java.lang.Class fromName(java.lang.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..

toName

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

Parameters:
type - A class , which may be a primitive TYPE field.
Returns:
Canonical name.

valueOf

public static java.lang.Object valueOf(java.lang.Class type,
                                       java.lang.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 java.lang.Object valueOf(java.lang.String type,
                                       java.lang.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.

newInteger

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


newLong

public static java.lang.Long newLong(long i)
Convert int to Integer using cache.


toString

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


toString

public static java.lang.String toString(long i)
Convert long to String using cache.


parseInt

public static int parseInt(java.lang.String s,
                           int offset,
                           int length,
                           int base)
                    throws java.lang.NumberFormatException
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:
java.lang.NumberFormatException

parseInt

public static int parseInt(byte[] b,
                           int offset,
                           int length,
                           int base)
                    throws java.lang.NumberFormatException
Parse an int from a byte array of ascii characters. Negative numbers are not handled.

Parameters:
b - byte array
offset - Offset within string
length - Length of integer or -1 for remainder of string
base - base of the integer
Throws:
java.lang.NumberFormatException

parseBytes

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

toString

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

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.

toHexString

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

toHexString

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

fromHexString

public static byte[] fromHexString(java.lang.String s)

dump

public static void dump(java.lang.Class c)

dump

public static void dump(java.lang.ClassLoader cl)

readLine

public static byte[] readLine(java.io.InputStream in)
                       throws java.io.IOException
Throws:
java.io.IOException

jarFor

public static java.net.URL jarFor(java.lang.String className)


Copyright © 1995-2009 Mort Bay Consulting. All Rights Reserved.