commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "RODRIGUEZ Eric" <>
Subject Betwixt and collections
Date Mon, 20 Mar 2006 09:04:11 GMT
Hi all,

I'm sorry if this may seem to you a classic (dummy) question but I get some difficulties to
get working betwixt with collections.
Basically, my problem is with List  I got a userlist with "boys" and "girls" list, and I want
to be populated in the right way.
I get lost in the documentation to find a example on how to handle correctly the "addDefaults"
or "updater" settings.
What should I use to ensure that boys entries are added to boys List (and girls to girls List).

Sorry if this may seem too simple but I tried several betwixt-config files and .betwixt but
I can't get this working properly.

Thanks for any help or comments or links.

Eric Rodriguez

Here are my test classes:
Betwixt Write:
        UserList userList = Factory.getData();
        FileWriter outputWriter = new FileWriter(new File("users.xml"));
        outputWriter.write("<?xml version='1.0' ?>");

        BeanWriter beanWriter = new BeanWriter(outputWriter);

        beanWriter.write("users", userList);


Betwixt XML out:
<?xml version='1.0' ?>  <users>
        <name>Boy 1</name>
        <name>Boy 2</name>
        <name>Girl 1</name>
        <name>Girl 2</name>
    <userListName>User List</userListName>

Betwixt Read:
        FileReader xmlReader = new FileReader(new File("users.xml"));
        BeanReader beanReader = new BeanReader();

        beanReader.registerBeanClass("users", UserList.class);
        UserList userList = (UserList) beanReader.parse(xmlReader);

public class UserList {

    private String userListName;

    private ArrayList girls;

    private ArrayList boys;

    public UserList() {
        this.girls = new ArrayList();
        this.boys = new ArrayList();

    public ArrayList getBoys() {
        return boys;

    public void setBoys(ArrayList boys) {
        this.boys = boys;

    public ArrayList getGirls() {
        return girls;

    public void setGirls(ArrayList girls) {
        this.girls = girls;

    public String getUserArrayListName() {
        return userListName;

    public void setUserArrayListName(String userListName) {
        this.userListName = userListName;
    public void addBoy(User user) {
    public void addGirl(User user) {


public class User {

    private String name;

    public User() {

    public User(String userName) { = userName;
    public String getName() {
        return name;

    public void setName(String name) { = name;


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message