Jason- In the past I've just left the type blank, but apparently that doesn't work now. I'd try type="java.lang.Object" and see what happens.
Stephen On 3/16/06, Jason Wood <[EMAIL PROTECTED]> wrote: > So what do I set the type attribute equal to? I just tried without > setting the type and castor through a NPE. It seems the type attribute > must be set to something, but in my case as explained below the > collection can hold different class types. I am using Castor 9.7 if that > makes a difference > > Thanks :) > J > > -----Original Message----- > From: Stephen Bash [mailto:[EMAIL PROTECTED] > Sent: Wednesday, March 15, 2006 8:13 PM > To: [email protected] > Subject: Re: [castor-user] Collections > > Jason- > > In general Castor will determine the class of an object automatically > and map it based on the mapping for the given class. If Castor > doesn't think there is enough information in the mapping file to > instantiate the correct object during unmarshalling, it will add an > xsi:type attribute to the xml element to help out the Unmarshaller > (i.e. xsi:type="java:java.lang.String" or xsi:type="java:foo.Bar"). > > So in general I would say just try it. If you run into some problems, > feel free to ask further questions. > > HTH, > Stephen > > > On 3/15/06, Jason Wood <[EMAIL PROTECTED]> wrote: > > > > > > > > How do I define within a mapping file the different types of object a > > collection member can hold? > > > > > > > > So I have.... > > > > > > > > Class myClass { > > > > private ArrayList mylist = new ArrayList(); > > > > public void add(Object obj) { > > > > myList.add(obj); > > > > } > > > > } > > > > > > > > myClass my = new myClass(); > > > > my.add(new String("Hello")); > > > > my.add(new Integer(1)); > > > > my.add(new SomeOfObject()); > > > > > > > > > > > > How do I tell Castor to us the correct mapping class for each? > > > > > > > > J > > ------------------------------------------------- > If you wish to unsubscribe from this list, please > send an empty message to the following address: > > [EMAIL PROTECTED] > ------------------------------------------------- > >

