00001 /* 00002 * OpenMobileIS - a free Java(TM) Framework for mobile applications Java(TM) 00003 * Copyright (C) 2004-2006 Philippe Delrieu 00004 * All rights reserved. 00005 * Contact: pdelrieu@openmobileis.org 00006 * 00007 * This library is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU Lesser General Public 00009 * License as published by the Free Software Foundation; either 00010 * version 2.1 of the License, or any later version. 00011 * 00012 * This library is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 * Lesser General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU Lesser General Public 00018 * License along with this library; if not, write to the Free Software 00019 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 00020 * USA 00021 * 00022 * Author : Philippe Delrieu 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.ProfileService; 00030 import org.openmobileis.common.util.OpenMISSerializable; 00031 00036 public final class Profile implements OpenMISSerializable { 00037 static final long serialVersionUID = 5521257935120563452L; 00041 public String userID; 00042 00046 public ProfileProperty[] profilProperties; 00047 00051 public ProfileService[] ProfileServices; 00052 00056 public String profilName; 00057 00061 public Profile() { } 00062 00070 public Profile(String userID, ProfileProperty[] profilProperties, ProfileService[] profilRubric) { 00071 this.userID = userID; 00072 this.profilProperties = profilProperties; 00073 this.ProfileServices = profilRubric; 00074 } 00075 00076 public int hashCode() { 00077 final int prime = 31; 00078 int result = 1; 00079 result = prime * result + ((profilName == null) ? 0 : profilName.hashCode()); 00080 return result; 00081 } 00082 00083 public boolean equals(Object obj) { 00084 if (this == obj) 00085 return true; 00086 if (obj == null) 00087 return false; 00088 if (getClass() != obj.getClass()) 00089 return false; 00090 final Profile other = (Profile) obj; 00091 if (profilName == null) { 00092 if (other.profilName != null) 00093 return false; 00094 } else if (!profilName.equals(other.profilName)) 00095 return false; 00096 return true; 00097 } 00098 00099 00100 00101 00102 /* public String toXML() { 00103 StringBuffer buff = new StringBuffer(); 00104 buff.append("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n\t"); 00105 buff.append("<PROFILLIST>"); 00106 buff.append("<PROFILNAME name=\""+this.profilName+"\">"); 00107 for (int i=0; i<ProfileServices.length; i++) { 00108 buff.append("<ENTRY moduleName=\""+ProfileServices[i].moduleName+"\" serviceName=\""+ProfileServices[i].serviceName+"\""); 00109 if (ProfileServices[i].description != null) { 00110 buff.append(" description=\""+ProfileServices[i].description+"\""); 00111 } 00112 if (ProfileServices[i].version != null) { 00113 buff.append(" version=\""+ProfileServices[i].version+"\""); 00114 } 00115 buff.append(" />"); 00116 } 00117 for (int i=0; i<profilProperties.length; i++) { 00118 buff.append("<PROPERTY key=\""+profilProperties[i].key+"\" value=\""+profilProperties[i].value+"\" "); 00119 if (profilProperties[i].moduleName!= null) { 00120 buff.append(" module=\""+profilProperties[i].moduleName+"\""); 00121 } 00122 buff.append(" />"); 00123 } 00124 buff.append("</PROFILNAME>"); 00125 buff.append("</PROFILLIST>"); 00126 return buff.toString(); 00127 } 00128 00129 public boolean equals(Object obj) { 00130 if (obj instanceof Profile) { 00131 Profile nobj = (Profile) obj; 00132 if (nobj.profilName.equals(this.profilName)) { 00133 //validate profil service 00134 Array thisrubric = new Array(this.ProfileServices); 00135 for (int i=0; i<nobj.ProfileServices.length; i++) { 00136 if (!thisrubric.contains(nobj.ProfileServices[i])) { 00137 return false; 00138 } 00139 } 00140 Array nobjrubric = new Array(nobj.ProfileServices); 00141 for (int i=0; i<this.ProfileServices.length; i++) { 00142 if (!nobjrubric.contains(this.ProfileServices[i])) { 00143 return false; 00144 } 00145 } 00146 //validate profil properties 00147 Array thisprop = new Array(this.profilProperties); 00148 for (int i=0; i<nobj.profilProperties.length; i++) { 00149 if (!thisprop.contains(nobj.profilProperties[i])) { 00150 return false; 00151 } 00152 } 00153 Array nobjprop= new Array(nobj.profilProperties); 00154 for (int i=0; i<this.profilProperties.length; i++) { 00155 if (!nobjprop.contains(this.profilProperties[i])) { 00156 return false; 00157 } 00158 } 00159 00160 return true; 00161 } 00162 } 00163 return false; 00164 } 00165 00166 public int hashCode() { 00167 return profilName.hashCode(); 00168 } 00169 */ 00170 00171 00172 }