|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjfun.yan.util.Utils
public class Utils
Common utility class that provides some utility functions.
| Constructor Summary | |
|---|---|
Utils()
|
|
| Method Summary | |
|---|---|
static Component |
asComponent(Binder binder)
Convert a Binder object's bind() method to a Component that expects one parameter and instantiates the component instance by calling the return value of the bind() method. |
static java.util.List |
asList(java.lang.Object arr)
Use an array as a list. |
static java.util.List |
createList(java.lang.Class impltype,
int capacity)
Create a java.util.List instance. |
static java.util.Map |
createMap(java.lang.Class impltype,
int capacity)
Create a java.util.Map instance. |
static java.lang.Object |
createPreallocatedCollection(java.lang.Class type)
To instantiate a collection instance. |
static java.util.Set |
createSet(java.lang.Class impltype,
int capacity)
Create a java.util.Set instance. |
static java.lang.Class |
getObjType(java.lang.Object arg,
java.lang.Class nulltype)
Get the type of an object. |
static java.lang.String |
getObjTypeName(java.lang.Object arg,
java.lang.String nullname)
Get the type name of an object. |
static void |
injectProperties(BeanType btype,
java.lang.Object obj,
java.util.Set props,
Dependency dep)
Inject property values into a bean. |
static void |
injectProperty(BeanType btype,
java.lang.Object obj,
java.lang.String name,
Dependency dep)
Inject a property value. |
static boolean |
isCompatible(java.lang.Class type,
Component c)
Checkes to see if a component may return a value that's an instance of a type. |
static java.util.Properties |
loadResourceProperties(ResourceLoader loader,
java.lang.String resource)
To read a property file from a class loader into a Properties object. |
static BeanType |
toBeanType(java.lang.Class type)
Get the BeanType for a class. |
static java.util.HashSet |
toSet(java.lang.Object[] keys,
java.lang.String item_name)
Convert an array of objects to a Set. |
static java.lang.String |
toString(java.lang.Class[] param_types)
Convert an array of parameter types to a string in the form of "(type1, type2, type3)". |
static void |
verifyProperties(BeanType btype,
java.util.Set props,
Dependency dep)
Verify that a set of properties can be resolved. |
static YanException |
wrapInstantiationException(java.lang.Throwable e)
Wrap an exception thrown when instantiating components. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Utils()
| Method Detail |
|---|
public static java.lang.String toString(java.lang.Class[] param_types)
param_types - the parameter types.
public static boolean isCompatible(java.lang.Class type,
Component c)
type - the type.c - the component.
public static java.util.Set createSet(java.lang.Class impltype,
int capacity)
throws java.lang.IllegalAccessException,
java.lang.InstantiationException
impltype - the actual implementation class.
If it is null or java.util.Set, java.util.HashSet is used.capacity - the initial capacity.
java.lang.IllegalAccessException - when the constructor is not public.
java.lang.InstantiationException - when the constructor fails.
public static java.util.Map createMap(java.lang.Class impltype,
int capacity)
throws java.lang.IllegalAccessException,
java.lang.InstantiationException
impltype - the actual implementation class.
If it is null or java.util.Map, java.util.HashMap is used.capacity - the initial capacity.
java.lang.IllegalAccessException - when the constructor is not public.
java.lang.InstantiationException - when the constructor fails.
public static java.util.List createList(java.lang.Class impltype,
int capacity)
throws java.lang.IllegalAccessException,
java.lang.InstantiationException
impltype - the implementation class.
If it is null or java.util.List, java.util.ArrayList is used.capacity - the initial capacity.
java.lang.IllegalAccessException - when the constructor is not public.
java.lang.InstantiationException - when the constructor fails.
public static java.lang.Object createPreallocatedCollection(java.lang.Class type)
throws java.lang.IllegalAccessException,
java.lang.InstantiationException
The default constructor of the type is called.
type - the type of the collection.
java.lang.IllegalAccessException - when the constructor is not public.
java.lang.InstantiationException - when the constructor fails.public static Component asComponent(Binder binder)
binder - the Binder object.
public static java.util.List asList(java.lang.Object arr)
arr - the array object.
public static YanException wrapInstantiationException(java.lang.Throwable e)
e - the exception.
public static void injectProperty(BeanType btype,
java.lang.Object obj,
java.lang.String name,
Dependency dep)
btype - the BeanType.obj - the object to inject property into.name - the property name.dep - the dependency to resolve property value.public static BeanType toBeanType(java.lang.Class type)
type - the class.
public static void injectProperties(BeanType btype,
java.lang.Object obj,
java.util.Set props,
Dependency dep)
btype - the BeanType.obj - the bean object.props - the property names.dep - the dependency object to resolve property values.
public static void verifyProperties(BeanType btype,
java.util.Set props,
Dependency dep)
btype - the BeanType object.props - the set of property names.dep - the dependency.
public static java.util.HashSet toSet(java.lang.Object[] keys,
java.lang.String item_name)
keys - the array of objects.item_name - the item name in the error message when duplicate is found.
public static java.util.Properties loadResourceProperties(ResourceLoader loader,
java.lang.String resource)
throws java.io.IOException
loader - the ResourceLoader used to load resource.resource - the resource name.
java.io.IOException - when loading fails.
public static java.lang.String getObjTypeName(java.lang.Object arg,
java.lang.String nullname)
arg - the object.nullname - the default name if the object is null.
public static java.lang.Class getObjType(java.lang.Object arg,
java.lang.Class nulltype)
arg - the object.nulltype - the default type if the object is null.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||