commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jerome Jacobsen" <jerome.jacob...@gentootech.com>
Subject BeanUtils.populate() throws IllegalArgumentException for indexed String properties.
Date Tue, 28 May 2002 21:09:12 GMT
Maybe I'm misunderstanding BeanUtils.populate, but shouldn't this work????!

public class Company {
    private List m_locations = new ArrayList();

    public String[] getLocation() {
        return (String[])m_locations.toArray(new String[0]);
    }

    public String getLocation(
        int index) {

        return (String)m_locations.get(index);
    }

    public void setLocation(
        String[] locations) {

        if (locations == null) {
            locations = new String[0];
        }

        m_locations = Arrays.asList(locations);
    }

    public void setLocation(
        int index,
        String location) {

        m_locations.set(index, location);
    }

    public static void main(String[] args) throws Exception {
        Company gentoo = new Company();

        Map properties = new HashMap();
        properties.put("location", new String[] {"Blacksburg", "Richmond"});

        BeanUtils.populate(gentoo, properties);  // throws
IllegalArgumentException!
    }
}


--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message