Re: [Simple-support] Strategy implementation
Brought to you by:
niallg
|
From: Niall G. <gal...@ya...> - 2008-03-10 21:34:47
|
Hi Yaniv, This is exactly what the Strategy is intended to do. As well as implementing your own, you can use a filter/decorator pattern. Where you implement a strategy that transforms the result of the Defaultstrategy. Here you could simply modify the NodeMap before invoking the DefaultStragegy.setRoot and DefaultStrategy.setElement and modify it back to the expected form before invoking DefaultStrategy.getRoot and Defaultstrategy.getRoot. Either that or you could just create your own strategy based on the DefaultStratgy and modify it to do what you need. I am intending on making it easier to do this type of thing in furture releases. Niall --- Yaniv Kunda <Ku...@Te...> wrote: > I wanted to implement a strategy that, similarly to > the DefaultStrategy > class, determines the class of the parsed element > from the optional > "class" attribute. > The difference is that I want to derive the class > off a different > attribute, using some arbitrary logic. > For example, instead of the following XML: > <tasks> > <task class="com.tasks.FirstTask"> > <init>true</init> > </task> > <task class="com.tasks.SecondTask"> > <start>true</start> > </task> > </tasks> > > I would like to have this XML: > <tasks> > <task type=1> > <init>true</init> > </task> > <task type=2> > <start>true</start> > </task> > </tasks> > Plus some code responsible for the logic. > > If the getClass(String) method in DefaultStrategy > was protected and not > private, this could be done via a simple extended > class containing a > single method override. > > Does this sounds like a good idea, or is there a > simpler way to do it? > > Regards, > Yaniv Kunda > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio > 2008. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > Simple-support mailing list > Sim...@li... > https://lists.sourceforge.net/lists/listinfo/simple-support > ____________________________________________________________________________________ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ |