Here's how I did it:
In your generated code for the doc type, you will find an addXXX
method which is used to add records to the vector. Immediately
before adding, call vector.clear() and you will only store one
object at a time.
Now the doc 'type' object is subclassed by the doc 'name' object,
so you must override the addXXX method like this:
super.addXXX(rec);
// call the registered record handler
_recordHandler.handle(rec);
You will need to create an interface that will handle the record
and in the generated code, just add a method like:
setRecordHandler(RecordHandler h) {
_recordHandler = h;
}
so that you control where the record goes.
Now for some reason, you may need to make the _recordHandler
instance variable static instead, because you will get a lot of
NullPointerExceptions when Castor re-builds your doc name object.
Nathan
--standard disclaimer--
The statements expressed herein are my own and are not necessarily
those held by my employer.
-----Original Message-----
From: Bhaskar_V [mailto:[EMAIL PROTECTED]]
Sent: Thursday, September 27, 2001 2:16 AM
To: [EMAIL PROTECTED]
Subject: [castor-dev] Doubt in Unmarshalling
hi,
How can unmarshall only one record at a time. (i.e) i don't want my sequence
objects in my xml file to be loaded into an enumeration or array or vector
immediately during parsing. I want to unmarshall only one object at a time
(something similar to startElement in SAX parser). I have around 1000
records in my xml file- each of min 100KB size - and so getting it as
enumeration or vector, i forsee a memory problem. Is there any work around
for this in castor?
Regards,
V.Bhaskar
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev