1 29 38 39 package org.planetamessenger.plugin; 40 41 42 public class JContactListItem implements java.lang.Comparable { 43 44 static public final int CONTACT_IN_LIST = 0; 45 static public final int CONTACT_NOT_IN_LIST = 1; 46 47 java.lang.String strNickName = ""; 48 java.lang.String strUserId = ""; 49 java.lang.String strFirstName = ""; 50 java.lang.String strLastName = ""; 51 java.lang.String strEmail = ""; 52 java.lang.String strNotes = ""; 53 54 int nPluginId = -1; 55 int nGender = -1; 56 int nGroupId = -1; 57 int nAge = 0; 58 int nContactFlag = CONTACT_IN_LIST; 59 boolean bVisible = true; 60 boolean bBlocked = false; 61 int nOnlineStatus = JPlugin.STATUS_OFFLINE; 62 int nCurrentStatus = JPlugin.STATUS_OFFLINE; 63 64 65 66 70 public JContactListItem() { 71 72 } 73 74 81 public JContactListItem( int nPluginId, java.lang.String strUserId, java.lang.String strNickName ) { 82 83 this(); 84 85 this.strUserId = strUserId; 86 this.nPluginId = nPluginId; 87 this.strNickName = strNickName; 88 } 89 90 94 public void setUserId( java.lang.String strUserId ) { 95 96 this.strUserId = strUserId; 97 } 98 99 102 public java.lang.String getUserId() { 103 104 return strUserId; 105 } 106 107 111 public void setPluginId( int nPluginId ) { 112 113 this.nPluginId = nPluginId; 114 } 115 116 120 public int getPluginId() { 121 122 return nPluginId; 123 } 124 125 129 public void setNickName( java.lang.String strNickName ) { 130 131 this.strNickName = strNickName; 132 } 133 134 137 public java.lang.String getNickName() { 138 139 return strNickName; 140 } 141 142 146 public void setFirstName( java.lang.String strFirstName ) { 147 148 this.strFirstName = strFirstName; 149 } 150 151 154 public java.lang.String getFirstName() { 155 156 return strFirstName; 157 } 158 159 163 public void setLastName( java.lang.String strLastName ) { 164 165 this.strLastName = strLastName; 166 } 167 168 171 public java.lang.String getLastName() { 172 173 return strLastName; 174 } 175 176 180 public void setEmail( java.lang.String strEmail ) { 181 182 this.strEmail = strEmail; 183 } 184 185 188 public java.lang.String getEmail() { 189 190 return strEmail; 191 } 192 193 200 public void setGender( int nGender ) { 201 202 this.nGender = nGender; 203 } 204 205 208 public int getGender() { 209 210 return nGender; 211 } 212 213 217 public void setAge( int nAge ) { 218 219 this.nAge = nAge; 220 } 221 222 225 public int getAge() { 226 227 return nAge; 228 } 229 230 234 public void setVisible( boolean bVisible ) { 235 236 this.bVisible = bVisible; 237 } 238 239 242 public boolean getVisible() { 243 244 return bVisible; 245 } 246 247 251 public void setBlocked( boolean bBlocked ) { 252 253 this.bBlocked = bBlocked; 254 } 255 256 259 public boolean getBlocked() { 260 261 return bBlocked; 262 } 263 264 268 public void setNotes( java.lang.String strNotes ) { 269 270 this.strNotes = strNotes; 271 } 272 273 276 public java.lang.String getNotes() { 277 278 return strNotes; 279 } 280 281 285 public void setGroupId( int nGroupId ) { 286 287 this.nGroupId = nGroupId; 288 } 289 290 293 public int getGroupId() { 294 295 return nGroupId; 296 } 297 298 303 public void setContactFlag( int nContactFlag ) { 304 305 this.nContactFlag = nContactFlag; 306 } 307 308 312 public int getContactFlag() { 313 314 return nContactFlag; 315 } 316 317 318 321 public boolean isContact() { 322 323 return ( nContactFlag == CONTACT_IN_LIST ); 324 } 325 326 330 public void setStatus( int nNewStatus ) { 331 332 if( ( nNewStatus != JPlugin.STATUS_MESSAGE ) && 333 ( nNewStatus != JPlugin.STATUS_URL ) ) 334 nOnlineStatus = nNewStatus; 335 336 if( ( nCurrentStatus != JPlugin.STATUS_MESSAGE ) && 337 ( nCurrentStatus != JPlugin.STATUS_URL ) ) 338 nCurrentStatus = nNewStatus; 339 } 340 341 344 public int getStatus() { 345 346 return ( nCurrentStatus != nOnlineStatus ? nCurrentStatus : nOnlineStatus ); 347 } 348 349 352 public int getOnlineStatus() { 353 354 return nOnlineStatus; 355 } 356 357 363 public void restoreRealStatus() { 364 365 nCurrentStatus = nOnlineStatus; 366 } 367 368 372 public void copy( JContactListItem item ) { 373 374 strNickName = item.strNickName; 375 strUserId = item.strUserId; 376 strFirstName = item.strFirstName; 377 strLastName = item.strLastName; 378 strEmail = item.strEmail; 379 strNotes = item.strNotes; 380 nPluginId = item.nPluginId; 381 nGender = item.nGender; 382 nGroupId = item.nGroupId; 383 nAge = item.nAge; 384 nContactFlag = item.nContactFlag; 385 bVisible = item.bVisible; 386 bBlocked = item.bBlocked; 387 nOnlineStatus = item.nOnlineStatus; 388 nCurrentStatus = item.nCurrentStatus; 389 } 390 391 397 public boolean equals( Object obj ) { 398 399 JContactListItem item = ( JContactListItem ) obj; 400 401 402 if( strUserId.equals( item.strUserId ) && ( nPluginId == item.nPluginId ) ) 403 return true; 404 else 405 return false; 406 } 407 408 418 public int compareTo( Object obj ) { 419 420 JContactListItem item = ( JContactListItem ) obj; 421 422 423 if( item.getPluginId() == -1 ) 424 return 1; 425 else 426 if( ( item.getPluginId() == -2 ) && ( getOnlineStatus() == JPlugin.STATUS_OFFLINE ) ) 427 return 1; 428 else 429 if( ( item.getStatus() >= JPlugin.STATUS_URL ) && 430 ( item.getOnlineStatus() > JPlugin.STATUS_OFFLINE ) && 431 ( getPluginId() != -1 ) && ( getPluginId() != -2 ) && 432 ( getOnlineStatus() > JPlugin.STATUS_OFFLINE ) && 433 ( getStatus() < JPlugin.STATUS_URL ) ) 434 return 1; 435 else 436 if( ( getStatus() >= JPlugin.STATUS_URL ) && 437 ( getOnlineStatus() > JPlugin.STATUS_OFFLINE ) && 438 ( item.getPluginId() != -1 ) && ( item.getPluginId() != -2 ) && 439 ( item.getOnlineStatus() > JPlugin.STATUS_OFFLINE ) && 440 ( item.getStatus() < JPlugin.STATUS_URL ) ) 441 return -1; 442 else 443 if( ( item.getOnlineStatus() > JPlugin.STATUS_OFFLINE ) && 444 ( getOnlineStatus() == JPlugin.STATUS_OFFLINE ) && 445 ( getPluginId() != -1 ) ) 446 return 1; 447 else 448 if( ( item.getStatus() >= JPlugin.STATUS_URL ) && 449 ( item.getOnlineStatus() == JPlugin.STATUS_OFFLINE ) && 450 ( getOnlineStatus() == JPlugin.STATUS_OFFLINE ) && 451 ( getPluginId() != -1 ) && ( getPluginId() != -2 ) ) 452 return 1; 453 454 return 0; 455 } 456 457 462 public java.lang.String toString() { 463 464 return strNickName; 465 } 466 } 467 468 | Popular Tags |