/* * SortObject */ package _download.src.list.sort; //java import java.io.Serializable; import java.text.Collator; /** * Sorting object with individual comparison */ public class SortObject implements Comparable, Serializable { private String firstName = null; private String lastName = null; /** * Compares two objects by checking the attributes * If two objects have same firstname the lastname will be checked too * The check is done in a localized manner (german special characters will be regarded) * The comparison strength is set to case-insensitive (a == A, a != ä) * @param compareObject Object which should be checked against this * @return Negativ means less, zero means equal and otherwise means greater */ public int compareTo(SortObject compareObject) { int result = 0; Collator collator = null; //INIT collator = Collator.getInstance(java.util.Locale.GERMAN); collator.setStrength(Collator.SECONDARY); //FIRSTNAME result = collator.compare(getFirstName(), compareObject.getFirstName()); if (result != 0) return result; //LASTNAME return collator.compare(getLastName(), compareObject.getLastName()); } /** * Returns the firstname of the object * @return Firstname of the object */ public String getFirstName() { return firstName; } /** * Sets the firstname of the object * @param firstName New firstname of the object */ public void setFirstName(String firstName) { this.firstName = firstName; } /** * Returns the lastname of the object * @return Lastname of the object */ public String getLastName() { return lastName; } /** * Sets the lastname of the object * @param lastName New lastname of the object */ public void setLastName(String lastName) { this.lastName = lastName; } /** * Returns the object as XML-String * @return Object as XML-String */ public String toXML() { StringBuilder xml = new StringBuilder(); xml.append("\n"); xml.append("\n"); xml.append("\n"); xml.append("\n"); return xml.toString(); } }