Class BeanMap
- java.lang.Object
 - 
- java.util.AbstractMap
 - 
- org.apache.commons.collections.BeanMap
 
 
 
- 
- All Implemented Interfaces:
 java.lang.Cloneable,java.util.Map
public class BeanMap extends java.util.AbstractMap implements java.lang.CloneableDeprecated.Identical class now available in commons-beanutils (full jar version). This version is due to be removed in collections v4.0.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:
 - Commons Collections 1.0
 
 
- 
- 
Field Summary
Fields Modifier and Type Field Description static java.util.HashMapdefaultTransformersDeprecated.Maps primitive Class types to transformers.static java.lang.Object[]NULL_ARGUMENTSDeprecated.An empty array. 
- 
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidclear()Deprecated.This method reinitializes the bean map to have default values for the bean's properties.java.lang.Objectclone()Deprecated.Clone this bean map using the following process: If there is no underlying bean, return a cloned BeanMap without a bean.booleancontainsKey(java.lang.Object name)Deprecated.Returns true if the bean defines a property with the given name.booleancontainsValue(java.lang.Object value)Deprecated.Returns true if the bean defines a property whose current value is the given object.java.util.IteratorentryIterator()Deprecated.Convenience method for getting an iterator over the entries.java.util.SetentrySet()Deprecated.Gets a Set of MapEntry objects that are the mappings for this BeanMap.java.lang.Objectget(java.lang.Object name)Deprecated.Returns the value of the bean's property with the given name.java.lang.ObjectgetBean()Deprecated.Returns the bean currently being operated on.java.lang.reflect.MethodgetReadMethod(java.lang.String name)Deprecated.Returns the accessor for the property with the given name.java.lang.ClassgetType(java.lang.String name)Deprecated.Returns the type of the property with the given name.java.lang.reflect.MethodgetWriteMethod(java.lang.String name)Deprecated.Returns the mutator for the property with the given name.java.util.IteratorkeyIterator()Deprecated.Convenience method for getting an iterator over the keys.java.util.SetkeySet()Deprecated.Get the keys for this BeanMap.java.lang.Objectput(java.lang.Object name, java.lang.Object value)Deprecated.Sets the bean property with the given name to the given value.voidputAllWriteable(BeanMap map)Deprecated.Puts all of the writable properties from the given BeanMap into this BeanMap.voidsetBean(java.lang.Object newBean)Deprecated.Sets the bean to be operated on by this map.intsize()Deprecated.Returns the number of properties defined by the bean.java.lang.StringtoString()Deprecated.java.util.IteratorvalueIterator()Deprecated.Convenience method for getting an iterator over the values.java.util.Collectionvalues()Deprecated.Returns the values for the BeanMap. 
 - 
 
- 
- 
Field Detail
- 
NULL_ARGUMENTS
public static final java.lang.Object[] NULL_ARGUMENTS
Deprecated.An empty array. Used to invoke accessors via reflection. 
- 
defaultTransformers
public static java.util.HashMap defaultTransformers
Deprecated.Maps primitive Class types to transformers. The transformer transform strings into the appropriate primitive wrapper. 
 - 
 
- 
Constructor Detail
- 
BeanMap
public BeanMap()
Deprecated.Constructs a new emptyBeanMap. 
- 
BeanMap
public BeanMap(java.lang.Object bean)
Deprecated.Constructs a newBeanMapthat operates on the specified bean. If the given bean isnull, then this map will be empty.- Parameters:
 bean- the bean for this map to operate on
 
 - 
 
- 
Method Detail
- 
toString
public java.lang.String toString()
Deprecated.- Overrides:
 toStringin classjava.util.AbstractMap
 
- 
clone
public java.lang.Object clone() throws java.lang.CloneNotSupportedExceptionDeprecated.Clone this bean map using the following process:- If there is no underlying bean, return a cloned BeanMap without a bean.
 - Since there is an underlying bean, try to instantiate a new bean of the same type using Class.newInstance().
 - If the instantiation fails, throw a CloneNotSupportedException
 - Clone the bean map and set the newly instantiated bean as the underlying bean for the bean map.
 - Copy each property that is both readable and writable from the existing object to a cloned bean map.
 - If anything fails along the way, throw a
 CloneNotSupportedException.
 
 
- Throws:
 java.lang.CloneNotSupportedException
 
- 
putAllWriteable
public void putAllWriteable(BeanMap map)
Deprecated.Puts all of the writable properties from the given BeanMap into this BeanMap. Read-only and Write-only properties will be ignored.- Parameters:
 map- the BeanMap whose properties to put
 
- 
clear
public void clear()
Deprecated.This method reinitializes the bean map to have default values for the bean's properties. This is accomplished by constructing a new instance of the bean which the map uses as its underlying data source. This behavior forclear()differs from the Map contract in that the mappings are not actually removed from the map (the mappings for a BeanMap are fixed).- Specified by:
 clearin interfacejava.util.Map- Overrides:
 clearin classjava.util.AbstractMap
 
- 
containsKey
public boolean containsKey(java.lang.Object name)
Deprecated.Returns true if the bean defines a property with the given name.The given name must be a
String; if not, this method returns false. This method will also return false if the bean does not define a property with that name.Write-only properties will not be matched as the test operates against property read methods.
- Specified by:
 containsKeyin interfacejava.util.Map- Overrides:
 containsKeyin classjava.util.AbstractMap- Parameters:
 name- the name of the property to check- Returns:
 - false if the given name is null or is not a 
String; false if the bean does not define a property with that name; or true if the bean does define a property with that name 
 
- 
containsValue
public boolean containsValue(java.lang.Object value)
Deprecated.Returns true if the bean defines a property whose current value is the given object.- Specified by:
 containsValuein interfacejava.util.Map- Overrides:
 containsValuein classjava.util.AbstractMap- Parameters:
 value- the value to check- Returns:
 - false true if the bean has at least one property whose current value is that object, false otherwise
 
 
- 
get
public java.lang.Object get(java.lang.Object name)
Deprecated.Returns the value of the bean's property with the given name.The given name must be a
Stringand must not be null; otherwise, this method returnsnull. If the bean defines a property with the given name, the value of that property is returned. Otherwise,nullis returned.Write-only properties will not be matched as the test operates against property read methods.
- Specified by:
 getin interfacejava.util.Map- Overrides:
 getin classjava.util.AbstractMap- Parameters:
 name- the name of the property whose value to return- Returns:
 - the value of the property with that name
 
 
- 
put
public java.lang.Object put(java.lang.Object name, java.lang.Object value) throws java.lang.IllegalArgumentException, java.lang.ClassCastExceptionDeprecated.Sets the bean property with the given name to the given value.- Specified by:
 putin interfacejava.util.Map- Overrides:
 putin classjava.util.AbstractMap- Parameters:
 name- the name of the property to setvalue- the value to set that property to- Returns:
 - the previous value of that property
 - Throws:
 java.lang.IllegalArgumentException- if the given name is null; if the given name is not aString; if the bean doesn't define a property with that name; or if the bean property with that name is read-onlyjava.lang.ClassCastException
 
- 
size
public int size()
Deprecated.Returns the number of properties defined by the bean.- Specified by:
 sizein interfacejava.util.Map- Overrides:
 sizein classjava.util.AbstractMap- Returns:
 - the number of properties defined by the bean
 
 
- 
keySet
public java.util.Set keySet()
Deprecated.Get the keys for this BeanMap.Write-only properties are not included in the returned set of property names, although it is possible to set their value and to get their type.
- Specified by:
 keySetin interfacejava.util.Map- Overrides:
 keySetin classjava.util.AbstractMap- Returns:
 - BeanMap keys. The Set returned by this method is not modifiable.
 
 
- 
entrySet
public java.util.Set entrySet()
Deprecated.Gets a Set of MapEntry objects that are the mappings for this BeanMap.Each MapEntry can be set but not removed.
- Specified by:
 entrySetin interfacejava.util.Map- Specified by:
 entrySetin classjava.util.AbstractMap- Returns:
 - the unmodifiable set of mappings
 
 
- 
values
public java.util.Collection values()
Deprecated.Returns the values for the BeanMap.- Specified by:
 valuesin interfacejava.util.Map- Overrides:
 valuesin classjava.util.AbstractMap- Returns:
 - values for the BeanMap. The returned collection is not modifiable.
 
 
- 
getType
public java.lang.Class getType(java.lang.String name)
Deprecated.Returns the type of the property with the given name.- Parameters:
 name- the name of the property- Returns:
 - the type of the property, or 
nullif no such property exists 
 
- 
keyIterator
public java.util.Iterator keyIterator()
Deprecated.Convenience method for getting an iterator over the keys.Write-only properties will not be returned in the iterator.
- Returns:
 - an iterator over the keys
 
 
- 
valueIterator
public java.util.Iterator valueIterator()
Deprecated.Convenience method for getting an iterator over the values.- Returns:
 - an iterator over the values
 
 
- 
entryIterator
public java.util.Iterator entryIterator()
Deprecated.Convenience method for getting an iterator over the entries.- Returns:
 - an iterator over the entries
 
 
- 
getBean
public java.lang.Object getBean()
Deprecated.Returns the bean currently being operated on. The return value may be null if this map is empty.- Returns:
 - the bean being operated on by this map
 
 
- 
setBean
public void setBean(java.lang.Object newBean)
Deprecated.Sets the bean to be operated on by this map. The given value may be null, in which case this map will be empty.- Parameters:
 newBean- the new bean to operate on
 
- 
getReadMethod
public java.lang.reflect.Method getReadMethod(java.lang.String name)
Deprecated.Returns the accessor for the property with the given name.- Parameters:
 name- the name of the property- Returns:
 - the accessor method for the property, or null
 
 
- 
getWriteMethod
public java.lang.reflect.Method getWriteMethod(java.lang.String name)
Deprecated.Returns the mutator for the property with the given name.- Parameters:
 name- the name of the property- Returns:
 - the mutator method for the property, or null
 
 
 - 
 
 -