kullyN
asked on
mapping data into a collection or data structure (easy)
i have data like below:
licNo cusRef cusName
1 "005" "gdgd"
2 "006" "llkm"
3 "007" "lkjlk"
i need to map this data into a structure where i can access each element data through the licNo
licNo cusRef cusName
1 "005" "gdgd"
2 "006" "llkm"
3 "007" "lkjlk"
i need to map this data into a structure where i can access each element data through the licNo
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
OK - just omit the key from the class then. My code will still work - it's just that you won't hold the licNo in the class itself
ASKER
how will i be able to map the licNo to the newly created Customer in the map.
at runtime i will run a test which will retrun a set of customer with licNo's
i then need to do a quick check to see which of the licNo match with the data i have and then from there retrieve the results map linked to the licNo
does this make sense?
at runtime i will run a test which will retrun a set of customer with licNo's
i then need to do a quick check to see which of the licNo match with the data i have and then from there retrieve the results map linked to the licNo
does this make sense?
ASKER
what i have so far
Map testData = new HashMap();
Address add1 = new Address(80005023, "UK");
Customer cus1 = new Customer("0044234", "academics", 9905504, "N", "CNV", add1, null);
Map testData = new HashMap();
Address add1 = new Address(80005023, "UK");
Customer cus1 = new Customer("0044234", "academics", 9905504, "N", "CNV", add1, null);
Not sure what you're posting now kullyN - that's just creating two different objects that don't seem to be related
ASKER
is this any better?
Map testData = new HashMap();
Object[] cus1 = {"81","0044234", "academics", "9905504", "N", "CNV", null, null}; // customer 1
Object[] cus2 = {"1","0044234", "academics", "9905504", "N", "CNV", null, null}; // customer 2
Collection coll = new ArrayList();
coll.add(cus1);
coll.add(cus2);
testData.put(CommonConstan ts.PARAM_R ESULTS, coll);
Map testData = new HashMap();
Object[] cus1 = {"81","0044234", "academics", "9905504", "N", "CNV", null, null}; // customer 1
Object[] cus2 = {"1","0044234", "academics", "9905504", "N", "CNV", null, null}; // customer 2
Collection coll = new ArrayList();
coll.add(cus1);
coll.add(cus2);
testData.put(CommonConstan
Your customer should be represented by its own abstraction (class)
testData.put(cus1licNo, cus1);
testData.put(cus2licNo, cus2);
testData.put(cus2licNo, cus2);
ASKER
In the Object Relational Mapping the Licences are linked to the Customer through the attribute cusRef
im making a copy of data from the DB and then testing a function which retrieves customer via parsing in the licNo.
thus i need this testData structure to check the values retrived from the test