commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bill Keese <bi...@tech.beacon-it.co.jp>
Subject Re: [Digester] Create an object using parent attribute
Date Fri, 25 Jun 2004 00:55:49 GMT

>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
>  }
>}
>  
>
Looks good to me. I think that's what the original poster wanted. He
just needs to add in the parts using reflection to instantiate the child
object and set the attributes on it. Although, I guess the reflection
code is a bit tricky, especially if there are type conversions, such as
converting a string value of an attribute into a number. (Basically,
it's re-implementing whatever digester.addSetProperties() does.)

---------------------------------------------------------------------
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