Solved

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

Posted on 2007-03-28
1
159 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
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
word0 challenge 3 58
firstChar challenge 13 85
Java passing arguments (type error) 2 35
Cipher Configuration on Apache HTTPD 4 22
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to implement Singleton Design Pattern in Java.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

760 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now