*******
VCard4J
*******
Description:
------------
vCard4J is a Java toolkit to manipulate vCards.
vCard4J contains a set of Java API to manipulate vCard entries in Java.
It contains a parser to instantiate these objects from a vCard file.
vCard4J relies on XSLTs for the rendering (vCard, xHTML, XML, ...) since
the internal model is DOM based. vCard4J also includes a 'type' compiler
to add custom vCard types to the library. All the types are defined in a
XML file, making it easy to add custom types.
Dependencies:
-------------
vCard4J requires the following packages:
- JDK 1.4 (java.util.regex, new RuntimeExceptions...)
- Xalan 2.4.1 (http://xml.apache.org/dist/xalan-j/)
Code license: GNU Lesser General Public License
-------------
Last release: 2003
-------------
Site: http://vcard4j.sourceforge.net/
-----
Code Example:
-------------
public class MainJava {
public static void main(String args[]) {
try {
DomParser parser = new DomParser();
Document document = new DocumentImpl();
parser.parse(new FileInputStream(args[0]), document);
AddressBook addressBook = new AddressBook(document);
for (Iterator vcards = addressBook.getVCards();
vcards.hasNext(); ) {
VCard vcard = (VCard) vcards.next();
FN fn = (FN) vcard.getTypes("FN").next();
System.out.println(fn.get() + ":");
for (Iterator tels=vcard.getTypes("TEL");
tels.hasNext(); ) {
TEL tel = (TEL) tels.next();
if (((TEL.Parameters)
tel.getParameters()).containsTYPE(TEL.Parameters.TYPE_CELL)) {
System.out.println(" Tel (gsm): " + tel.get());
} else {
System.out.println(" Tel : " + tel.get());
}
}
for (Iterator emails=vcard.getTypes("EMAIL");
emails.hasNext(); ) {
EMAIL email = (EMAIL) emails.next();
System.out.println(" E-Mail : " + email.get());
}
System.out.println();
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
Tested by be and it seems to work fine.
------------------------------------------------------------------------------------------------------------------------------
*************
android-vcard
*************
Description:
------------
Java library for manipulating vCard files.
The source code was extracted from the Google Android project.
Dependencies:
-------------
commons-codec-1.3.jar
Code license: Apache License 2.0
-------------
Last release: 2009
-------------
Site: http://code.google.com/p/android-vcard/
-----
Code Example:
-------------
public class ReadExample {
//run the WriteExample first or provide your own "example.vcard"
public static void main(String[] args) throws Exception {
VCardParser parser = new VCardParser();
VDataBuilder builder = new VDataBuilder();
String file = "example.vcard";
//read whole file to string
BufferedReader reader = new BufferedReader(new InputStreamReader(
new FileInputStream(file), "UTF-8"));
String vcardString = "";
String line;
while ((line = reader.readLine()) != null) {
vcardString += line + "\n";
}
reader.close();
//parse the string
boolean parsed = parser.parse(vcardString, "UTF-8", builder);
if (!parsed) {
throw new VCardException("Could not parse vCard file: " + file);
}
//get all parsed contacts
List<VNode> pimContacts = builder.vNodeList;
//do something for all the contacts
for (VNode contact : pimContacts) {
ArrayList<PropertyNode> props = contact.propList;
//contact name - FN property
String name = null;
for (PropertyNode prop : props) {
if ("FN".equals(prop.propName)) {
name = prop.propValue;
//we have the name now
break;
}
}
//similarly for other properties (N, ORG, TEL, etc)
//...
System.out.println("Found contact: " + name);
}
}
}
I haven't tested yet this library.
_______________________________________________
sipx-dev mailing list [email protected]
List Archive: http://list.sipfoundry.org/archive/sipx-dev
Unsubscribe: http://list.sipfoundry.org/mailman/listinfo/sipx-dev
sipXecs IP PBX -- http://www.sipfoundry.org/