Best data-structure to parse data

jkteater
jkteater used Ask the Experts™
on
I am pulling data from a jtable.

for(int i = 0; i < SingletonSelectTable.getInstance().getRowCount(); i++) {
         Object item_id = SingletonSelectTable.getInstance().getValueAt(i, SingletonSelectTable.getInstance().ITEMID_COL);
         Object rev_id = SingletonSelectTable.getInstance().getValueAt(i, SingletonSelectTable.getInstance().REVID_COL);
         Object prl_id = SingletonSelectTable.getInstance().getValueAt(i, SingletonSelectTable.getInstance().PRL_COL);
         Object datasetName_id = SingletonSelectTable.getInstance().getValueAt(i, SingletonSelectTable.getInstance().DATASETNAME_COL);
         Object datasetType_id = SingletonSelectTable.getInstance().getValueAt(i, SingletonSelectTable.getInstance().DATASET_COL);

Open in new window


I want to store the data in a data-structure, so once I all the data I can parse the data looking for matching values and write out a XML StringBuffer.  

Which data-structure do you prefer?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Use java bean and has table
It depends on what you mean by "looking for matching data".

The obvious data structure to use is a Map - where the key is whatever value you want to match against.  E.g. if you want to match data based on the item_id then you'd create a

Map<ItemID, Object>

where ItemID is the type of your item_id field and then Object is an object containing all of the other fields.

Once you have that you can easily do any matching you want and then ultimately convert it back to XML.

Doug

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial