?
Solved

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

Posted on 2007-03-29
1
Medium Priority
?
181 Views
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();
                  attr.setName("LAB_ID");
                  attr.setValue(String.valueOf(lab.getId()));
                  attrs.add(attr);
            }

            if(lab.getDescription() != null && lab.getDescription().length() > 0) {
                  TEServiceStub.Attribute attr = new TEServiceStub.Attribute();
                  attr.setName("DESCRIPTION");
                  attr.setValue(lab.getDescription());
                  attrs.add(attr);
            }

            if(lab.getLocation() != null && lab.getLocation().length() > 0) {
                  TEServiceStub.Attribute attr = new TEServiceStub.Attribute();
                  attr.setName("LOCATION");
                  attr.setValue(lab.getLocation());
                  attrs.add(attr);
            }

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

            request.setAttributes(array);
            // 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());
      }
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: 18817201
Let's take an example:
           if(lab.getDescription() != null && lab.getDescription().length() > 0) {
                  TEServiceStub.Attribute attr = new TEServiceStub.Attribute();
                  attr.setName("DESCRIPTION");
                  attr.setValue(lab.getDescription());
                  attrs.add(attr);
            }
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
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone 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

Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
In this post we will learn different types of Android Layout and some basics of an Android App.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
Suggested Courses
Course of the Month9 days, 8 hours left to enroll

762 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