|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.norther.tammi.acorn.type.Types
public abstract class Types
Converts between primitive types and lang classes.
Field Summary | |
---|---|
static String |
BOOLEAN_CLASS_NAME
Boolean class name. |
static String |
BOOLEAN_TYPE
boolean type. |
static String |
BYTE_CLASS_NAME
Byte class name. |
static String |
BYTE_TYPE
byte type. |
static String |
CHAR_TYPE
char type. |
static String |
CHARACTER_CLASS_NAME
Character class name. |
static String |
DOUBLE_CLASS_NAME
Double class name. |
static String |
DOUBLE_TYPE
double type. |
static String |
ENUM_CLASS_NAME
Enum class name. |
static String |
FLOAT_CLASS_NAME
Float class name. |
static String |
FLOAT_TYPE
float type. |
static int |
INT_SIGN
The int sign bit. |
static String |
INT_TYPE
int type. |
static String |
INTEGER_CLASS_NAME
Integer class name. |
static String |
LONG_CLASS_NAME
Long class name. |
static long |
LONG_SIGN
The long sign bit. |
static String |
LONG_TYPE
long type. |
static Integer |
MINUS
Minus. |
static Double |
NAN
NaN. |
static String |
OBJECT_CLASS_NAME
Object class name. |
static Integer |
PLUS
Plus. |
static String |
SHORT_CLASS_NAME
Short class name. |
static String |
SHORT_TYPE
short type. |
static Integer |
ZERO
Zero. |
Constructor Summary | |
---|---|
Types()
|
Method Summary | |
---|---|
static boolean |
equals(Object o1,
Object o2)
Checks whether two objects are equal. |
static int |
getArrayDepth(String type)
Gets the depth of a multi-dimensional array type. |
static ClassLoader |
getContextClassLoader(Object... objects)
Gets the context class loader with privileges enabled. |
static boolean |
isArrayType(String className)
Checks whether the specified class type is an array. |
static boolean |
isBooleanType(String className,
boolean arrayp,
Class<?>... loaded)
Checks whether the specified class type is boolean, i.e. |
static boolean |
isDecimalType(String className,
boolean arrayp,
Class<?>... loaded)
Checks whether the specified class type is decimal. |
static boolean |
isEnumType(String className,
boolean arrayp,
Class<?>... loaded)
Checks whether the specified class type is enum, i.e. |
static boolean |
isIntegralType(String className,
boolean arrayp,
Class<?>... loaded)
Checks whether the specified class type is integral. |
static boolean |
isNaN(Number number)
Checks whether the specified number is a NaN. |
static boolean |
isNumericType(String className,
boolean arrayp,
Class<?>... loaded)
Checks whether the specified class type is numeric, i.e. |
static boolean |
isPrimitiveType(String className,
boolean arrayp)
Checks whether the specified class type is primitive. |
static String |
toArrayType(String className,
int... depth)
Converts the specified component type to the corresponding array type. |
static boolean |
toBoolean(String str)
Converts a string to a boolean. |
static byte |
toByte(String str)
Converts a string to a byte. |
static Class<?> |
toComponentClass(Class<?> clazz)
Converts the specified array class to the corresponding component class. |
static String |
toComponentType(String className)
Converts the specified array type to the corresponding component type. |
static Enum<?>[] |
toEnums(Class<?> clazz,
int mask)
Converts a mask of ordinals of enums to an array of enum instances. |
static Enum<?>[] |
toEnums(Enum<?>[] enums,
int mask)
Converts a mask of ordinals of enums to an array of enum instances. |
static Enum<?>[] |
toEnums(String className,
int mask)
Converts a mask of ordinals of enums to an array of enum instances. |
static int |
toInt(String str)
Converts a string to an int. |
static long |
toLong(String str)
Converts a string to a long. |
static int |
toMask(Enum<?>[] enums)
Converts an array of enum instances to a mask of enum ordinals. |
static Number |
toNumber(Number num,
String type)
Converts a number to the specified number. |
static Number |
toNumber(String str)
Converts a typed string to a number. |
static Number |
toNumber(String str,
String type)
Converts a string to the specified number. |
static Class<?> |
toObjectClass(Class<?> type)
Converts a primitive type to its corresponding object class. |
static Class<?> |
toObjectClass(String primitive)
Converts a named primitive type to its corresponding object class. |
static String |
toObjectType(String primitive)
Converts a primitive type to the corresponding object type. |
static String |
toPackageName(String className)
Converts a class name to a package name. |
static String |
toPlainType(Class<?> clazz)
Converts a class to its plain non-qualified component type. |
static String |
toPlainType(String className)
Converts a class name to its plain non-qualified component type. |
static String |
toPrimitiveArrayType(String className)
Converts an object type to the corresponding primitive array type. |
static Class<?> |
toPrimitiveClass(Class<?> clazz)
Converts a class to its corresponding primitive type. |
static Class<?> |
toPrimitiveClass(String className)
Converts a named class to its corresponding primitive type. |
static String |
toPrimitiveType(String className)
Converts an object type to the corresponding primitive type. |
static short |
toShort(String str)
Converts a string to a short. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int INT_SIGN
public static final long LONG_SIGN
public static final Double NAN
public static final Integer ZERO
public static final Integer PLUS
public static final Integer MINUS
public static final String BYTE_TYPE
public static final String CHAR_TYPE
public static final String SHORT_TYPE
public static final String INT_TYPE
public static final String LONG_TYPE
public static final String FLOAT_TYPE
public static final String DOUBLE_TYPE
public static final String BOOLEAN_TYPE
public static final String BYTE_CLASS_NAME
public static final String CHARACTER_CLASS_NAME
public static final String SHORT_CLASS_NAME
public static final String INTEGER_CLASS_NAME
public static final String LONG_CLASS_NAME
public static final String FLOAT_CLASS_NAME
public static final String DOUBLE_CLASS_NAME
public static final String BOOLEAN_CLASS_NAME
public static final String ENUM_CLASS_NAME
public static final String OBJECT_CLASS_NAME
Constructor Detail |
---|
public Types()
Method Detail |
---|
public static boolean toBoolean(String str)
str
- the string to convert.
public static byte toByte(String str)
str
- the string to convert.
public static short toShort(String str)
str
- the string to convert.
public static int toInt(String str)
str
- the string to convert.
public static long toLong(String str)
str
- the string to convert.
public static Number toNumber(String str)
str
- the string to convert.
NumberFormatException
- for an invalid string.public static Number toNumber(Number num, String type)
num
- the number to convert.type
- the requested type.
public static Number toNumber(String str, String type)
str
- the string to convert.type
- the requested type.
NumberFormatException
- for an invalid string.public static boolean equals(Object o1, Object o2)
o1
- the first object.o2
- the second object.
public static boolean isNaN(Number number)
number
- the number to check.
public static boolean isNumericType(String className, boolean arrayp, Class<?>... loaded)
className
- the class type to check.arrayp
- true if an array type is accepted.loaded
- an optionally loaded class.
public static boolean isDecimalType(String className, boolean arrayp, Class<?>... loaded)
className
- the class type to check.arrayp
- true if an array type is accepted.loaded
- an optionally loaded class.
public static boolean isIntegralType(String className, boolean arrayp, Class<?>... loaded)
className
- the class type to check.arrayp
- true if an array type is accepted.loaded
- an optionally loaded class.
public static boolean isBooleanType(String className, boolean arrayp, Class<?>... loaded)
className
- the class type to check.arrayp
- true if an array type is accepted.loaded
- an optionally loaded class.
public static boolean isEnumType(String className, boolean arrayp, Class<?>... loaded)
className
- the class type to check.arrayp
- true if an array type is accepted.loaded
- an optionally loaded class.
public static boolean isPrimitiveType(String className, boolean arrayp)
className
- the class type to check.arrayp
- true if an array type is accepted.
public static boolean isArrayType(String className)
className
- the class type to check.
public static Class<?> toPrimitiveClass(Class<?> clazz)
clazz
- the class to convert.
public static Class<?> toPrimitiveClass(String className)
className
- the class name to convert.
public static Class<?> toObjectClass(Class<?> type)
type
- the primitive type to convert.
public static Class<?> toObjectClass(String primitive)
primitive
- the primitive type to convert.
public static String toComponentType(String className)
Note that the return type is a non-array component type also for multidimensional arrays.
className
- the array type to convert.
public static String toArrayType(String className, int... depth)
className
- the component type to convert.depth
- the array depth to add.
public static String toPrimitiveType(String className)
className
- the object type to convert.
public static Class<?> toComponentClass(Class<?> clazz)
Note that the return type is a non-array component class also for multidimensional arrays.
clazz
- the array class to convert.
public static String toPrimitiveArrayType(String className)
className
- the object type to convert.
public static String toObjectType(String primitive)
primitive
- the primitive type to convert.
public static int getArrayDepth(String type)
type
- the array type.
public static String toPlainType(Class<?> clazz)
clazz
- the class.
public static String toPlainType(String className)
className
- the qualified class name.
public static String toPackageName(String className)
className
- the class name to convert.
public static int toMask(Enum<?>[] enums)
enums
- an array of enum instances.
public static Enum<?>[] toEnums(String className, int mask)
className
- the enum class name.mask
- the enum mask to convert.
public static Enum<?>[] toEnums(Class<?> clazz, int mask)
clazz
- the enum class.mask
- the enum mask to convert.
public static Enum<?>[] toEnums(Enum<?>[] enums, int mask)
enums
- an array of enums constants.mask
- the enum mask to convert.
public static ClassLoader getContextClassLoader(Object... objects)
objects
- optional default objects, classes and loaders.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |