[prev in list] [next in list] [prev in thread] [next in thread] 

List:       jibx-users
Subject:    Re: [jibx-users] Reading JiBX collections
From:       Dennis Sosnoski <dms () sosnoski ! com>
Date:       2004-07-05 22:57:07
Message-ID: 40E9DCC3.1080000 () sosnoski ! com
[Download RAW message or body]

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
jibx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jibx-users
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic