|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.abstracthorizon.danube.beanconsole.BeanHelper
public class BeanHelper
Helper class for manipulation of beans.
Field Summary | |
---|---|
static Object[] |
EMPTY_ARRAY
Empty object array |
Constructor Summary | |
---|---|
BeanHelper()
|
Method Summary | |
---|---|
static String[] |
convertPath(String path)
Converts "/" delimited string into the array |
protected static String |
createName(String path)
Creates name of the bean from the given path. |
static String |
createPath(String path)
Creates path separated with ".". |
static String |
createResourcePath(String path)
This method ensures that component path is or empty string or a path that starts and ends with "/" |
static String |
getAccessType(PropertyDescriptor property)
Returns access type as in BeanDef for the given property |
static Collection<MethodDescriptor> |
getMethodDescriptors(BeanInfo beanInfo)
This method returns collection of method descriptors for given beanInfo. |
static Object |
getPropertyValue(Object bean,
PropertyDescriptor property)
Returns property's value of the given bean |
static String |
getPropertyValueAsString(Object bean,
PropertyDescriptor property)
Returns property's value as a string. |
static String |
getPropertyValueAsString(Object object,
String propertyName)
Returns property's value as a string. |
static boolean |
isFollowable(Class<?> cls)
Returns true if given class is not String and not a primitive type. |
static boolean |
isFollowable(Object object)
Returns true if given object is not null and its class is not String and not a primitive type. |
static Object |
navigate(Object from,
String path)
This method navigates through objects from given root object to the object specified by path. |
static void |
prepare(Object object,
Map<String,Object> result)
This method set model parameters needed for preseting given object. |
static String |
stackTrace(Throwable t)
Returns stack trace of given throwable object as a string. |
static String |
toString(Object object)
Presents given object as a string. |
static String |
toTypeString(Class<?> type)
Presetns a class as a string |
static String |
toTypeString(Object object)
result.toString() Presetns the object's class as a string |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final Object[] EMPTY_ARRAY
Constructor Detail |
---|
public BeanHelper()
Method Detail |
---|
public static Object navigate(Object from, String path) throws BeanAccessException
Algorithm for navigating through objects is as following (in that order):
List
or an array.ApplicationContext
type then a bean of path element's name is tried to be retrieved.Map
) then an entry of path's entry name is fetched
Each step is performed if previous returns null
(or an exception that is in this case ignored).
from
- root objectpath
- path
BeanAccessException
- if there is a problem in dereferencingpublic static void prepare(Object object, Map<String,Object> result)
BeanDef
objects - if object is of ConfigurableApplicationContext
type.BeanDef
objects - if object is of Map
type.BeanDef
objects - if object is of Collection
type.BeanDef
objects - object accessible properties.MethodDescriptor
object - methods that are not used for properties' access.
object
- result
- public static String toString(Object object)
object
- object
public static String toTypeString(Class<?> type)
type
- the class
public static String toTypeString(Object object)
object
- the class
protected static String createName(String path)
path
- the path
public static String createPath(String path)
path
- the path
public static String createResourcePath(String path)
path
- component path
public static String[] convertPath(String path)
path
- "/" delimited
public static String getAccessType(PropertyDescriptor property)
BeanDef
for the given property
property
- the property
BeanDef
public static Object getPropertyValue(Object bean, PropertyDescriptor property)
bean
- the beanproperty
- the property
public static String getPropertyValueAsString(Object object, String propertyName)
Object.toString()
method.
object
- the beanproperty
- the property
public static String getPropertyValueAsString(Object bean, PropertyDescriptor property)
Object.toString()
method.
bean
- the beanproperty
- the property
public static Collection<MethodDescriptor> getMethodDescriptors(BeanInfo beanInfo)
beanInfo
-
public static boolean isFollowable(Class<?> cls)
true
if given class is not String
and not a primitive type.
cls
- the class
true
if given class is not String
and not a primitive type.public static boolean isFollowable(Object object)
true
if given object is not null and its class is not String
and not a primitive type.
object
- the object
true
if given object is not null and its class is not String
and not a primitive type.public static String stackTrace(Throwable t)
t
- the throwable object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |