Solved

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

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

735 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