Chapter 14 Snippets

p. 465

Step 9:

try
{
}
catch (Exception e)
{
  System.out.println(e.toString());
  throw new EJBException(e);
}

p. 466

Step 10:

ArrayList dtoList = new ArrayList();

Step 12:

Collection beanList =
  getDepartmentsLocalHome().findByLocationId(new Long(1700));
Iterator beanIter = beanList.iterator();
DepartmentsLocal currBean;

Step 14:

while (beanIter.hasNext())
{
  currBean = (DepartmentsLocal) beanIter.next();
  DepartmentsLocalDTO deptsDTO =
    new DepartmentsLocalDTO(currBean);
  dtoList.add(deptsDTO);
}

Step 15:

return dtoList;

p. 482

Step 2:

public String calculateName(DatabaseRow row)
{
}

Step 4, near bottom of page:

String firstName = (String) row.get("FIRST_NAME");
String lastName = (String) row.get("LAST_NAME");
return firstName + " " + lastName;

Step 5, bottom of page:

public String nameToFirstName()
{
  int spacePosition = getName().indexOf(' ');
  return getName().substring(0, spacePosition);
}

p. 483

Step 6:

public String nameToLastName()
{
  int spacePosition = getName().indexOf(' ');
  return getName().substring(spacePosition + 1);
}

p. 486

Step 7:

SELECT DEPARTMENT_ID,
  DEPARTMENT_NAME
FROM DEPARTMENTS
WHERE LOCATION_ID = 1700

p. 492

Step 5:

private final GoogleSearchServiceStub stub;

Step 6:

stub = new GoogleSearchServiceStub();

Step 7, bottom of page (Note that you must replace XXXX with a valid license key):

public GoogleSearchResult doSearch(String searchString)
  throws Exception
{
  return stub.doGoogleSearch(
    "XXXX",             // license key
    searchString,       // search string
    new Integer(0),     // start at
    new Integer(10),    // results returned
    new Boolean(true),  // filter results
    "",
    new Boolean(true),  // SafeSearch
    "",
    "",
    ""
  );
}