I have to be able to store data in a new object, that I am getting from a complex object where each item is held in a List.
The hierarchy is the following:
bookId
pageId
wordId
bookIdis unique and can have zero to manypageId'spageIdcan have zero to manywordId's
I have the data, but I need to cycle through each item and put into an object – ArrayList or similar – so I can pass off to another class, which is expecting a List. In the next class, the data is to be presented in a jsp table.
Can someone please help the best way to do this. Do I need ArrayList or ArrayLists, or is there a simple way to do it?
Simple way of organizing this structure is following:
Each your entity is an object. For example Create simple book you can with next code:
Note that you need provide appropriate constructors and setters/getters to operate with that code.
For presenting this data on jsp, you can use bean object Book, and with jstl you can get access to any field from book (includes each page and each word in a page) that you need.
Actually, there are lot of more complex structures but its usage depends on your requirements. I think, this model is fit for simple cases.