|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.norther.tammi.acorn.type.Classes
public abstract class Classes
Converts between object classes.
Field Summary | |
---|---|
static String |
ANY_DOMAIN
The domain wildcard. |
static String |
FILE_PATH_SPLITTER
The class path separator expression. |
static String |
GMT_TIME_ZONE
The GMT time zone. |
static String |
MBEAN_SUFFIX
The MBean interface suffix. |
static OrderedMap<String,TimeZone> |
TIME_ZONES
The known time zones. |
Constructor Summary | |
---|---|
Classes()
|
Method Summary | ||
---|---|---|
static
|
cast(Object object)
Casts an unknown object to the specified parametrized type. |
|
static Object |
getPropertyValue(Object bean,
String field)
Gets the value of the specified property. |
|
static boolean |
isDateType(String className,
boolean arrayp,
Class<?>... loaded)
Checks whether the specified class type is a date, i.e. |
|
static boolean |
isLOBType(String className,
boolean arrayp,
Class<?>... loaded)
Checks whether the specified class type is a LOB, i.e. |
|
static boolean |
isLocalizedPath(String path)
Checks if a path is a localized one. |
|
static boolean |
isLocationType(String className,
boolean arrayp,
Class<?>... loaded)
Checks whether the specified class type is a location, i.e. |
|
static boolean |
isSubtypeOf(String className,
Class<?> superType,
boolean arrayp,
Class<?>... loaded)
Checks whether the specified class type is a subtype of or implements the interface of the specified super type. |
|
static void |
mergePropertyValues(Object source,
Object target,
AttributeFilter... filter)
Merges values of properties of two objects. |
|
static void |
setPropertyValue(Object bean,
String field,
Object value)
Sets the value of the specified property. |
|
static String |
toBaseName(String name)
Converts a localized name to its base name. |
|
static
|
toClass(String type,
boolean... options)
Converts a class or primitive type to the corresponding class by applying the default class loader. |
|
static
|
toClass(String type,
ClassLoader loader,
boolean... options)
Converts a class or primitive type to the corresponding class by applying the specified class loader. |
|
static Class<?>[] |
toClassHierarchy(Class<?> clazz)
Converts the specified class to a class hierarchy of its implemented interfaces and extended superclasses. |
|
static Class<?>[] |
toClassHierarchy(String className)
Converts the named class to a class hierarchy of its implemented interfaces and extended superclasses. |
|
static OrderedMap<Class<Enum<?>>,Enum<?>> |
toEnumConstants(String[] classNames)
Converts the named classes to enum instances. |
|
static
|
toEventListeners(String[] classNames)
Converts the named classes to event listener instances. |
|
static String |
toExtension(File file,
String def)
Converts a file to its extension. |
|
static String |
toExtension(String path,
String def)
Converts a path to its extension. |
|
static String |
toFileName(String path)
Converts a file path to its file name. |
|
static Locale |
toLocale(String str,
String... pattern)
Converts a string to a locale. |
|
static String |
toLocaleName(String name)
Converts a localized name to its corresponding locale name. |
|
static String |
toLocalizedName(String name,
Locale locale)
Converts a base name to a localized name. |
|
static String |
toLocalizedPath(String path,
Locale locale)
Converts a base path to a localized path. |
|
static Class<?> |
toMBean(Class<?> clazz)
Converts a class into its MBean interface. |
|
static Locale |
toNamedLocale(String name)
Converts a localized name to its corresponding locale. |
|
static String |
toPackageName(String uri,
String domain)
Converts an URI path to a package name. |
|
static Object[] |
toParameters(Object parameters,
Object signature)
Converts parameters into the corresponding parameter array. |
|
static String |
toPathName(String path,
boolean... includeSeparator)
Converts a file path to its path name. |
|
static PropertyDescriptor |
toPropertyDescriptor(Class<?> clazz,
String field)
Converts a field of a class into the corresponding property descriptor. |
|
static String |
toQualifiedName(String name)
Converts a base name to the corresponding qualified name. |
|
static String |
toRelativePath(String path)
Converts an absolute path to a relative one. |
|
static String |
toSignature(Object parameter)
Converts a parameter into the corresponding signature. |
|
static String[] |
toSignature(Object parameters,
Object signature)
Converts parameters into the corresponding signature array. |
|
static String |
toString(Locale locale,
String... pattern)
Converts a locale to a string. |
|
static String[] |
toStrings(Locale locale,
String... variants)
Tokenizes a locale and variants and returns the tokens in an array. |
|
static TimeZone |
toTimeZone(Locale locale)
Converts a locale to a time zone. |
|
static TimeZone |
toTimeZone(String id)
Converts a time zone id or a locale variant to a time zone. |
|
static String[] |
toTypeHierarchy(Class<?> clazz)
Converts the specified class to a type hierarchy of its implemented interfaces and extended superclasses. |
|
static String[] |
toTypeHierarchy(String className)
Converts the named class to a type hierarchy of its implemented interfaces and extended superclasses. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String ANY_DOMAIN
public static final String MBEAN_SUFFIX
public static final String GMT_TIME_ZONE
public static final String FILE_PATH_SPLITTER
public static final OrderedMap<String,TimeZone> TIME_ZONES
Constructor Detail |
---|
public Classes()
Method Detail |
---|
public static <T> T cast(Object object)
T
- the parametrized type.object
- the unknown object.
public static <T> Class<T> toClass(String type, boolean... options) throws ClassNotFoundException
T
- the class to load.type
- the type to convert.options
- to discard array dimensions and to prefer object types.
ClassNotFoundException
- if not found.public static <T> Class<T> toClass(String type, ClassLoader loader, boolean... options) throws ClassNotFoundException
T
- the class to load.type
- the type to convert.loader
- the class loader to apply.options
- to discard array dimensions and to prefer object types.
ClassNotFoundException
- if not found.public static Class<?>[] toClassHierarchy(Class<?> clazz)
clazz
- the class to convert.
public static Class<?>[] toClassHierarchy(String className)
className
- the named class to convert.
public static String[] toTypeHierarchy(Class<?> clazz)
clazz
- the class to convert.
public static String[] toTypeHierarchy(String className)
className
- the named class to convert.
public static boolean isSubtypeOf(String className, Class<?> superType, boolean arrayp, Class<?>... loaded)
className
- the class type to check.superType
- the super type.arrayp
- true if an array type is accepted.loaded
- an optionally loaded class.
public static boolean isDateType(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 isLocationType(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 isLOBType(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 String toFileName(String path)
path
- the file path.
public static String toPathName(String path, boolean... includeSeparator)
path
- the file path.includeSeparator
- true to inlude the separator at the end.
public static String toString(Locale locale, String... pattern)
locale
- the locale.pattern
- an optional pattern.
public static Locale toLocale(String str, String... pattern)
Note that the conversion is case insensitive.
str
- the locale string.pattern
- an optional pattern.
public static String toLocaleName(String name)
name
- the localized name.
public static Locale toNamedLocale(String name)
name
- the localized name.
public static String[] toStrings(Locale locale, String... variants)
locale
- the locale to tokenize.variants
- optional variants.
public static String toBaseName(String name)
name
- the localized name.
public static String toLocalizedName(String name, Locale locale)
Note that if the name already contains a locale component, it is returned unmodified.
name
- the base name.locale
- the locale.
public static boolean isLocalizedPath(String path)
path
- the base name.
public static String toLocalizedPath(String path, Locale locale)
Note that if the path already contains a locale component, it is returned unmodified.
path
- the base name.locale
- the locale.
public static String toRelativePath(String path)
path
- the base name.
public static TimeZone toTimeZone(Locale locale)
locale
- the locale.
public static TimeZone toTimeZone(String id)
id
- the id.
public static String toQualifiedName(String name)
name
- the base name.
public static String toPackageName(String uri, String domain)
uri
- the URI path to convert.domain
- the default domain to replace '*'.
public static String toExtension(String path, String def)
path
- the path.def
- the default.
public static String toExtension(File file, String def)
file
- the file.def
- the default.
public static Class<?> toMBean(Class<?> clazz)
clazz
- the class to convert.
public static <L extends EventListener> OrderedMap<Class<L>,L[]> toEventListeners(String[] classNames) throws ClassNotFoundException, InstantiationException, IllegalAccessException
L
- the event listener class.classNames
- the named classes to convert.
ClassNotFoundException
- for missing classes.
IllegalAccessException
- for illegal access.
InstantiationException
- for failed instantiation.public static OrderedMap<Class<Enum<?>>,Enum<?>> toEnumConstants(String[] classNames) throws ClassNotFoundException, InstantiationException, IllegalAccessException
classNames
- the named classes to convert.
ClassNotFoundException
- for missing classes.
IllegalAccessException
- for illegal access.
InstantiationException
- for failed instantiation.public static String toSignature(Object parameter)
parameter
- a parameter to convert.
public static String[] toSignature(Object parameters, Object signature)
parameters
- parameters to convert.signature
- an optional signature.
public static Object[] toParameters(Object parameters, Object signature)
parameters
- parameters to convert.signature
- an optional signature.
IllegalArgumentException
- if parameters and signature are
imcompatible with each other.public static PropertyDescriptor toPropertyDescriptor(Class<?> clazz, String field)
clazz
- the class.field
- the field.
public static Object getPropertyValue(Object bean, String field) throws IllegalAccessException, InvocationTargetException
bean
- the bean.field
- the field.
IllegalAccessException
- if inaccessible.
InvocationTargetException
- if failed.
IllegalArgumentException
- if not available.public static void setPropertyValue(Object bean, String field, Object value) throws IllegalAccessException, InvocationTargetException
bean
- the bean.field
- the field.value
- the value.
IllegalAccessException
- if inaccessible.
InvocationTargetException
- if failed.
IllegalArgumentException
- if not available.public static void mergePropertyValues(Object source, Object target, AttributeFilter... filter) throws IntrospectionException, IllegalAccessException, InvocationTargetException
source
- the source bean.target
- the target bean.filter
- an optional attribute filter.
IllegalAccessException
- if inaccessible.
IntrospectionException
- if faulty.
InvocationTargetException
- if failed.
IllegalArgumentException
- if not available.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |