[Simple-support] Strategy implementation
Brought to you by:
niallg
|
From: Yaniv K. <Ku...@Te...> - 2008-03-10 16:43:44
|
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
|