Solved

Can someone comment this Java code and tell me what its doing?

Posted on 2007-03-28
1
166 Views
Last Modified: 2010-03-31
Can someone comment this code for me and tell me what its doing?
private Tree cast(TEServiceStub.Tree tree) {
            if(tree.getChildren() != null && tree.getChildren().getTrees().length > 0) {
                  List<Tree> children = new ArrayList<Tree>();
                  for(TEServiceStub.Tree oneTree : tree.getChildren().getTrees()) {
                        children.add(cast(oneTree));
                  }
                  Node node = cast(tree.getNode());
                  return new Tree(children, node);
            } else {
                  return new Tree(cast(tree.getNode()));
            }
      }

      private Node cast(TEServiceStub.Node node) {
            if(node == null) {
                  return null;
            }
            Node result = new Node();
            result.setAttributes(cast(node.getAttributes()));
            result.setNodeId(node.getId());
            return result;
      }
}
0
Comment
Question by:yankeebushsoftware
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 11

Accepted Solution

by:
elfe69 earned 500 total points
ID: 18814112
Those two methods do a deep type casting of TEServiceStub.Tree objects to Tree objects and from TEServiceStub.Node objects to Node.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There is an easy way, in .NET, to centralize the treatment of all unexpected errors. First of all, instead of launching the application directly in a Form, you need first to write a Sub called Main, in a module. Then, set the Startup Object to th…
In this post we will learn different types of Android Layout and some basics of an Android App.
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
Suggested Courses

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question