yeah Rob,
consider the following document ( for collection's problem ):
<one>
<two>Two</two> // assume 'Two' to be a
String data
<three>
<four>Four</four> // assume 'Four' as another String data
<flag>true</flag> // 'true' as a boolean value
<vect>5</vect> // here 'vect' is an instance of "Vector"
<vect>true</vect> // having an 'Integer','Boolean' & 'X'
<vect>X</vect> // where 'X' is an object reference of an
. // abstract class defined by me locally
. // here i need to decide after encountering
. // values of different types ( in this case
. // an Integer, Boolean & an Abstract
</three> // type,...etc ) for the same tag element ,
</one> // that its a collection of different objects
To sum up theres a class called 'one' which has two & three as its attribute. while two is of simple type, assume 'three' is of a type called Three ( an user-defined class )and three has its own attributes ,,.... etc
class one
{
String two;
Three three;
// assume there are respective setters & getters for them..
}
class Three
{
String four;
boolean flag;
Vector vect;
// assume this class has its own setters & getters
}
the actual problem , i would face in here is that in the 'vect' , i might not know , what exactly is the type of object contained as value... for instance i cant differentiate between an 'int' and 'Date' for both of them are represented as integer values ( date : in terms of milliseconds ). so i might not be able to construct objects accordingly , you see.
but , i think anyway, we would be avoiding this situation and make use of arrays of objects instead... so , we are ignoring it for a while..
and theres another problem, i am facing, while constructing an array of complex types here. consider the following situation :
<x> // level 0
<y>10</y> // level 1
<z> // level 1
<A> // level 2
<a>23</a> // level 3
<a>45</a> // level 3
</A>
<A> // level 2
<a>100</a> // level 3
<a>200</a> // level 3
</A>
</z>
</x>
here, i am trying to construct an ultimate object of type 'x'. which contains an object of simple type 'y' and an object of complex type 'z'. class 'z' contains an array object of type 'A' : array size is 2. and class 'A' has a simple array of type 'a', from the above scenario.
the sequence is this. i m trying to create the objects based on the level . now you could see that both 'A' is at level 2 ( as they are arrays ) and all the 'a' are at level 3. now when i create the first array element of type 'A', its getting created with an array of type 'a' , WHICH IS OF SIZE 4, just because they are at the same level ( 3 ) and their parents happens to be the same level as well... so its giving a problem , when the second ( array ) object of type 'A' is to be created... i dont know how this could be rectified.. hope i have explained myself clearly... see if can throw some light on this.. Rob.
thanx & cheers
shiva