1 18 19 package sync4j.framework.server; 20 21 import java.io.Serializable ; 22 23 import java.util.Map ; 24 import java.util.Iterator ; 25 26 import org.apache.commons.lang.builder.ToStringBuilder; 27 28 29 37 public class Sync4jDevice implements Serializable { 38 39 private static final String DEFAULT_CHARSET = "UTF-8"; 41 42 private String deviceId ; 44 private String description ; 45 private String type ; 46 private byte[] clientNonce ; 47 private byte[] serverNonce ; 48 private String serverPassword ; 49 private String timeZone ; 50 private boolean convertDate ; 51 private Capabilities capabilities; 52 private String charset ; 53 54 55 57 public Sync4jDevice() { 58 this(null, null, null, null, null, null, null, false, null); 59 } 60 61 66 public Sync4jDevice(final String deviceId) { 67 this(deviceId, null, null, null, null, null, null, false, null); 68 } 69 70 78 public Sync4jDevice(final String deviceId , 79 final String description, 80 final String type ) { 81 this(deviceId, description, type, null, null, null, null, false, null); 82 83 } 84 85 94 public Sync4jDevice(final String deviceId , 95 final String description, 96 final String type , 97 final byte[] clientNonce , 98 final byte[] serverNonce) { 99 this(deviceId, 100 description, 101 type, 102 clientNonce, 103 serverNonce, 104 null, 105 null, 106 false, 107 null); 108 109 } 110 111 123 public Sync4jDevice(final String deviceId , 124 final String description, 125 final String type , 126 final byte[] clientNonce, 127 final byte[] serverNonce, 128 final String serverPassword, 129 final String timeZone, 130 final boolean convertDate, 131 final String charset) { 132 this.deviceId = deviceId; 133 this.description = description; 134 this.type = type; 135 this.clientNonce = clientNonce; 136 this.serverNonce = serverNonce; 137 this.serverPassword = serverPassword; 138 this.timeZone = timeZone; 139 this.convertDate = convertDate; 140 if (charset == null) { 141 this.charset = DEFAULT_CHARSET; 142 } else { 143 this.charset = charset; 144 } 145 146 this.capabilities = new Capabilities(); 150 } 151 152 153 157 public String getDeviceId() { 158 return deviceId; 159 } 160 161 165 public void setDeviceId(String deviceId) { 166 this.deviceId = deviceId; 167 } 168 169 173 public String getDescription() { 174 return description; 175 } 176 177 181 public void setDescription(String description) { 182 this.description = description; 183 } 184 185 189 public String getType() { 190 return type; 191 } 192 193 197 public void setType(String type) { 198 this.type = type; 199 } 200 201 207 public byte[] getClientNonce() { 208 return this.clientNonce; 209 } 210 211 217 public void setClientNonce(byte[] clientNonce) { 218 if (clientNonce == null) { 219 clientNonce = new byte[0]; 220 } 221 this.clientNonce = clientNonce; 222 } 223 224 230 public byte[] getServerNonce() { 231 return this.serverNonce; 232 } 233 234 240 public void setServerNonce(byte[] serverNonce) { 241 if (serverNonce == null) { 242 serverNonce = new byte[0]; 243 } 244 this.serverNonce = serverNonce; 245 } 246 247 252 public String getServerPassword() { 253 return this.serverPassword; 254 } 255 256 261 public void setServerPassword(String serverPassword) { 262 this.serverPassword = serverPassword; 263 } 264 265 270 public void setCapabilities(Capabilities capabilities) { 271 this.capabilities = capabilities; 272 } 273 274 279 public Capabilities getCapabilities() { 280 return capabilities; 281 } 282 283 288 public void setTimeZone(String tz) { 289 this.timeZone = tz; 290 } 291 292 297 public String getTimeZone() { 298 return timeZone; 299 } 300 301 306 public void setConvertDate(boolean convertDate) { 307 this.convertDate = convertDate; 308 } 309 310 315 public boolean getConvertDate() { 316 return convertDate; 317 } 318 319 324 public void setCharset(String charset) { 325 this.charset = charset; 326 } 327 328 333 public String getCharset() { 334 return charset; 335 } 336 337 338 public String toString() { 339 ToStringBuilder sb = new ToStringBuilder(this); 340 341 sb.append("deviceId", deviceId); 342 sb.append("description", description); 343 sb.append("type", type); 344 if (clientNonce != null) { 345 sb.append("client_nonce", new String (clientNonce)); 346 } 347 if (serverNonce != null) { 348 sb.append("server_nonce", new String (serverNonce)); 349 } 350 sb.append("serverPassword", serverPassword); 351 sb.append("timeZone", timeZone); 352 sb.append("convertDate", convertDate); 353 sb.append("charset", charset); 354 355 return sb.toString(); 356 } 357 358 } 359 | Popular Tags |