|
if you knew that the Unmarshaller.unmarshal
would unmarshall to a particular base class (or
interface) you could : com.enron.shred.everything.CastorBaseClass
Obj obj = (com.enron.shred.everything.CastorBaseClass)
Unmarshaller.unmarshal(Class.forName(className), reader); this would either work or throw a ClassCastException Conor -----Original Message----- Thanks for the reply Conor I know I can get type Object
via Unmarshal via: Object unmarshalled =
Unmarshaller.unmarshal But I suppose the question is then
how do I then cast it to the proper type so I can access the get() methods? In my example,
com.enron.shred.everything.BrandNewCastorObj
represents a future yet-to-be-seen, brand new instance of a
Castor-generated XML schema. I wanted to know if I can re-cast Object unmarshalled somehow to
type com.enron.shred.everything.BrandNewCastorObj Or is that asking for too much from
the Java lang? -----Original Message----- Steven I've
done something similar with the static StringReader
reader = new StringReader(xmlString); Object
unmarshalled = Unmarshaller.unmarshal(Class.forName(className), reader); and StringWriter
writer = new StringWriter(); Marshaller.marshal(object
,writer); You do
not need a common base class to do this though. Conor -----Original Message----- I have a similar question then: Is it possible to create a base
class with for abstract Unmarshal and Marshal methods (castor xml) such that I
wouldn't have to explicitly cast during class loading? I would like my code to be able to
accommodate unknown, future XML schemas that become Castor-ized (as opposed to
Pasteruized) into Java objects like this: BaseClass bc = (BaseClass)
Class.forName ( newCastorizedSchemaObject ); Without having to explicitly know
the type name that could happen in the future, instead of BrandNewCastorObj co = (BrandNewCastorObj)
Class.forName ( "com.enron.shred.everything.BrandNewCastorObj" ) I am new to Castor so I suppose this
could be stupid question, but is it possible to create generic Unmarshal code? -
steve -----O riginal Message----- Hi, (Sorry if this question has been posted before but
I've found it in the documentation neither the mailing list). + Is it possible to define a JDO's mapping for an
abstract class. I would expect to get back a collection of ImplClass1
and ImplClass2 's instances together. Thanks a lot, Isi, -- This e-mail is confidential and is intended for the
named recipient only. If This e-mail is confidential and is intended for the named recipient only. If |
Title: JDO: Abstract class and inheritance
- [castor-dev] JDO: Abstract class and ... "Legido Mart�nez, Isidoro"
- Re: [castor-dev] JDO: Abstract c... Conor Allen
- Re: [castor-dev] JDO: Abstract c... Mielnicki, Steven J
- Re: [castor-dev] JDO: Abstract c... Conor Allen
- Re: [castor-dev] JDO: Abstract c... "Legido Mart�nez, Isidoro"
- Re: [castor-dev] JDO: Abstract c... Mielnicki, Steven J
- Conor Allen
