00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 package org.openmobileis.modules.common.data;
00031
00032 import org.openmobileis.common.intl.IntlResourceManager;
00033 import org.openmobileis.common.util.StringFormater;
00034 import org.openmobileis.common.util.collection.Orderable;
00035 import org.openmobileis.common.util.log.*;
00036
00044 public class DefaultLabel implements Orderable, Label {
00045
00046 static final long serialVersionUID = 5521257935120563452L;
00047 private String labelId;
00048 private String label = null;
00049 private String langue;
00050 private String category;
00051 private int order;
00052
00053 protected DefaultLabel() {
00054 super();
00055 }
00056
00057 public DefaultLabel(String id, String category, String label) {
00058 this.label = label;
00059 this.labelId = id;
00060 this.category = category;
00061 langue = IntlResourceManager.DEFAULT;
00062 }
00063
00064 public DefaultLabel(String id, String category, String label, String language) {
00065 this.label = label;
00066 this.labelId = id;
00067 this.category = category;
00068 langue = language;
00069 }
00070
00071
00072 public int compareTo(Object parm1, Object parm2) {
00073 if (!(parm1 instanceof DefaultLabel) || !(parm2 instanceof DefaultLabel)) {
00074 LogManager.traceError(
00075 LogServices.WEBSERVICE,
00076 "Attempt to compare wrong objects, not label");
00077 return 0;
00078 } else {
00079 return ((DefaultLabel) parm1).compareTo(((DefaultLabel) parm2));
00080 }
00081 }
00082
00083 public String getLabel() {
00084 return label;
00085 }
00086
00087 public String getLabelLanguage() {
00088 return langue;
00089 }
00090
00091 public String getCategory() {
00092 return this.category;
00093 }
00094
00095 public String getLabelId() {
00096 return labelId;
00097 }
00098
00104 public void setLabelSortOrder(int o) {
00105 this.order = o;
00106 }
00107 public int getLabelSortOrder() {
00108 return this.order;
00109 }
00110
00111 public String toString() {
00112 return this.getLabelId()+"/"+label;
00113 }
00114
00115 public boolean equals(Object obj) {
00116 if (!(obj instanceof DefaultLabel)) {
00117 throw new ClassCastException();
00118 } else {
00119 DefaultLabel newLab = ((DefaultLabel) obj);
00120 if ((newLab.labelId.equals(this.labelId)) &&(newLab.category.equals(this.category)))
00121 return true;
00122 return false;
00123 }
00124 }
00125
00126 public int hashCode() {
00127 StringBuffer strbuff = new StringBuffer(this.category);
00128 strbuff.append('/').append(this.labelId);
00129 return strbuff.hashCode();
00130 }
00131
00132
00133 public int compareTo(Object parm2) {
00134 if (!(parm2 instanceof DefaultLabel)) {
00135 LogManager.traceError(LogServices.WEBSERVICE, "DefaultLabel Attempt to compare wrong objects, not label");
00136 return 0;
00137 } else {
00138 DefaultLabel lab2 = (DefaultLabel)parm2;
00139 int comp = this.order - lab2.order;
00140 if (comp == 0) {
00141 comp = StringFormater.removeAccent(this.getLabel()).toUpperCase().compareTo(StringFormater.removeAccent(lab2.getLabel()).toUpperCase());
00142 }
00143 return comp;
00144 }
00145 }
00146
00147 }