commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Chris Cheshire" <cheshira...@gmail.com>
Subject [digester] FactoryCreateRule help
Date Wed, 13 Sep 2006 01:01:07 GMT
I have to process an XML file that contains (in part) the following structure
<variables>
  <Variable>
    <ID>...</ID>
    <Name>...</Name>
    <Instance>...</Instance>
    <Value>...</Value>
  </Variable>
</variables>

I have a predefined list of variables based upon their ID, an abstract
Variable class, and then concrete subclasses of these for each valid
ID.

Variable contains a static method Variable getInstance(int ID) that
creates a new variable subclass based upon the ID (the id-subclass
mapping is based upon a properties file).

The FactoryCreateRule allows for creation of classes based via a
factory providing the identifiying parameter is an XML attribute. In
this case it is not. It is a sub-element, I have no control over that.

How can I use the FactoryCreateRule to call getInstance(int ID) in my
Variable class when I need to extract the ID from a nested element not
an attribute?

Thanks

Chris

PS I did explore other options for the Variable class where there is
just one class, but there is a need for polymorphism with regards to
the variables that have led me to implement it this way, so changing
Variable is also not an option.

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