commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From uma...@comcast.net
Subject [Betwixt]: Writing polymorphic beans
Date Thu, 03 Jan 2008 08:09:42 GMT
Env: JDK1.6, Betwixt 0.8

I have a bean A which contains a polymorphic reference to a bean B or C via
an interface as follows:

    class A {
         private IVehicle vehicle;
         public IVehicle getVehicle() { ... }
         public void setVehicle(final IVehicle v) { ... }
    }

    class Car implements IVehicle { ... }
    class Bus implements IVehicle { ... }


I need to write an instance of A out as follows:

        <A>
             <car>
                  <model>...</model>
             </car>
         </A>

or as 

      <A>
             <bus>
                  <model>...</model>
             </bus>
         </A>
 
If I use a betwixt file as follows:

      <info primitiveTypes="attribute">
            <element name="A">
                <addDefaults/>
           </element>
      </info>

I get <A><model>...</model></A>

which is clearly wrong. How can I use the PolymorphicReferenceResolver  to identify
if <car> or <bus> must be emitted?

Can you point me to a sample?

Thanks,

/U

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


Mime
View raw message