To get an iterator you'd want to replace the top-level JiBX handling with your own code, which would basically initialize the unmarshaller and parse to the point where you're about to start in on the collection elements. Then whenever next() is called on the iterator, unmarshal the next item from the collection at that point and return it (which you can do by using the unmarshaller unmarshalElement method).

You can look at the org.jibx.extras.ObjectArrayMapper handling (since you're basically dealing with an array of items, you just want them one at a time), as well as "Controlling JiBX with front-end code" in the tutorial (http://jibx.sourceforge.net/tutorial/binding-custom.html#frontend).

If you need to embed this handling into your unmarshalling of the object containing the collection, and just want to process the items one at a time and then discard them, a simpler approach is to just use a set-method on the containing object. This will give you the items one at a time, and if you want to just process them directly rather than adding them to an actual collection JiBX will never know the difference. :-)

 - Dennis

HD wrote:

I was wondering if it is possible to read collections in a streaming way instead of loading everything in memory (through ArrayList) ?
Ideally, an Iterator interface would be nice but I could write my own code if I can have some hints.


Henri.




-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 - digital self defense, top technical experts, no vendor pitches, unmatched networking opportunities. Visit www.blackhat.com
_______________________________________________
jibx-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to