|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.navel.beans.BeanManipulator
public class BeanManipulator
This class allows for generically manipulating the values encapsulated in
JavaBeans and Navel beans. Values can be extracted, via Introspection, into a
Map and populated, via Introspection, back into any given JavaBean instance
from a Map.
Navel and JavaBeans are treated equally with no special handling of unset
properties or entries in the Map that do not match any available properties.
For more strict treatment of just Navel beans, use the
ProxyManipulator
.
Field Summary | |
---|---|
static java.lang.Class<?> |
VARIANT_METHODS_ONLY
Returned from typeOf(Class, String) when the property name is
for an indexed property that provides no access to the array itself. |
Method Summary | |
---|---|
static java.util.Map<java.lang.String,java.lang.Object> |
describe(java.lang.Object bean)
Overload that assumes true for suppressExceptions. |
static java.util.Map<java.lang.String,java.lang.Object> |
describe(java.lang.Object bean,
boolean suppressExceptions)
Extracts the values from the bean argument into a Map keyed by property names. |
static boolean |
isPropertyOf(java.lang.Class<?> beanType,
java.lang.String propertyName)
Support method to help in dealing with introspection, reflection of JavaBeans. |
static boolean |
isPropertyOf(java.lang.Object bean,
java.lang.String propertyName)
Support method to help in dealing with introspection, reflection of JavaBeans. |
static java.util.Map<java.lang.String,java.lang.Object> |
populate(java.lang.Object bean,
java.util.Map<java.lang.String,java.lang.Object> values)
Overload that suppresses exceptions. |
static java.util.Map<java.lang.String,java.lang.Object> |
populate(java.lang.Object bean,
java.util.Map<java.lang.String,java.lang.Object> values,
boolean suppressExceptions)
Populates the values from the Map argument into the bean argument. |
static boolean |
putValue(java.lang.Object bean,
java.lang.String property,
java.lang.Object value)
Put a single value into the target bean, assumes that exceptions should be suppressed. |
static boolean |
putValue(java.lang.Object bean,
java.lang.String property,
java.lang.Object value,
boolean suppressException)
Put a single value into the target bean. |
static java.lang.Object |
resolveValue(java.lang.String propertyName,
java.util.Map<java.lang.String,java.lang.Object> values)
Overload that suppresses exceptions. |
static java.lang.Object |
resolveValue(java.lang.String propertyName,
java.util.Map<java.lang.String,java.lang.Object> values,
boolean suppressExceptions)
Utility method to recurse into a description map explicitly for a nested property name and dig out the ultimate value. |
static java.lang.Class<?> |
typeOf(java.lang.Class<?> beanType,
java.lang.String propertyName)
Parse and traverse the provided property name and try to determine its type. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.Class<?> VARIANT_METHODS_ONLY
typeOf(Class, String)
when the property name is
for an indexed property that provides no access to the array itself.
Method Detail |
---|
public static java.util.Map<java.lang.String,java.lang.Object> describe(java.lang.Object bean)
bean
- JavaBean to extract from.flattenNested
- If any of the properties are themselves Navel beans, should we
flatten their properties into the key set of the containing
bean?
public static java.util.Map<java.lang.String,java.lang.Object> describe(java.lang.Object bean, boolean suppressExceptions)
bean
- JavaBean to extract from.suppressExceptions
- Should exceptions by re-thrown as
PropertyAccessException
instances or logged only as
warnings?
public static java.util.Map<java.lang.String,java.lang.Object> populate(java.lang.Object bean, java.util.Map<java.lang.String,java.lang.Object> values)
bean
- JavaBean instance to populate.values
- Values to populate into the bean.public static java.util.Map<java.lang.String,java.lang.Object> populate(java.lang.Object bean, java.util.Map<java.lang.String,java.lang.Object> values, boolean suppressExceptions)
bean
- JavaBean instance to populate.values
- Values to populate into the bean.suppressExceptions
- Should exceptions by re-thrown as
PropertyAccessException
instances or logged only as
warnings?public static boolean putValue(java.lang.Object bean, java.lang.String property, java.lang.Object value)
bean
- Target into which the value will be put, if the property name
is applicable.property
- Single property expression to set the specified value.value
- Value to set if the property expression is valid for the
target.
public static boolean putValue(java.lang.Object bean, java.lang.String property, java.lang.Object value, boolean suppressException)
bean
- Target into which the value will be put, if the property name
is applicable.property
- Single property expression to set the specified value.value
- Value to set if the property expression is valid for the
target.suppressException
- If true, no error will be thrown if the property expression is
invalid.
public static java.lang.Object resolveValue(java.lang.String propertyName, java.util.Map<java.lang.String,java.lang.Object> values)
propertyName
- Property name, may use dot notation.values
- Map of possible values, initially the immediate properties of
some bean, but with each recursive call, it will represent a
new layer of bean properties.
public static java.lang.Object resolveValue(java.lang.String propertyName, java.util.Map<java.lang.String,java.lang.Object> values, boolean suppressExceptions)
propertyName
- Property name, may use dot notation.values
- Map of possible values, initially the immediate properties of
some bean, but with each recursive call, it will represent a
new layer of bean properties.suppressExceptions
- Should exceptions by re-thrown as
PropertyAccessException
instances or logged only as
warnings?
public static boolean isPropertyOf(java.lang.Object bean, java.lang.String propertyName)
bean
- Target bean of any type.propertyName
- Name of a property to check via introspection.
public static boolean isPropertyOf(java.lang.Class<?> beanType, java.lang.String propertyName)
beanType
- Target bean type, be careful not to pass the proxy
type from a dynamic proxy backing a bean.propertyName
- Name of a property to check via introspection.
public static java.lang.Class<?> typeOf(java.lang.Class<?> beanType, java.lang.String propertyName)
beanType
- Target bean type, be careful not to pass the proxy
type from a dynamic proxy backing a bean.propertyName
- Name of a property to check via introspection.
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |