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 package org.openmobileis.common.user.profile;
00027
00028 import org.openmobileis.common.user.profile.ProfileProperty;
00029 import org.openmobileis.common.user.profile.ProfileRubric;
00030 import org.openmobileis.common.util.OpenMISSerializable;
00031 import org.openmobileis.common.util.collection.Array;
00032
00037 public final class Profile implements OpenMISSerializable {
00038 static final long serialVersionUID = 5521257935120563452L;
00042 public String userID;
00043
00047 public ProfileProperty[] profilProperties;
00048
00052 public ProfileRubric[] profilRubric;
00053
00057 public String profilName;
00058
00062 public Profile() { }
00063
00071 public Profile(String userID, ProfileProperty[] profilProperties, ProfileRubric[] profilRubric) {
00072 this.userID = userID;
00073 this.profilProperties = profilProperties;
00074 this.profilRubric = profilRubric;
00075 }
00076
00077 public String toXML() {
00078 StringBuffer buff = new StringBuffer();
00079 buff.append("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n\t");
00080 buff.append("<PROFILLIST>");
00081 buff.append("<PROFILNAME name=\""+this.profilName+"\">");
00082 for (int i=0; i<profilRubric.length; i++) {
00083 buff.append("<ENTRY moduleName=\""+profilRubric[i].moduleName+"\" rubricName=\""+profilRubric[i].rubricName+"\"");
00084 if (profilRubric[i].description != null) {
00085 buff.append(" description=\""+profilRubric[i].description+"\"");
00086 }
00087 if (profilRubric[i].version != null) {
00088 buff.append(" version=\""+profilRubric[i].version+"\"");
00089 }
00090 buff.append(" />");
00091 }
00092 for (int i=0; i<profilProperties.length; i++) {
00093 buff.append("<PROPERTY key=\""+profilProperties[i].key+"\" value=\""+profilProperties[i].value+"\" ");
00094 if (profilProperties[i].moduleName!= null) {
00095 buff.append(" module=\""+profilProperties[i].moduleName+"\"");
00096 }
00097 buff.append(" />");
00098 }
00099 buff.append("</PROFILNAME>");
00100 buff.append("</PROFILLIST>");
00101 return buff.toString();
00102 }
00103
00104 public boolean equals(Object obj) {
00105 if (obj instanceof Profile) {
00106 Profile nobj = (Profile) obj;
00107 if (nobj.profilName.equals(this.profilName)) {
00108
00109 Array thisrubric = new Array(this.profilRubric);
00110 for (int i=0; i<nobj.profilRubric.length; i++) {
00111 if (!thisrubric.contains(nobj.profilRubric[i])) {
00112 return false;
00113 }
00114 }
00115 Array nobjrubric = new Array(nobj.profilRubric);
00116 for (int i=0; i<this.profilRubric.length; i++) {
00117 if (!nobjrubric.contains(this.profilRubric[i])) {
00118 return false;
00119 }
00120 }
00121
00122 Array thisprop = new Array(this.profilProperties);
00123 for (int i=0; i<nobj.profilProperties.length; i++) {
00124 if (!thisprop.contains(nobj.profilProperties[i])) {
00125 return false;
00126 }
00127 }
00128 Array nobjprop= new Array(nobj.profilProperties);
00129 for (int i=0; i<this.profilProperties.length; i++) {
00130 if (!nobjprop.contains(this.profilProperties[i])) {
00131 return false;
00132 }
00133 }
00134
00135 return true;
00136 }
00137 }
00138 return false;
00139 }
00140
00141 public int hashCode() {
00142 return profilName.hashCode();
00143 }
00144
00145 }