|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jpu.patterns.common.JPUBeanUtils
Public static methods for manipulating beans. Unless otherwise
indicated, these methods are all standalone and usable with our without any of the other
classes provided by the org.jpu.patterns.proxy
package or any other portions
of the JPatternUtils library. None of these methods requires that any of the objects passed
in be backed by ProxyBean
.
Some of the methods of this class perform similar functions to
org.apache.commons.beanutils.PropertyUtils,
and you may use PropertyUtils
to manipulate objects backed by ProxyBean
.
However, the methods here are optimized to give the best performance for the operations
needed by ProxyBean
, and provide a finer level of control.
Nested Class Summary | |
static class |
JPUBeanUtils.MethodDescriptor
|
Constructor Summary | |
JPUBeanUtils()
|
Method Summary | |
static java.util.Map |
copy(java.lang.Object from,
java.lang.Object to)
Convenience alias for " copy(from, to, null) ". |
static java.util.Map |
copy(java.lang.Object from,
java.lang.Object to,
CopyOptions options)
Copies specified attributes from " from " to "to "
giving the caller very precise control, via the "options " parameter,
over how the copying is to take place. |
static long |
getCacheHits()
|
static long |
getCacheMisses()
|
protected static org.jpu.patterns.common.JPUBeanUtils.ClassDescriptor |
getClassDescriptor(java.lang.Class c)
|
protected static java.util.Iterator |
getClassIterator(java.lang.Class c)
|
static JPUBeanUtils.MethodDescriptor |
getDescriptor(java.lang.reflect.Method method)
|
static java.util.Map |
getMethods(java.lang.Class[] classes,
int type,
boolean descs,
boolean includeSuperclassAttributes)
Returns all methods of the given type declared in any classes in the " classes "
array (or their superclasses or superinterfaces), keyed by corresponding attribute
name. |
static void |
resetCacheCounters()
|
protected static java.lang.Class[] |
trimClasses(java.lang.Class[] classes,
java.lang.Object o)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public JPUBeanUtils()
Method Detail |
public static java.util.Map copy(java.lang.Object from, java.lang.Object to) throws CopyException
copy(from, to, null)
".
CopyException
public static java.util.Map copy(java.lang.Object from, java.lang.Object to, CopyOptions options) throws CopyException
from
" to "to
"
giving the caller very precise control, via the "options
" parameter,
over how the copying is to take place. Copying is done via accessible
getters of "from
" and compatible accessible setters of
"to
".
This class does not perform any kind of attribute conversion. You can use org.apache.commons.beanutils.BeanUtils, for this type of copying.
For purposes of this method, a getter is a method whose name starts with
"get", takes no arguments, and returns non-void; or starts with the word
"is", takes no arguents, and returns a Boolean
or boolean
.
A setter is a method whose name starts with "set" and takes one argument.
Options affecting this method's behavior are described below:
options.ignoreNulls
. If the getter returns null
, don't call
the corresponding setter.
options.sourceClasses
. If non-null
, copy only attributes whose getters are
declared in one or more of these classes or interfaces (or their superclasses or superinterfaces), ignoring all others.
Any classes or interfaces that "from
" is not an instance of
are tacitly ignored.
options.destClasses
. If non-null
, restrict the search for appropriate setters
to methods declared in at least one of these classes or interfaces (or their superclasses or superinterfaces).
Any classes or interfaces that "to
" is not an instance of
are tacitly ignored.
options.attributesToCopy
. If non-null
, only copy the attributes whose
names are contained in this set, ignoring all others. Any named attribute
that has no corresponding getter in the source or setter in the destination
is ignored.
options.attributesToIgnore
. If non-null
, ignore any attributes whose
names are contained in this set.
options.unmatchedAttributes
. If non-null
, this
Map
is populated with all attributes which were obtained
from "from
" but for which no matching setter was found
in "to
". The map's keys will be attribute names, while
the corresponding values will be the attributes' values as returned
by the getter.
CopyException
public static void resetCacheCounters()
public static long getCacheMisses()
public static long getCacheHits()
public static JPUBeanUtils.MethodDescriptor getDescriptor(java.lang.reflect.Method method)
public static java.util.Map getMethods(java.lang.Class[] classes, int type, boolean descs, boolean includeSuperclassAttributes)
classes
"
array (or their superclasses or superinterfaces), keyed by corresponding attribute
name. "type
" should be one of the public static constants of
JPUBeanUtils.MethodDescriptor
. If descs
is true, the returned Map
will contain JPUBeanUtils.MethodDescriptor
's, else it will contain Method
's.
protected static java.util.Iterator getClassIterator(java.lang.Class c)
protected static java.lang.Class[] trimClasses(java.lang.Class[] classes, java.lang.Object o)
protected static org.jpu.patterns.common.JPUBeanUtils.ClassDescriptor getClassDescriptor(java.lang.Class c)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |