Improve javadoc to clatify role of read-only properties
noted by BluePhelix@web.de git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/collections/trunk@130985 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
1a2f50cb26
commit
2298039999
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/BeanMap.java,v 1.16 2003/02/19 20:14:25 scolebourne Exp $
|
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/BeanMap.java,v 1.17 2003/03/03 19:41:29 scolebourne Exp $
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*
|
*
|
||||||
* The Apache Software License, Version 1.1
|
* The Apache Software License, Version 1.1
|
||||||
|
@ -82,7 +82,7 @@ import java.util.Set;
|
||||||
* property is considered non existent in the Map
|
* property is considered non existent in the Map
|
||||||
*
|
*
|
||||||
* @since Commons Collections 1.0
|
* @since Commons Collections 1.0
|
||||||
* @version $Revision: 1.16 $ $Date: 2003/02/19 20:14:25 $
|
* @version $Revision: 1.17 $ $Date: 2003/03/03 19:41:29 $
|
||||||
*
|
*
|
||||||
* @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
|
* @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
|
||||||
* @author Stephen Colebourne
|
* @author Stephen Colebourne
|
||||||
|
@ -96,13 +96,13 @@ public class BeanMap extends AbstractMap implements Cloneable {
|
||||||
private transient HashMap types = new HashMap();
|
private transient HashMap types = new HashMap();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An empty array. Used to invoke accessors via reflection.
|
* An empty array. Used to invoke accessors via reflection.
|
||||||
*/
|
*/
|
||||||
public static final Object[] NULL_ARGUMENTS = {};
|
public static final Object[] NULL_ARGUMENTS = {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Maps primitive Class types to transformers. The transformer
|
* Maps primitive Class types to transformers. The transformer
|
||||||
* transform strings into the appropriate primitive wrapper.
|
* transform strings into the appropriate primitive wrapper.
|
||||||
*/
|
*/
|
||||||
public static HashMap defaultTransformers = new HashMap();
|
public static HashMap defaultTransformers = new HashMap();
|
||||||
|
|
||||||
|
@ -178,17 +178,17 @@ public class BeanMap extends AbstractMap implements Cloneable {
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new empty <Code>BeanMap</Code>.
|
* Constructs a new empty <code>BeanMap</code>.
|
||||||
*/
|
*/
|
||||||
public BeanMap() {
|
public BeanMap() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new <Code>BeanMap</Code> that operates on the
|
* Constructs a new <code>BeanMap</code> that operates on the
|
||||||
* specified bean. If the given bean is <Code>null</COde>, then
|
* specified bean. If the given bean is <code>null</COde>, then
|
||||||
* this map will be empty.
|
* this map will be empty.
|
||||||
*
|
*
|
||||||
* @param bean the bean for this map to operate on
|
* @param bean the bean for this map to operate on
|
||||||
*/
|
*/
|
||||||
public BeanMap(Object bean) {
|
public BeanMap(Object bean) {
|
||||||
this.bean = bean;
|
this.bean = bean;
|
||||||
|
@ -199,29 +199,28 @@ public class BeanMap extends AbstractMap implements Cloneable {
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clone this bean map using the following process:
|
* Clone this bean map using the following process:
|
||||||
*
|
*
|
||||||
* <ul>
|
* <ul>
|
||||||
|
* <li>If there is no underlying bean, return a cloned BeanMap without a
|
||||||
* <li>If there is no underlying bean, return a cloned BeanMap without a
|
* bean.
|
||||||
* bean.
|
|
||||||
*
|
*
|
||||||
* <li>Since there is an underlying bean, try to instantiate a new bean of
|
* <li>Since there is an underlying bean, try to instantiate a new bean of
|
||||||
* the same type using Class.newInstance().
|
* the same type using Class.newInstance().
|
||||||
*
|
*
|
||||||
* <li>If the instantiation fails, throw a CloneNotSupportedException
|
* <li>If the instantiation fails, throw a CloneNotSupportedException
|
||||||
*
|
*
|
||||||
* <li>Clone the bean map and set the newly instantiated bean as the
|
* <li>Clone the bean map and set the newly instantiated bean as the
|
||||||
* underyling bean for the bean map.
|
* underyling bean for the bean map.
|
||||||
*
|
*
|
||||||
* <li>Copy each property that is both readable and writable from the
|
* <li>Copy each property that is both readable and writable from the
|
||||||
* existing object to a cloned bean map.
|
* existing object to a cloned bean map.
|
||||||
*
|
*
|
||||||
* <li>If anything fails along the way, throw a
|
* <li>If anything fails along the way, throw a
|
||||||
* CloneNotSupportedException.
|
* CloneNotSupportedException.
|
||||||
*
|
*
|
||||||
* <ul>
|
* <ul>
|
||||||
**/
|
*/
|
||||||
public Object clone() throws CloneNotSupportedException {
|
public Object clone() throws CloneNotSupportedException {
|
||||||
BeanMap newMap = (BeanMap)super.clone();
|
BeanMap newMap = (BeanMap)super.clone();
|
||||||
|
|
||||||
|
@ -272,16 +271,16 @@ public class BeanMap extends AbstractMap implements Cloneable {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Puts all of the writeable properties from the given BeanMap into this
|
* Puts all of the writeable properties from the given BeanMap into this
|
||||||
* BeanMap. Read-only properties will be ignored.
|
* BeanMap. Read-only and Write-only properties will be ignored.
|
||||||
*
|
*
|
||||||
* @param map the BeanMap whose properties to put
|
* @param map the BeanMap whose properties to put
|
||||||
*/
|
*/
|
||||||
public void putAllWriteable(BeanMap map) {
|
public void putAllWriteable(BeanMap map) {
|
||||||
Iterator readableKeys = map.readMethods.keySet().iterator();
|
Iterator readableKeys = map.readMethods.keySet().iterator();
|
||||||
while(readableKeys.hasNext()) {
|
while (readableKeys.hasNext()) {
|
||||||
Object key = readableKeys.next();
|
Object key = readableKeys.next();
|
||||||
if(getWriteMethod(key) != null) {
|
if (getWriteMethod(key) != null) {
|
||||||
this.put(key, map.get(key));
|
this.put(key, map.get(key));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -289,13 +288,13 @@ public class BeanMap extends AbstractMap implements Cloneable {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method reinitializes the bean map to have default values for the
|
* This method reinitializes the bean map to have default values for the
|
||||||
* bean's properties. This is accomplished by constructing a new instance
|
* bean's properties. This is accomplished by constructing a new instance
|
||||||
* of the bean which the map uses as its underlying data source. This
|
* of the bean which the map uses as its underlying data source. This
|
||||||
* behavior for <code>clear()</code> differs from the Map contract in that
|
* behavior for <code>clear()</code> differs from the Map contract in that
|
||||||
* the mappings are not actually removed from the map (the mappings for a
|
* the mappings are not actually removed from the map (the mappings for a
|
||||||
* BeanMap are fixed).
|
* BeanMap are fixed).
|
||||||
**/
|
*/
|
||||||
public void clear() {
|
public void clear() {
|
||||||
if(bean == null) return;
|
if(bean == null) return;
|
||||||
|
|
||||||
|
@ -310,44 +309,52 @@ public class BeanMap extends AbstractMap implements Cloneable {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if the bean defines a property with the given name.
|
* Returns true if the bean defines a property with the given name.
|
||||||
* The given name must be a <Code>String</Code>; if not, this method
|
* <p>
|
||||||
* returns false. This method will also return false if the bean
|
* The given name must be a <code>String</code>; if not, this method
|
||||||
* does not define a property with that name.
|
* returns false. This method will also return false if the bean
|
||||||
|
* does not define a property with that name.
|
||||||
|
* <p>
|
||||||
|
* Write-only properties will not be matched as the test operates against
|
||||||
|
* property read methods.
|
||||||
*
|
*
|
||||||
* @param name the name of the property to check
|
* @param name the name of the property to check
|
||||||
* @return false if the given name is null or is not a <Code>String</Code>;
|
* @return false if the given name is null or is not a <code>String</code>;
|
||||||
* false if the bean does not define a property with that name; or
|
* false if the bean does not define a property with that name; or
|
||||||
* true if the bean does define a property with that name
|
* true if the bean does define a property with that name
|
||||||
*/
|
*/
|
||||||
public boolean containsKey(Object name) {
|
public boolean containsKey(Object name) {
|
||||||
Method method = getReadMethod( name );
|
Method method = getReadMethod(name);
|
||||||
return method != null;
|
return method != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if the bean defines a property whose current value is
|
* Returns true if the bean defines a property whose current value is
|
||||||
* the given object.
|
* the given object.
|
||||||
*
|
*
|
||||||
* @param value the value to check
|
* @param value the value to check
|
||||||
* @return false true if the bean has at least one property whose
|
* @return false true if the bean has at least one property whose
|
||||||
* current value is that object, false otherwise
|
* current value is that object, false otherwise
|
||||||
*/
|
*/
|
||||||
public boolean containsValue(Object value) {
|
public boolean containsValue(Object value) {
|
||||||
// use default implementation
|
// use default implementation
|
||||||
return super.containsValue( value );
|
return super.containsValue(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the value of the bean's property with the given name.
|
* Returns the value of the bean's property with the given name.
|
||||||
* The given name must be a {@link String} and must not be
|
* <p>
|
||||||
* null; otherwise, this method returns <Code>null</Code>.
|
* The given name must be a {@link String} and must not be
|
||||||
* If the bean defines a property with the given name, the value of
|
* null; otherwise, this method returns <code>null</code>.
|
||||||
* that property is returned. Otherwise, <Code>null</Code> is
|
* If the bean defines a property with the given name, the value of
|
||||||
* returned.
|
* that property is returned. Otherwise, <code>null</code> is
|
||||||
|
* returned.
|
||||||
|
* <p>
|
||||||
|
* Write-only properties will not be matched as the test operates against
|
||||||
|
* property read methods.
|
||||||
*
|
*
|
||||||
* @param name the name of the property whose value to return
|
* @param name the name of the property whose value to return
|
||||||
* @return the value of the property with that name
|
* @return the value of the property with that name
|
||||||
*/
|
*/
|
||||||
public Object get(Object name) {
|
public Object get(Object name) {
|
||||||
if ( bean != null ) {
|
if ( bean != null ) {
|
||||||
|
@ -374,15 +381,15 @@ public class BeanMap extends AbstractMap implements Cloneable {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the bean property with the given name to the given value.
|
* Sets the bean property with the given name to the given value.
|
||||||
*
|
*
|
||||||
* @param name the name of the property to set
|
* @param name the name of the property to set
|
||||||
* @param value the value to set that property to
|
* @param value the value to set that property to
|
||||||
* @return the previous value of that property
|
* @return the previous value of that property
|
||||||
* @throws IllegalArgumentException if the given name is null;
|
* @throws IllegalArgumentException if the given name is null;
|
||||||
* if the given name is not a {@link String}; if the bean doesn't
|
* if the given name is not a {@link String}; if the bean doesn't
|
||||||
* define a property with that name; or if the bean property with
|
* define a property with that name; or if the bean property with
|
||||||
* that name is read-only
|
* that name is read-only
|
||||||
*/
|
*/
|
||||||
public Object put(Object name, Object value) throws IllegalArgumentException, ClassCastException {
|
public Object put(Object name, Object value) throws IllegalArgumentException, ClassCastException {
|
||||||
if ( bean != null ) {
|
if ( bean != null ) {
|
||||||
|
@ -412,9 +419,9 @@ public class BeanMap extends AbstractMap implements Cloneable {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the number of properties defined by the bean.
|
* Returns the number of properties defined by the bean.
|
||||||
*
|
*
|
||||||
* @return the number of properties defined by the bean
|
* @return the number of properties defined by the bean
|
||||||
*/
|
*/
|
||||||
public int size() {
|
public int size() {
|
||||||
return readMethods.size();
|
return readMethods.size();
|
||||||
|
@ -423,9 +430,13 @@ public class BeanMap extends AbstractMap implements Cloneable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the keys for this BeanMap.
|
* Get the keys for this BeanMap.
|
||||||
|
* <p>
|
||||||
|
* Write-only properties are <b>not</b> included in the returned set of
|
||||||
|
* property names, although it is possible to set their value and to get
|
||||||
|
* their type.
|
||||||
*
|
*
|
||||||
* @return BeanMap keys. The Set returned by this method is not
|
* @return BeanMap keys. The Set returned by this method is not
|
||||||
* modifiable.
|
* modifiable.
|
||||||
*/
|
*/
|
||||||
public Set keySet() {
|
public Set keySet() {
|
||||||
return Collections.unmodifiableSet(readMethods.keySet());
|
return Collections.unmodifiableSet(readMethods.keySet());
|
||||||
|
@ -435,7 +446,7 @@ public class BeanMap extends AbstractMap implements Cloneable {
|
||||||
* Get the mappings for this BeanMap
|
* Get the mappings for this BeanMap
|
||||||
*
|
*
|
||||||
* @return BeanMap mappings. The Set returned by this method
|
* @return BeanMap mappings. The Set returned by this method
|
||||||
* is not modifiable.
|
* is not modifiable.
|
||||||
*/
|
*/
|
||||||
public Set entrySet() {
|
public Set entrySet() {
|
||||||
return Collections.unmodifiableSet(new AbstractSet() {
|
return Collections.unmodifiableSet(new AbstractSet() {
|
||||||
|
@ -471,7 +482,7 @@ public class BeanMap extends AbstractMap implements Cloneable {
|
||||||
* Returns the values for the BeanMap.
|
* Returns the values for the BeanMap.
|
||||||
*
|
*
|
||||||
* @return values for the BeanMap. The returned collection is not
|
* @return values for the BeanMap. The returned collection is not
|
||||||
* modifiable.
|
* modifiable.
|
||||||
*/
|
*/
|
||||||
public Collection values() {
|
public Collection values() {
|
||||||
ArrayList answer = new ArrayList( readMethods.size() );
|
ArrayList answer = new ArrayList( readMethods.size() );
|
||||||
|
@ -489,26 +500,28 @@ public class BeanMap extends AbstractMap implements Cloneable {
|
||||||
* Returns the type of the property with the given name.
|
* Returns the type of the property with the given name.
|
||||||
*
|
*
|
||||||
* @param name the name of the property
|
* @param name the name of the property
|
||||||
* @return the type of the property, or <Code>null</Code> if no such
|
* @return the type of the property, or <code>null</code> if no such
|
||||||
* property exists
|
* property exists
|
||||||
*/
|
*/
|
||||||
public Class getType(String name) {
|
public Class getType(String name) {
|
||||||
return (Class) types.get( name );
|
return (Class) types.get( name );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convenience method for getting an iterator over the keys.
|
* Convenience method for getting an iterator over the keys.
|
||||||
|
* <p>
|
||||||
|
* Write-only properties will not be returned in the iterator.
|
||||||
*
|
*
|
||||||
* @return an iterator over the keys
|
* @return an iterator over the keys
|
||||||
*/
|
*/
|
||||||
public Iterator keyIterator() {
|
public Iterator keyIterator() {
|
||||||
return readMethods.keySet().iterator();
|
return readMethods.keySet().iterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convenience method for getting an iterator over the values.
|
* Convenience method for getting an iterator over the values.
|
||||||
*
|
*
|
||||||
* @return an iterator over the values
|
* @return an iterator over the values
|
||||||
*/
|
*/
|
||||||
public Iterator valueIterator() {
|
public Iterator valueIterator() {
|
||||||
final Iterator iter = keyIterator();
|
final Iterator iter = keyIterator();
|
||||||
|
@ -527,9 +540,9 @@ public class BeanMap extends AbstractMap implements Cloneable {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convenience method for getting an iterator over the entries.
|
* Convenience method for getting an iterator over the entries.
|
||||||
*
|
*
|
||||||
* @return an iterator over the entries
|
* @return an iterator over the entries
|
||||||
*/
|
*/
|
||||||
public Iterator entryIterator() {
|
public Iterator entryIterator() {
|
||||||
final Iterator iter = keyIterator();
|
final Iterator iter = keyIterator();
|
||||||
|
@ -553,20 +566,20 @@ public class BeanMap extends AbstractMap implements Cloneable {
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the bean currently being operated on. The return value may
|
* Returns the bean currently being operated on. The return value may
|
||||||
* be null if this map is empty.
|
* be null if this map is empty.
|
||||||
*
|
*
|
||||||
* @return the bean being operated on by this map
|
* @return the bean being operated on by this map
|
||||||
*/
|
*/
|
||||||
public Object getBean() {
|
public Object getBean() {
|
||||||
return bean;
|
return bean;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the bean to be operated on by this map. The given value may
|
* Sets the bean to be operated on by this map. The given value may
|
||||||
* be null, in which case this map will be empty.
|
* be null, in which case this map will be empty.
|
||||||
*
|
*
|
||||||
* @param newBean the new bean to operate on
|
* @param newBean the new bean to operate on
|
||||||
*/
|
*/
|
||||||
public void setBean( Object newBean ) {
|
public void setBean( Object newBean ) {
|
||||||
bean = newBean;
|
bean = newBean;
|
||||||
|
@ -598,32 +611,32 @@ public class BeanMap extends AbstractMap implements Cloneable {
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the accessor for the property with the given name.
|
* Returns the accessor for the property with the given name.
|
||||||
*
|
*
|
||||||
* @param name the name of the property
|
* @param name the name of the property
|
||||||
* @return null if the name is null; null if the name is not a
|
* @return null if the name is null; null if the name is not a
|
||||||
* {@link String}; null if no such property exists; or the accessor
|
* {@link String}; null if no such property exists; or the accessor
|
||||||
* method for that property
|
* method for that property
|
||||||
*/
|
*/
|
||||||
protected Method getReadMethod( Object name ) {
|
protected Method getReadMethod( Object name ) {
|
||||||
return (Method) readMethods.get( name );
|
return (Method) readMethods.get( name );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the mutator for the property with the given name.
|
* Returns the mutator for the property with the given name.
|
||||||
*
|
*
|
||||||
* @param name the name of the
|
* @param name the name of the
|
||||||
* @return null if the name is null; null if the name is not a
|
* @return null if the name is null; null if the name is not a
|
||||||
* {@link String}; null if no such property exists; null if the
|
* {@link String}; null if no such property exists; null if the
|
||||||
* property is read-only; or the mutator method for that property
|
* property is read-only; or the mutator method for that property
|
||||||
*/
|
*/
|
||||||
protected Method getWriteMethod( Object name ) {
|
protected Method getWriteMethod( Object name ) {
|
||||||
return (Method) writeMethods.get( name );
|
return (Method) writeMethods.get( name );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reinitializes this bean. Called during {@link #setBean(Object)}.
|
* Reinitializes this bean. Called during {@link #setBean(Object)}.
|
||||||
* Does introspection to find properties.
|
* Does introspection to find properties.
|
||||||
*/
|
*/
|
||||||
protected void reinitialise() {
|
protected void reinitialise() {
|
||||||
readMethods.clear();
|
readMethods.clear();
|
||||||
|
@ -666,13 +679,13 @@ public class BeanMap extends AbstractMap implements Cloneable {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called during a successful {@link #put(Object,Object)} operation.
|
* Called during a successful {@link #put(Object,Object)} operation.
|
||||||
* Default implementation does nothing. Override to be notified of
|
* Default implementation does nothing. Override to be notified of
|
||||||
* property changes in the bean caused by this map.
|
* property changes in the bean caused by this map.
|
||||||
*
|
*
|
||||||
* @param key the name of the property that changed
|
* @param key the name of the property that changed
|
||||||
* @param oldValue the old value for that property
|
* @param oldValue the old value for that property
|
||||||
* @param newValue the new value for that property
|
* @param newValue the new value for that property
|
||||||
*/
|
*/
|
||||||
protected void firePropertyChange( Object key, Object oldValue, Object newValue ) {
|
protected void firePropertyChange( Object key, Object oldValue, Object newValue ) {
|
||||||
}
|
}
|
||||||
|
@ -681,17 +694,17 @@ public class BeanMap extends AbstractMap implements Cloneable {
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Map entry used by {@link BeanMap}.
|
* Map entry used by {@link BeanMap}.
|
||||||
*/
|
*/
|
||||||
protected static class MyMapEntry extends DefaultMapEntry {
|
protected static class MyMapEntry extends DefaultMapEntry {
|
||||||
private BeanMap owner;
|
private BeanMap owner;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new <Code>MyMapEntry</Code>.
|
* Constructs a new <code>MyMapEntry</code>.
|
||||||
*
|
*
|
||||||
* @param owner the BeanMap this entry belongs to
|
* @param owner the BeanMap this entry belongs to
|
||||||
* @param key the key for this entry
|
* @param key the key for this entry
|
||||||
* @param value the value for this entry
|
* @param value the value for this entry
|
||||||
*/
|
*/
|
||||||
protected MyMapEntry( BeanMap owner, Object key, Object value ) {
|
protected MyMapEntry( BeanMap owner, Object key, Object value ) {
|
||||||
super( key, value );
|
super( key, value );
|
||||||
|
@ -699,10 +712,10 @@ public class BeanMap extends AbstractMap implements Cloneable {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the value.
|
* Sets the value.
|
||||||
*
|
*
|
||||||
* @param value the new value for the entry
|
* @param value the new value for the entry
|
||||||
* @return the old value for the entry
|
* @return the old value for the entry
|
||||||
*/
|
*/
|
||||||
public Object setValue(Object value) {
|
public Object setValue(Object value) {
|
||||||
Object key = getKey();
|
Object key = getKey();
|
||||||
|
@ -716,18 +729,18 @@ public class BeanMap extends AbstractMap implements Cloneable {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an array of parameters to pass to the given mutator method.
|
* Creates an array of parameters to pass to the given mutator method.
|
||||||
* If the given object is not the right type to pass to the method
|
* If the given object is not the right type to pass to the method
|
||||||
* directly, it will be converted using {@link #convertType(Class,Object)}.
|
* directly, it will be converted using {@link #convertType(Class,Object)}.
|
||||||
*
|
*
|
||||||
* @param method the mutator method
|
* @param method the mutator method
|
||||||
* @param value the value to pass to the mutator method
|
* @param value the value to pass to the mutator method
|
||||||
* @return an array containing one object that is either the given value
|
* @return an array containing one object that is either the given value
|
||||||
* or a transformed value
|
* or a transformed value
|
||||||
* @throws IllegalAccessException if {@link #convertType(Class,Object)}
|
* @throws IllegalAccessException if {@link #convertType(Class,Object)}
|
||||||
* raises it
|
* raises it
|
||||||
* @throws IllegalArgumentException if any other exception is raised
|
* @throws IllegalArgumentException if any other exception is raised
|
||||||
* by {@link #convertType(Class,Object)}
|
* by {@link #convertType(Class,Object)}
|
||||||
*/
|
*/
|
||||||
protected Object[] createWriteMethodArguments( Method method, Object value ) throws IllegalAccessException, ClassCastException {
|
protected Object[] createWriteMethodArguments( Method method, Object value ) throws IllegalAccessException, ClassCastException {
|
||||||
try {
|
try {
|
||||||
|
@ -766,7 +779,7 @@ public class BeanMap extends AbstractMap implements Cloneable {
|
||||||
* {@link Object#toString() toString()} method, and that string is
|
* {@link Object#toString() toString()} method, and that string is
|
||||||
* parsed into the correct primitve type using, for instance,
|
* parsed into the correct primitve type using, for instance,
|
||||||
* {@link Integer#valueOf(String)} to convert the string into an
|
* {@link Integer#valueOf(String)} to convert the string into an
|
||||||
* <Code>int</Code>.<P>
|
* <code>int</code>.<P>
|
||||||
*
|
*
|
||||||
* If no special constructor exists and the given type is not a
|
* If no special constructor exists and the given type is not a
|
||||||
* primitive type, this method returns the original value.
|
* primitive type, this method returns the original value.
|
||||||
|
@ -775,12 +788,12 @@ public class BeanMap extends AbstractMap implements Cloneable {
|
||||||
* @param value the value to conert
|
* @param value the value to conert
|
||||||
* @return the converted value
|
* @return the converted value
|
||||||
* @throws NumberFormatException if newType is a primitive type, and
|
* @throws NumberFormatException if newType is a primitive type, and
|
||||||
* the string representation of the given value cannot be converted
|
* the string representation of the given value cannot be converted
|
||||||
* to that type
|
* to that type
|
||||||
* @throws InstantiationException if the constructor found with
|
* @throws InstantiationException if the constructor found with
|
||||||
* reflection raises it
|
* reflection raises it
|
||||||
* @throws InvocationTargetExcetpion if the constructor found with
|
* @throws InvocationTargetExcetpion if the constructor found with
|
||||||
* reflection raises it
|
* reflection raises it
|
||||||
* @throws IllegalAccessException never
|
* @throws IllegalAccessException never
|
||||||
* @throws IllegalArgumentException never
|
* @throws IllegalArgumentException never
|
||||||
*/
|
*/
|
||||||
|
@ -805,38 +818,36 @@ public class BeanMap extends AbstractMap implements Cloneable {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a transformer for the given primitive type.
|
* Returns a transformer for the given primitive type.
|
||||||
*
|
*
|
||||||
* @param aType the primitive type whose transformer to return
|
* @param aType the primitive type whose transformer to return
|
||||||
* @return a transformer that will convert strings into that type,
|
* @return a transformer that will convert strings into that type,
|
||||||
* or null if the given type is not a primitive type
|
* or null if the given type is not a primitive type
|
||||||
*/
|
*/
|
||||||
protected Transformer getTypeTransformer( Class aType ) {
|
protected Transformer getTypeTransformer( Class aType ) {
|
||||||
return (Transformer) defaultTransformers.get( aType );
|
return (Transformer) defaultTransformers.get( aType );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logs the given exception to <Code>System.out</Code>. Used to display
|
* Logs the given exception to <code>System.out</code>. Used to display
|
||||||
* warnings while accessing/mutating the bean.
|
* warnings while accessing/mutating the bean.
|
||||||
*
|
*
|
||||||
* @param e the exception to log
|
* @param ex the exception to log
|
||||||
*/
|
*/
|
||||||
protected void logInfo(Exception e) {
|
protected void logInfo(Exception ex) {
|
||||||
// XXXX: should probably use log4j here instead...
|
// Deliberately do not use LOG4J or Commons Logging to avoid dependencies
|
||||||
System.out.println( "INFO: Exception: " + e );
|
System.out.println( "INFO: Exception: " + ex );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logs the given exception to <Code>System.err</Code>. Used to display
|
* Logs the given exception to <code>System.err</code>. Used to display
|
||||||
* errors while accessing/mutating the bean.
|
* errors while accessing/mutating the bean.
|
||||||
*
|
*
|
||||||
* @param e the exception to log
|
* @param ex the exception to log
|
||||||
*/
|
*/
|
||||||
protected void logWarn(Exception e) {
|
protected void logWarn(Exception ex) {
|
||||||
// XXXX: should probably use log4j here instead...
|
// Deliberately do not use LOG4J or Commons Logging to avoid dependencies
|
||||||
System.out.println( "WARN: Exception: " + e );
|
System.out.println( "WARN: Exception: " + ex );
|
||||||
e.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue