commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sacha Fournier <sacha.fourn...@isi-corp.biz>
Subject [betwixt] Array of extended class
Date Thu, 17 Nov 2005 15:08:06 GMT
Hi,

I have something like this:

MainClass.java
class MainClass
{
   private MyObject aObject[];

  public MyObject[] getMyObject()
 {
    return this.aObject;
 }
}

MyObjectA.java
class MyObjectA extends MyObject
{
    // Some specific attribute getter...
}

MyObjectB.java
class MyObjectB extends MyObject
{
    // Some other specific attribute getter...
}

Main.java
void Main()
{
  MainClass oMain = new MainClass();
  MainClass.addToMyObject(new MyObjectA());
  MainClass.addToMyObject(new MyObjectB());

  StringWriter outputWriter = new StringWriter();
  outputWriter.write("<?xml version='1.0' ?>");
  BeanWriter beanWriter = new BeanWriter(outputWriter);       
  beanWriter.write(oMain.getClass().getName(), oMain);
}

=============================================
My xml output is
<MainClass>
  <MyObject>{all MyObjectA attributes}</MyObject>
  <MyObject>{all MyObjectB attributes}</MyObject>
</MainClass>

But I was expecting something like that:
<MainClass>
  <MyObjectA>{all MyObjectA attributes}</MyObjectA>
  <MyObjectB>{all MyObjectB attributes}</MyObjectB>
</MainClass>


Any ideas ?

-- 
Sacha Fournier
sacha.fournier@isi-corp.biz
514-258-4096


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