?
Solved

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

Posted on 2007-03-28
1
Medium Priority
?
171 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 2000 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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
Suggested Courses

752 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