1 import whisper.PublicKey; 2 3 5 public final class Profile{ 6 public String JabberID=new String (""); 7 public String FullName=new String (""); 8 public String NickName=new String (""); 9 public String Birthday=new String (""); 10 public String Email=new String (""); 11 public String HomePage=new String (""); 12 public String Phone=new String (""); 13 public String Street=new String (""); 14 public String City=new String (""); 15 public String State=new String (""); 16 public String PostCode=new String (""); 17 public String Country=new String (""); 18 public String Company=new String (""); 19 public String Department=new String (""); 20 public String Position=new String (""); 21 public String Role=new String (""); 22 public String Notes=new String (""); 23 24 25 public Profile(){ 26 } 28 29 32 public Profile(VCard vcard) throws IllegalArgumentException { 33 setFromVCard(vcard); 34 } 35 36 public void setFromVCard(VCard vcard){ 37 JabberID=n2e(vcard.getJabberID()); 38 if(vcard.getFullName()!=null){ 39 FullName=vcard.getFullName(); 40 } 41 else{ 42 FullName=n2e(vcard.getName_Prefix()+" "+vcard.getName_Given())+" "+n2e(vcard.getName_Family()+" "+vcard.getName_Suffix()); 43 } 44 NickName=n2e(vcard.getNickname()); 45 Birthday=n2e(vcard.getBirthday()); 46 if(vcard.getEmail_Work()!=null){ 47 Email=vcard.getEmail_Work(); 48 } 49 else{ 50 Email=n2e(vcard.getEmail_Home()); 51 } 52 HomePage=n2e(vcard.getURL()); 53 if(vcard.getTel_Work_Voice()!=null){ 54 Phone=vcard.getTel_Work_Voice(); 55 } 56 else{ 57 Phone=n2e(vcard.getTel_Home_Voice()); 58 } 59 if(vcard.hasWorkAddress()){ 60 Street=n2e(vcard.getAddress_Work_House())+n2e(vcard.getAddress_Work_Street()); 61 City=n2e(vcard.getAddress_Work_Locality()); 62 State=n2e(vcard.getAddress_Work_Region()); 63 PostCode=n2e(vcard.getAddress_Work_PCode()); 64 Country=n2e(vcard.getAddress_Work_Country()); 65 } 66 else{ 67 if(vcard.hasHomeAddress()){ 68 Street=n2e(vcard.getAddress_Home_House())+n2e(vcard.getAddress_Home_Street()); 69 City=n2e(vcard.getAddress_Home_Locality()); 70 State=n2e(vcard.getAddress_Home_Region()); 71 PostCode=n2e(vcard.getAddress_Home_PCode()); 72 Country=n2e(vcard.getAddress_Home_Country()); 73 } 74 } 75 Company=n2e(vcard.getOrg_Name()); 76 Department=n2e(vcard.getOrg_Unit()); 77 Position=n2e(vcard.getTitle()); 78 Role=n2e(vcard.getRole()); 79 Notes=n2e(vcard.getDescription()); 80 } 81 82 public VCard asVcard(){ 83 VCard v=new VCard(); 84 v.setFullName(t(FullName)); 85 v.setNickname(t(NickName)); 86 v.setBirthday(t(Birthday)); 87 v.setURL(t(HomePage)); 88 v.setAddress_Work_Street(t(Street)); 89 v.setAddress_Work_Locality(t(City)); 90 v.setAddress_Work_Region(t(State)); 91 v.setAddress_Work_PCode(t(PostCode)); 92 v.setAddress_Work_Country(t(Country)); 93 v.setTel_Work_Voice(t(Phone)); 94 v.setEmail_Work(t(Email)); 95 v.setDescription(t(Notes)); 96 v.setJabberID(t(JabberID)); 97 v.setOrg_Name(t(Company)); 98 v.setOrg_Unit(t(Department)); 99 v.setRole(t(Role)); 100 v.setTitle(t(Position)); 101 return v; 102 } 103 104 private String t(String s){ 105 if(s==null){return null;} 106 if(s.equals("")){ 107 return null; 108 } 109 return s; 110 } 111 112 private String n2e(String s){ 113 if(s!=null){ 114 return s; 115 } 116 return (""); 117 } 118 } | Popular Tags |