BrightSide Workbench Full Report + Source Code
org.turro.vcard.ContactToVCard Class Reference

Public Member Functions

 ContactToVCard (Contact contact)
 
VCard getVCard (Properties properties)
 
String generateAndroidVCard (Properties properties) throws VCardException, IOException
 

Detailed Description

Author
Lluis TurrĂ³ Cutiller lluis.nosp@m.@tur.nosp@m.ro.or.nosp@m.g

Definition at line 38 of file ContactToVCard.java.

Constructor & Destructor Documentation

◆ ContactToVCard()

org.turro.vcard.ContactToVCard.ContactToVCard ( Contact  contact)

Definition at line 43 of file ContactToVCard.java.

43  {
44  this.contact = contact;
45  }

Member Function Documentation

◆ generateAndroidVCard()

String org.turro.vcard.ContactToVCard.generateAndroidVCard ( Properties  properties) throws VCardException, IOException

Definition at line 54 of file ContactToVCard.java.

54  {
55  VCardComposer composer = new VCardComposer();
56 
57  ContactStruct contact1 = new ContactStruct();
58  contact1.name = contact.getName();
59  contact1.addExtension(new PropertyNode("ID", contact.getId(), null, null, null, null, null));
60  contact1.addExtension(new PropertyNode("GID", contact.getGlobalIdentifier(), null, null, null, null, null));
61 
62  for(Address address : contact.getAddresses()) {
63  if(!address.isEmpty()) {
64  contact1.addContactmethod(Contacts.KIND_POSTAL, Contacts.ContactMethods.TYPE_CUSTOM,
65  getAddressString(address), address.getDescription(),
66  "Fiscal".equals(address.getDescription()));
67  }
68  }
69 
70  for(Connector connector : contact.getConnectors()) {
71  if(!connector.isEmpty()) {
72  if(matchValue(properties, "Telephone", "Telephone", connector.getDescription())) {
73  contact1.addPhone(Contacts.Phones.TYPE_WORK, connector.getValue(), null, true);
74  } else if(matchValue(properties, "Cell", "Cell", connector.getDescription())) {
75  contact1.addPhone(Contacts.Phones.TYPE_MOBILE, connector.getValue(), null, false);
76  } else if(matchValue(properties, "Fax", "Fax", connector.getDescription())) {
77  contact1.addPhone(Contacts.Phones.TYPE_FAX_WORK, connector.getValue(), null, false);
78  } else if(matchValue(properties, "Email", "Email", connector.getDescription())) {
79  contact1.addContactmethod(Contacts.KIND_EMAIL, Contacts.ContactMethods.TYPE_WORK, connector.getValue(), null, true);
80  } else if(matchValue(properties, "Source", "Web", connector.getDescription())) {
81  contact1.addWeb(connector.getValue());
82  }
83  }
84  }
85 
86  for(BusinessRelation relation : contact.getBusinessSet()) {
87  if(!relation.isEmpty()) {
88  contact1.addOrganization(Contacts.KIND_ORGANIZATION, relation.getBusiness().getName(), relation.getFormattedDescription(), false);
89  }
90  }
91 
92  for(Comment comment : contact.getComments()) {
93  if(!comment.isEmpty()) {
94  contact1.notes.add(comment.getComment());
95  }
96  }
97 
98  StringWriter writer = new StringWriter();
99  String vcardString = composer.createVCard(contact1, VCardComposer.VERSION_VCARD30_INT);
100  writer.write(vcardString);
101  writer.write("\n");
102  writer.close();
103  return writer.toString();
104  }
Set< Comment > getComments()
Definition: Contact.java:415
Set< Address > getAddresses()
Definition: Contact.java:355
Set< Connector > getConnectors()
Definition: Contact.java:367
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getVCard()

VCard org.turro.vcard.ContactToVCard.getVCard ( Properties  properties)

Definition at line 47 of file ContactToVCard.java.

47  {
48  if(vCard == null) {
49  generateVCard(properties);
50  }
51  return vCard;
52  }
Here is the caller graph for this function:

The documentation for this class was generated from the following file: