Solved

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
bitbucket vs gitbucket 3 57
micro services vs rest web services 16 84
thymeleaf natural templating vs JSP 2 66
table example 4 21
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

912 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

22 Experts available now in Live!

Get 1:1 Help Now