commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Simon Kitching <si...@ecnetwork.co.nz>
Subject Re: [Digester] Create an object using parent attribute
Date Fri, 25 Jun 2004 00:28:41 GMT
On Fri, 2004-06-25 at 12:19, Bill Keese wrote:
> >><parent childClass="mypackage.childClass">
> >>   <child attribute1="value1" attribute2="value2"/>
> >>   <child attribute1="value3" attribute2="value4"/>
> >></parent>
> >>
> >>        digester.addObjectCreate("parent", "mypackage.parentClass");
> >>        digester.addSetProperties("parent");
> >>
> >>    
> >>
> Did I misunderstand the meaning of the original post? I thought the
> above example should create a mypackage.parentClass object which
> contains 2 mypackage.childClass objects. Right?

No, sorry, my mistake not yours. I completely misread the original post.
Thanks for pointing that out! [and please ignore my previos post].

How about this??

public class ChildCreationFactory implements ObjectCreationFactory {
  public Object createObject(Attributes x) {
    ParentClass parent = (ParentClass) digester.peek();
    String childClassName = parent.getChildClassName();

    // create instance of child class and return it
  }
}

digester.addObjectCreate("parent", ParentClass.class);
digester.addSetProperties("parent");
digester.addFactoryCreate("parent/child", new ChildCreationFactory());
digester.addSetNext("parent/child");


That looks much better...[I hope]

Regards,

Simon


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message