org.jpu.patterns.common
Class JPUBeanUtils

java.lang.Object
  extended byorg.jpu.patterns.common.JPUBeanUtils

public class JPUBeanUtils
extends java.lang.Object

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

JPUBeanUtils

public JPUBeanUtils()
Method Detail

copy

public static java.util.Map copy(java.lang.Object from,
                                 java.lang.Object to)
                          throws CopyException
Convenience alias for "copy(from, to, null)".

Throws:
CopyException

copy

public static java.util.Map copy(java.lang.Object from,
                                 java.lang.Object to,
                                 CopyOptions options)
                          throws CopyException
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. 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:

If for a given attribute no appropriate setter can be found, that attribute is tacitly ignored.

Throws:
CopyException

resetCacheCounters

public static void resetCacheCounters()

getCacheMisses

public static long getCacheMisses()

getCacheHits

public static long getCacheHits()

getDescriptor

public static JPUBeanUtils.MethodDescriptor getDescriptor(java.lang.reflect.Method method)

getMethods

public 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. "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.


getClassIterator

protected static java.util.Iterator getClassIterator(java.lang.Class c)

trimClasses

protected static java.lang.Class[] trimClasses(java.lang.Class[] classes,
                                               java.lang.Object o)

getClassDescriptor

protected static org.jpu.patterns.common.JPUBeanUtils.ClassDescriptor getClassDescriptor(java.lang.Class c)


Copyright (c) 2001-2003 - Apache Software Foundation