Make getReadMethod and getWriteMethod public
Solves bug 15897 git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/collections/trunk@130964 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a164d04789
commit
5069664f18
|
@ -1,13 +1,10 @@
|
||||||
/*
|
/*
|
||||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/BeanMap.java,v 1.14 2002/10/12 22:15:19 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.15 2003/01/25 12:06:55 scolebourne Exp $
|
||||||
* $Revision: 1.14 $
|
|
||||||
* $Date: 2002/10/12 22:15:19 $
|
|
||||||
*
|
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*
|
*
|
||||||
* The Apache Software License, Version 1.1
|
* The Apache Software License, Version 1.1
|
||||||
*
|
*
|
||||||
* Copyright (c) 1999-2002 The Apache Software Foundation. All rights
|
* Copyright (c) 1999-2003 The Apache Software Foundation. All rights
|
||||||
* reserved.
|
* reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -23,11 +20,11 @@
|
||||||
* distribution.
|
* distribution.
|
||||||
*
|
*
|
||||||
* 3. The end-user documentation included with the redistribution, if
|
* 3. The end-user documentation included with the redistribution, if
|
||||||
* any, must include the following acknowlegement:
|
* any, must include the following acknowledgment:
|
||||||
* "This product includes software developed by the
|
* "This product includes software developed by the
|
||||||
* Apache Software Foundation (http://www.apache.org/)."
|
* Apache Software Foundation (http://www.apache.org/)."
|
||||||
* Alternately, this acknowlegement may appear in the software itself,
|
* Alternately, this acknowledgment may appear in the software itself,
|
||||||
* if and wherever such third-party acknowlegements normally appear.
|
* if and wherever such third-party acknowledgments normally appear.
|
||||||
*
|
*
|
||||||
* 4. The names "The Jakarta Project", "Commons", and "Apache Software
|
* 4. The names "The Jakarta Project", "Commons", and "Apache Software
|
||||||
* Foundation" must not be used to endorse or promote products derived
|
* Foundation" must not be used to endorse or promote products derived
|
||||||
|
@ -36,7 +33,7 @@
|
||||||
*
|
*
|
||||||
* 5. Products derived from this software may not be called "Apache"
|
* 5. Products derived from this software may not be called "Apache"
|
||||||
* nor may "Apache" appear in their names without prior written
|
* nor may "Apache" appear in their names without prior written
|
||||||
* permission of the Apache Group.
|
* permission of the Apache Software Foundation.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
|
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
|
||||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
@ -77,16 +74,19 @@ import java.util.Iterator;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
|
||||||
/** An implementation of Map for JavaBeans which uses introspection to
|
/**
|
||||||
* get and put properties in the bean.
|
* 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
|
* <p>
|
||||||
* property is considered non existent in the Map
|
* 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 <a href="mailto:jstrachan@apache.org">James Strachan</a>
|
* @since Commons Collections 1.0
|
||||||
*/
|
* @version $Revision: 1.15 $ $Date: 2003/01/25 12:06:55 $
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
|
||||||
|
* @author Stephen Colebourne
|
||||||
|
*/
|
||||||
public class BeanMap extends AbstractMap implements Cloneable {
|
public class BeanMap extends AbstractMap implements Cloneable {
|
||||||
|
|
||||||
private transient Object bean;
|
private transient Object bean;
|
||||||
|
@ -573,6 +573,26 @@ public class BeanMap extends AbstractMap implements Cloneable {
|
||||||
reinitialise();
|
reinitialise();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the accessor for the property with the given name.
|
||||||
|
*
|
||||||
|
* @param name the name of the property
|
||||||
|
* @return the accessor method for the property, or null
|
||||||
|
*/
|
||||||
|
public Method getReadMethod(String name) {
|
||||||
|
return (Method) readMethods.get(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the mutator for the property with the given name.
|
||||||
|
*
|
||||||
|
* @param name the name of the property
|
||||||
|
* @return the mutator method for the property, or null
|
||||||
|
*/
|
||||||
|
public Method getWriteMethod(String name) {
|
||||||
|
return (Method) writeMethods.get(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Implementation methods
|
// Implementation methods
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/TestBeanMap.java,v 1.8 2003/01/07 23:44:19 rwaldhoff Exp $
|
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/TestBeanMap.java,v 1.9 2003/01/25 12:06:55 scolebourne Exp $
|
||||||
* $Revision: 1.8 $
|
* $Revision: 1.9 $
|
||||||
* $Date: 2003/01/07 23:44:19 $
|
* $Date: 2003/01/25 12:06:55 $
|
||||||
*
|
*
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*
|
*
|
||||||
|
@ -61,6 +61,7 @@
|
||||||
package org.apache.commons.collections;
|
package org.apache.commons.collections;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import junit.framework.Test;
|
import junit.framework.Test;
|
||||||
|
@ -344,4 +345,16 @@ public class TestBeanMap extends TestMap {
|
||||||
assertEquals(map1.get("someIntValue"), new Integer(0));
|
assertEquals(map1.get("someIntValue"), new Integer(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testMethodAccessor() throws Exception {
|
||||||
|
BeanMap map = (BeanMap) makeFullMap();
|
||||||
|
Method method = BeanWithProperties.class.getDeclaredMethod("getSomeIntegerValue", null);
|
||||||
|
assertEquals(method, map.getReadMethod("someIntegerValue"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testMethodMutator() throws Exception {
|
||||||
|
BeanMap map = (BeanMap) makeFullMap();
|
||||||
|
Method method = BeanWithProperties.class.getDeclaredMethod("setSomeIntegerValue", new Class[] {Integer.class});
|
||||||
|
assertEquals(method, map.getWriteMethod("someIntegerValue"));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue