Keel 2.1RC2

org.apache.commons.collections
Class BeanMap

java.lang.Object
  extended byjava.util.AbstractMap
      extended byorg.apache.commons.collections.BeanMap
All Implemented Interfaces:
java.lang.Cloneable, java.util.Map

public class BeanMap
extends java.util.AbstractMap
implements java.lang.Cloneable

An implementation of Map for JavaBeans which uses introspection to get and put properties in the bean. If an exception occurs during attempts to get or set a property then the property is considered non existent in the Map

Since:
1.0
Author:

Nested Class Summary
protected static class BeanMap.MyMapEntry
          Map entry used by BeanMap.
 
Nested classes inherited from class java.util.AbstractMap
 
Nested classes inherited from class java.util.Map
java.util.Map.Entry
 
Field Summary
private  java.lang.Object bean
           
static java.util.HashMap defaultTransformers
          Maps primitive Class types to transformers.
static java.lang.Object[] NULL_ARGUMENTS
          An empty array.
private  java.util.HashMap readMethods
           
private  java.util.HashMap types
           
private  java.util.HashMap writeMethods
           
 
Fields inherited from class java.util.AbstractMap
 
Constructor Summary
BeanMap()
          Constructs a new empty BeanMap.
BeanMap(java.lang.Object bean)
          Constructs a new BeanMap that operates on the specified bean.
 
Method Summary
 void clear()
          This method reinitializes the bean map to have default values for the bean's properties.
 java.lang.Object clone()
          Clone this bean map using the following process: If there is no underlying bean, return a cloned BeanMap without a bean.
 boolean containsKey(java.lang.Object name)
          Returns true if the bean defines a property with the given name.
 boolean containsValue(java.lang.Object value)
          Returns true if the bean defines a property whose current value is the given object.
protected  java.lang.Object convertType(java.lang.Class newType, java.lang.Object value)
          Converts the given value to the given type.
protected  java.lang.Object[] createWriteMethodArguments(java.lang.reflect.Method method, java.lang.Object value)
          Creates an array of parameters to pass to the given mutator method.
 java.util.Iterator entryIterator()
          Convenience method for getting an iterator over the entries.
 java.util.Set entrySet()
          Get the mappings for this BeanMap
protected  void firePropertyChange(java.lang.Object key, java.lang.Object oldValue, java.lang.Object newValue)
          Called during a successful put(Object,Object) operation.
 java.lang.Object get(java.lang.Object name)
          Returns the value of the bean's property with the given name.
 java.lang.Object getBean()
          Returns the bean currently being operated on.
protected  java.lang.reflect.Method getReadMethod(java.lang.Object name)
          Returns the accessor for the property with the given name.
 java.lang.Class getType(java.lang.String name)
          Returns the type of the property with the given name.
protected  Transformer getTypeTransformer(java.lang.Class aType)
          Returns a transformer for the given primitive type.
protected  java.lang.reflect.Method getWriteMethod(java.lang.Object name)
          Returns the mutator for the property with the given name.
private  void initialise()
           
 java.util.Iterator keyIterator()
          Convenience method for getting an iterator over the keys.
 java.util.Set keySet()
          Get the keys for this BeanMap.
protected  void logInfo(java.lang.Exception e)
          Logs the given exception to System.out.
protected  void logWarn(java.lang.Exception e)
          Logs the given exception to System.err.
 java.lang.Object put(java.lang.Object name, java.lang.Object value)
          Sets the bean property with the given name to the given value.
 void putAllWriteable(BeanMap map)
          Puts all of the writeable properties from the given BeanMap into this BeanMap.
protected  void reinitialise()
          Reinitializes this bean.
 void setBean(java.lang.Object newBean)
          Sets the bean to be operated on by this map.
 int size()
          Returns the number of properties defined by the bean.
 java.util.Iterator valueIterator()
          Convenience method for getting an iterator over the values.
 java.util.Collection values()
          Returns the values for the BeanMap.
 
Methods inherited from class java.util.AbstractMap
equals, hashCode, isEmpty, putAll, remove, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

bean

private transient java.lang.Object bean

readMethods

private transient java.util.HashMap readMethods

writeMethods

private transient java.util.HashMap writeMethods

types

private transient java.util.HashMap types

NULL_ARGUMENTS

public static final java.lang.Object[] NULL_ARGUMENTS
An empty array. Used to invoke accessors via reflection.


defaultTransformers

public static java.util.HashMap defaultTransformers
Maps primitive Class types to transformers. The transformer transform strings into the appropriate primitive wrapper.

Constructor Detail

BeanMap

public BeanMap()
Constructs a new empty BeanMap.


BeanMap

public BeanMap(java.lang.Object bean)
Constructs a new BeanMap that operates on the specified bean. If the given bean is null, then this map will be empty.

Parameters:
bean - the bean for this map to operate on
Method Detail

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Clone this bean map using the following process: