AddressBook Reads a Contact

Listing 1. The AddressBook application reads a contact by fetching its fields from the ContactDatabase and assembling them into an object.

this.details = theDetails; 
currentContact = contact; // So we can update
  // this card
try  {
  if (!contact.getName().equals(""))
  {
    // Get the name Aggregate field and split
    // it apart
    AggregateField name = (AggregateField)contact.
      getField("N"); // Get name. 
    theDetails.setSurname(name.getField(
      ContactDatabase.FAMILY_NAME).getString());
    theDetails.setName(name.getField(
      ContactDatabase.GIVEN_NAME).getString());
  }
} catch (NullPointerException ne) {
  println("Contact Contains No Name"); 
}

// Get The Role 
ItemField role = contact.getField(
  ContactDatabase.ROLE);
if (role != null)
  theDetails.setRole(role.getString());
...