Methods Summary |
---|
public void | addEmailAddress(java.lang.String address)
// Make sure the address isn't there already
if (!mEmailAddresses.contains(address)) {
mEmailAddresses.add(address);
}
|
public boolean | equals(java.lang.Object other)
boolean eq = false;
if (other instanceof Person) {
Person p2 = (Person)other;
// If both references point to the same object, then
// shortcut the equality check below
if (p2 == this) {
return true;
}
// The id and name attributes should either be both null, or
// both non-null and equal to each other
eq = ((p2.getId() == null && this.getId() == null) ||
(p2.getId() != null && this.getId() != null &&
p2.getId().equals(this.getId())));
eq = eq &&
((p2.getFirstName() == null && this.getFirstName() == null) ||
(p2.getFirstName() != null && this.getFirstName() != null &&
p2.getFirstName().equals(this.getFirstName())));
eq = eq &&
((p2.getLastName() == null && this.getFirstName() == null) ||
(p2.getLastName() != null && this.getLastName() != null &&
p2.getLastName().equals(this.getLastName())));
// Both should have the same number of email addresses
eq = eq &&
(p2.getEmailAddresses().length ==
this.getEmailAddresses().length);
if (eq) {
// For each of our email addresses, confirm that the
// other has the address on its list
// We do this by putting one set of addresses in a collection
// and iterating through the other using contains() to check
// for its presence on the other list.
// This isn't the most efficient approach, but it's easy to
// implement.
ArrayList tmpList = new ArrayList();
for (int i = 0; i < p2.getEmailAddresses().length; i++) {
tmpList.add(p2.getEmailAddresses()[i]);
}
for (int i = 0; i < this.getEmailAddresses().length; i++) {
eq = eq && tmpList.contains(this.getEmailAddresses()[i]);
}
}
}
return eq;
|
public java.lang.String[] | getEmailAddresses()
String[] addrs = new String[mEmailAddresses.size()];
Object[] origAddrs = mEmailAddresses.toArray();
for (int i = 0; i < addrs.length; i++) {
addrs[i] = (String)origAddrs[i];
}
return addrs;
|
public java.lang.String | getFirstName()
return mFirstName;
|
public java.lang.String | getId()
return mID;
|
public java.lang.String | getLastName()
return mLastName;
|
public void | setEmailAddresses(java.lang.String[] addresses)
mEmailAddresses = new ArrayList();
for (int i = 0; i < addresses.length; i++) {
mEmailAddresses.add(addresses[i]);
}
|
public void | setFirstName(java.lang.String fName)
mFirstName = fName;
|
public void | setLastName(java.lang.String lName)
mLastName = lName;
|