You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Erik Price <ep...@ptc.com> on 2003/03/11 17:28:14 UTC

[digester] addSetNext call placement

Does it matter where you place the call to the "addSetNext" method of a 
Digester instance, as long as it's before the "parse" method call?

i.e.:

Digester dig = new Digester();
dig.push(this);
dig....
dig....
dig....
dig.addSetNext("some/pattern", "addFoo");
dig.parse(file);


is the same as:

Digester dig = new Digester();
dig.push(this);
dig.adSetNext("some/pattern", "addFoo");
dig....
dig....
dig....
dig.parse(file);


?


Thanks,

Erik


Re: [digester] addSetNext call placement

Posted by Erik Price <ep...@ptc.com>.

Craig R. McClanahan wrote:

> Ordering only matters among rules with the same pattern String -- they are
> executed in the order they were registered.  So, if you're creating the
> foo object before using the set next rule, you will want to register the
> object create rule first.
> 
> For example, my rulesets are full of things like:
> 
>   digester.addObjectCreate("some/pattern", "com.mycompany.MyFoo");
>   digester.addSetProperties("some/pattern");
>   digester.addSetNext("some/pattern", "addFoo");

Great, thanks Craig.  The above example is exactly what I had in mind 
(create an object and establish parent/child relationship immediately 
[at the same node in the XML file] before continuing to call methods on 
the new object at later nodes).



Erik




Re: [digester] addSetNext call placement

Posted by "Craig R. McClanahan" <cr...@apache.org>.
On Tue, 11 Mar 2003, Erik Price wrote:

> Date: Tue, 11 Mar 2003 11:28:14 -0500
> From: Erik Price <ep...@ptc.com>
> Reply-To: Jakarta Commons Users List <co...@jakarta.apache.org>
> To: Jakarta Commons Users List <co...@jakarta.apache.org>
> Subject: [digester] addSetNext call placement
>
> Does it matter where you place the call to the "addSetNext" method of a
> Digester instance, as long as it's before the "parse" method call?
>
> i.e.:
>
> Digester dig = new Digester();
> dig.push(this);
> dig....
> dig....
> dig....
> dig.addSetNext("some/pattern", "addFoo");
> dig.parse(file);
>
>
> is the same as:
>
> Digester dig = new Digester();
> dig.push(this);
> dig.adSetNext("some/pattern", "addFoo");
> dig....
> dig....
> dig....
> dig.parse(file);
>

Ordering only matters among rules with the same pattern String -- they are
executed in the order they were registered.  So, if you're creating the
foo object before using the set next rule, you will want to register the
object create rule first.

For example, my rulesets are full of things like:

  digester.addObjectCreate("some/pattern", "com.mycompany.MyFoo");
  digester.addSetProperties("some/pattern");
  digester.addSetNext("some/pattern", "addFoo");

The rules for different patterns can be added in any order.

>
> ?
>
>
> Thanks,
>
> Erik

Craig