Can someone comment what this if statements are doing in this method?

Posted on 2007-03-29
Last Modified: 2010-03-31
Can someone comment what this if statements are doing in this method?
public Attribute[] saveLab(Lab lab) throws ManagementSupportException {
             // creating "request" object using service's method
            TEServiceStub.SaveLab request = new TEServiceStub.SaveLab();

            TEServiceStub.AttributeArray array = new TEServiceStub.AttributeArray();
            List<TEServiceStub.Attribute> attrs = new ArrayList<TEServiceStub.Attribute>();

            if(lab.getId() > 0) {
                  TEServiceStub.Attribute attr = new TEServiceStub.Attribute();

            if(lab.getDescription() != null && lab.getDescription().length() > 0) {
                  TEServiceStub.Attribute attr = new TEServiceStub.Attribute();

            if(lab.getLocation() != null && lab.getLocation().length() > 0) {
                  TEServiceStub.Attribute attr = new TEServiceStub.Attribute();

            if(lab.getOwner() != null && lab.getOwner().length() > 0) {
                  TEServiceStub.Attribute attr = new TEServiceStub.Attribute();
            array.setAttributes((TEServiceStub.Attribute[]) attrs.toArray());

            // declaring "response" object
            TEServiceStub.SaveLabResponse response = null;
            try {
                  // invoking web service's method
                  response = stub.saveLab(request);
            } catch (RemoteException e) {
                  logger.warn("Fail to call TEService :" + e);
                  throw new ManagementSupportException("Fail to call TEService :" + e);
            // processing "response" object
            if(!response.getStatus().getSuccess()) {
                  logger.warn("TEService return failure while call saveLab()");
                  throw new ManagementSupportException("TEService return failure while call saveLab()");

            return cast(response.getAttributes());
Question by:yankeebushsoftware
1 Comment
LVL 11

Accepted Solution

elfe69 earned 500 total points
ID: 18817201
Let's take an example:
           if(lab.getDescription() != null && lab.getDescription().length() > 0) {
                  TEServiceStub.Attribute attr = new TEServiceStub.Attribute();
It says that if the description of lab is not empty, this description is stored in a list of attributes (attrs) that will be later sent with the request

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
base64 decode encode 12 122
github account with ecipse 1 42
How to monitor the number of connections/threads being utilized on Tomcat 6.0 8 56
java jdbc batch example 8 22
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…
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 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…
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.

867 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

16 Experts available now in Live!

Get 1:1 Help Now