commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From uma...@comcast.net
Subject [Betwixt]: How do I solve this?
Date Mon, 18 Feb 2008 01:05:25 GMT

Env: Betwixt 0.8, JDK1.6

I have a bean defined as follows:

    class Car {
         private IEngine engine;
         public IEngine getEngine() { ..}
         public void setEngine(final IEngine e) { ... }
    }

    interface IEngine { ... }

    public class DieselEngine implements IEngine { ... }
    public class GasolineEngine implements IEngine { ... }


I need entity Car with diesel engine to be emitted as:
     <car>
         <dieselEngine> ... </dieselEngine>
     </car>

and a car with asoline engine to be XML-ized as 
       <car>
         <gasolineEngine> ... </gasolineEngine>
     </car>


My betwixt files are as follows:
    <!-- car.betwixt -->
    <?xml version="1.0" encoding="UTF-8" ?>
    <info primitiveTypes="attribute">
      <element name="car">    
            <addDefaults />
       </element>
     </info>

    <!-- dieselEngine.betwixt -->
     <?xml version="1.0" encoding="UTF-8" ?>
    <info primitiveTypes="attribute">
      <element name="dieselEngine">    
            <addDefaults />
       </element>
     </info>

      <!-- gasolineEngine.betwixt -->
     <?xml version="1.0" encoding="UTF-8" ?>
    <info primitiveTypes="attribute">
      <element name="gasolineEngine">    
            <addDefaults />
       </element>
     </info>

However, since Car entity does not identify the concrete instance of IEngine,
the XML is not correctly generated?

How can I trigger the right betwixt file depending on the actual type of IEngine in a 
car entity?

Pl help!  Thanx....

/U


             

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message