01: package org.claros.intouch.contacts.utility;
02:
03: import java.util.Collections;
04: import java.util.List;
05:
06: import org.claros.intouch.contacts.models.Contact;
07:
08: /**
09: * @author Umut Gokbayrak
10: */
11: public class Utility {
12:
13: /* (non-Javadoc)
14: * @see java.lang.Comparable#compareTo(java.lang.Object)
15: */
16: public static List sortContacts(List contacts, boolean nameFirst) {
17: if (contacts != null) {
18: Collections.sort(contacts,
19: new ContactsComparator(nameFirst));
20: }
21: return contacts;
22: }
23:
24: public static String getFullName(Contact contact, boolean nameFirst) {
25: String firstName = contact.getFirstName();
26: String middleName = contact.getMiddleName();
27: String lastName = contact.getLastName();
28:
29: String fullName = "";
30: if (lastName == null || lastName.trim().equals("")) {
31: fullName = firstName;
32: } else {
33: if (nameFirst) {
34: fullName = firstName + " " + lastName;
35: if (middleName != null && !middleName.trim().equals("")) {
36: fullName = firstName + " " + middleName + " "
37: + lastName;
38: }
39: } else {
40: fullName = lastName + ", " + firstName;
41: if (middleName != null && !middleName.trim().equals("")) {
42: fullName = lastName + ", " + firstName + " "
43: + middleName;
44: }
45: }
46: }
47: return fullName.trim();
48: }
49:
50: }
|