aspose file tools
The moose likes Java in General and the fly likes Java Collection issue Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Java Collection issue" Watch "Java Collection issue" New topic
Author

Java Collection issue

zaxxon25
Ranch Hand

Joined: Feb 26, 2005
Posts: 35
am facing issue on how to store and then retrieve data . In my program which is simple java class i am retrieving data at 3 places from an xml. i need to store this temporarly in particular fashion as data is related and needed to be used later on at end program to generate report.

first data i am retireving is employee names eg Tom , Reggie, Martha.
Second data is department (Each employee belongs to 1 or many department ) so in this case

Tom : Billing
Reggie : Admin , HR
Martha : IT

Third data is Department number (This has 1 : 1 relationship with Department )
Billing :01
Admin :02
HR:03
IT:04

So when i am parsing xml first i am getting employee data, then department and lastly department number. I need to store it in collection in such way later on i can retireve and link data and use it.....

Which java collections i should use....
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

"zaxxon25",
Welcome back to the JavaRanch.

We're a friendly group, but we do require members to have valid display names.

Display names must be two words: your first name, a space, then your last name. Fictitious names are not allowed.

Please edit your profile and correct your display name since accounts with invalid display names get deleted.

This is the final request before we close your account.

thanks,
Dave.
Abdul Mohsin
Ranch Hand

Joined: Apr 26, 2007
Posts: 111

Hi zaxxon25 (Please make it realistic),

I suppose the third data of Department number is fixed so you can use class scope
hashtable which will be populated only once, for the other data you can create a bean ( inner class or outer if your project permits)

class EmpTempData{

public EmpTempData(Hashtable deptNumbers){
this.deptNumber=deptNumbers;
}
private String empName;
private ArrayList empDepartment;
/*
containing "deptName" and "deptNumber" pair
*/
private Hashtable deptNumbers;

//getter setter methods of empName,empDepartment and deptNumbers

// method to get department numbers corresponding to department name

public Hashtable getEmpDeptNameAndNumber(){
// implementation
}
}


Regards, Abdul Mohsin
 
I agree. Here's the link: jrebel
 
subject: Java Collection issue
 
Similar Threads
what is the error in this program
about toString() method in K&B's book
Marshalling XML with Spring (How to handle referenced classes)
one to many concepts
Design question regarding managing one-to-many relationship...