Hello, guys. I have ecountered a problem about xStream that forced me to ask 
some guidence.

Imagine the following class, representing the Vagon:

        class Vagon {
                int id;
                Vagon nextVagon;
        }

it has only two fields: an id and reference to next class instance.
So, imagine we have list of this objects representing train:

                Vagon vagon5 = new Vagon( 5, null );
                Vagon vagon4 = new Vagon( 4, vagon5 );
                Vagon vagon3 = new Vagon( 3, vagon4 );
                Vagon vagon2 = new Vagon( 2, vagon3 );
                Vagon vagon1 = new Vagon( 1, vagon2 );
                Vagon vagon0 = new Vagon( 0, vagon1 );

where the vagon0 - is the last, next to him vagon1 and so on.
So, when i serialise List of this vagons using xstream i got smth like this:

<list>
  <TrainTest_-Vagon>
    <id>0</id>
    <nextVagon>
      <id>1</id>
      <nextVagon>
        <id>2</id>
        <nextVagon>
          <id>3</id>
          <nextVagon>
            <id>4</id>
            <nextVagon>
              <id>5</id>
            </nextVagon>
          </nextVagon>
        </nextVagon>
      </nextVagon>
    </nextVagon>
  </TrainTest_-Vagon>
  <TrainTest_-Vagon reference="../TrainTest_-Vagon/nextVagon"/>
  <TrainTest_-Vagon reference="../TrainTest_-Vagon/nextVagon/nextVagon"/>
  <TrainTest_-Vagon 
reference="../TrainTest_-Vagon/nextVagon/nextVagon/nextVagon"/>
  <TrainTest_-Vagon 
reference="../TrainTest_-Vagon/nextVagon/nextVagon/nextVagon/nextVagon"/>
  <TrainTest_-Vagon 
reference="../TrainTest_-Vagon/nextVagon/nextVagon/nextVagon/nextVagon/nextVagon"/>
</list>

So IN fact - I have first big vagon0 that includes within itself  all other 
vagons, and the other list members - are refereces.

The problems are
1) if list size is very big xStream can't serialize it due to stack limiting - 
i'm just getting StackOverflow Error.
2) Output is very hard to read: i would like having smthing like that:

<list>
  <TrainTest_-Vagon>
    <id>0</id>
    <nextVagon reference="..ref to vagon1..">
  </TrainTest_-Vagon>
  <TrainTest_-Vagon>
    <id>1</id>
    <nextVagon reference="..ref to vagon2..">
  </TrainTest_-Vagon>
  <TrainTest_-Vagon>
    <id>2</id>
    <nextVagon reference="..ref to vagon3..">
  </TrainTest_-Vagon>
  <TrainTest_-Vagon>
    <id>3</id>
    <nextVagon reference="..ref to vagon4..">
  </TrainTest_-Vagon>
  <TrainTest_-Vagon>
    <id>4</id>
    <nextVagon reference="..ref to vagon5..">
  </TrainTest_-Vagon>
  <TrainTest_-Vagon>
    <id>5</id>
    <nextVagon reference="..null..">
  </TrainTest_-Vagon>
</list>

So, from tech point of view, I think that we are speaking of lazy marshalling - 
first marsal vagons leaving the "nextVagon" blank - and then when we will have 
all train in memory insert the refereces.
Is there any way to do this in xStream or i will have to write my own Converter 
to TrainList?

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to