David-
In order to save Keith some time, let me jump in. Keith's point about
the addBook() method is that you don't have to store the contents
<book> element. You can simply put whatever processing you want done
to each <book> element within the addBook() method. Using your
example, you could internally maintain a List of books, and when that
list reached 1000 objects, perform whatever processing you wish to
perform (assuming it happens on the same thread, Castor will wait),
and then empty the list and start over again.
Does that make more sense? Let me know if you have more questions.
Stephen
On 2/21/06, David <[EMAIL PROTECTED]> wrote:
> Keith,
>
> Thanks for your interest on my problem. The solution about the class
> Bookstore it is what I have implemented first, but if the file is very big
> after parsing and unmarshalling hte file, you will get a big array and this
> is what I don't want.
>
> I would like to unmarshal book by book or a list of books with size smaller
> than the original file, for example if my file has 1 000 000 of books
> unmarshal by package of 1000 books for example each time.
>
> Thanks in advance,
>
> David Leal
>
> Keith Visco <[EMAIL PROTECTED]> wrote:
> David,
>
> Another solution would be to create a Bookstore class with an addBook
> method...such as:
>
> public class Bookstore {
>
> public void addBook(Book book) {
> // add book to database
> }
>
> public Book[] getBooks() {
> // return array of Book instances
> }
>
> }
>
>
> You can write a very simple mapping file:
>
>
>
> get-method="getBooks" set-method="addBook"/>
>
>
>
>
> ...
>
>
>
> Each time Castor encounters the element it will call the addBook
> method. You can then do whatever you want with the book and discard it.
>
> If you're only going to use this for unmarshalling you don't need the
> getBooks method.
>
> --Keith
>
> David wrote:
> > Dear Members,
> >
> > I have a typical file like this:
> >
> >
> >
> >
> > ...
> >
> >
> >
> > if the file is big enough I can't load the whole book store at once, my
> > idea is to take one by one each information (or a fixed numbers
> > of book elements for avoiding overflow), then for example store into
> > database and then to take the next one, so I want to parse book event,
> > process it and then to go to the next one. ¿How can we do it with castor?
> >
> > If I bind the hole bookstore element into BookStore class with million
> > of books I get Overflow for sure.
> >
> > It should be a solution where the unmarshall process get each time a
> > book then you process it (for example stores into database) and go to
> > the next book without creation a new object for example each time or
> > doing by a package of certain number of books each time.
> >
> > Thanks in advance,
> >
> > David Leal
> > [EMAIL PROTECTED]
> >
> >
> ------------------------------------------------------------------------
> > Relax. Yahoo! Mail virus scanning
> >
> > helps detect nasty viruses!
>
>
> -------------------------------------------------
> If you wish to unsubscribe from this list, please
> send an empty message to the following address:
>
> [EMAIL PROTECTED]
> -------------------------------------------------
>
>
>
>
> ________________________________
>
> What are the most popular cars? Find out at Yahoo! Autos
>
>