File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes representing data in tree structure way Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "representing data in tree structure way" Watch "representing data in tree structure way" New topic
Author

representing data in tree structure way

R .sourav nayak
Ranch Hand

Joined: May 14, 2006
Posts: 67
hi,
i have to write a java class to represent the data in tree structure. In database the datas are being declared in tree structure way.

could some one provide me java class. which will help me retrive those datas in structural way.

thanks in advance
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
We always ask how far you've gotten and where you are stuck. Do you know how you want to make a tree in memory? Look in the JavaDoc for TreeNode and see if that gives you some ideas. How is the tree stored in the database? That will make a lot of difference when it comes time to load it.


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
R .sourav nayak
Ranch Hand

Joined: May 14, 2006
Posts: 67
hi,
thanks for the replay.on the database data's are stored in toplevel,sublevel and the leafnodes related to sublevel. In my java code i am able iterate through the node and leaf nodes. but i am having a problem string that in a list and bringing that to my jps page in a tree structure way. below is my cod e.


could you tell me how do i temporarily store it in a list after each iteration and call that on my jsp altogeter.

thanks in advance
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
I think you're missing a bit to add each new child to its parent. I'm going to use generic Nodes because I'm not sure I understand your data fully. Let's say a Node has an Object that we're interested in and a collection of children.

Now your JSP (or some other code) can walk the object graph from Root on down. Does that make sense?

BTW: You can write the for loop one line shorter:

[ November 15, 2007: Message edited by: Stan James ]
 
jQuery in Action, 2nd edition
 
subject: representing data in tree structure way