All Downloads are FREE. Search and download functionalities are using the official Maven repository.

it.cnr.iit.jscontact.tools.vcard.extensions.utils.VCardParser Maven / Gradle / Ivy

Go to download

Java tools for JSContact building, validation, serialization/deserialization and conversion from vCard 4.0 (RFC6350) and its transliterations, namely xCard (RFC6351) and jCard (RFC7095).

There is a newer version: 1.0.1
Show newest version
package it.cnr.iit.jscontact.tools.vcard.extensions.utils;

import ezvcard.Ezvcard;
import ezvcard.VCard;
import it.cnr.iit.jscontact.tools.vcard.extensions.io.scribe.ExtendedAddressScribe;
import it.cnr.iit.jscontact.tools.vcard.extensions.io.scribe.ExtendedStructuredNameScribe;

import java.io.File;
import java.io.IOException;
import java.io.Reader;
import java.util.List;

public class VCardParser {

    public static List parse(String str) {

        return Ezvcard.parse(str)
                      .caretDecoding(true)
                      .register(new ExtendedAddressScribe())
                      .register(new ExtendedStructuredNameScribe())
                      .all();
    }

    public static List parse(File file) throws IOException {

        return Ezvcard.parse(file)
                .caretDecoding(true)
                .register(new ExtendedAddressScribe())
                .register(new ExtendedStructuredNameScribe())
                .all();
    }

    public static List parse(Reader reader) throws IOException {

        return Ezvcard.parse(reader)
                .caretDecoding(true)
                .register(new ExtendedAddressScribe())
                .register(new ExtendedStructuredNameScribe())
                .all();
    }


    public static List parseJson(String str) {

        return Ezvcard.parseJson(str)
                .register(new ExtendedAddressScribe())
                .register(new ExtendedStructuredNameScribe())
                .all();
    }

    public static List parseJson(File file) throws IOException {

        return Ezvcard.parseJson(file)
                .register(new ExtendedAddressScribe())
                .register(new ExtendedStructuredNameScribe())
                .all();
    }

    public static List parseJson(Reader reader) throws IOException {

        return Ezvcard.parseJson(reader)
                .register(new ExtendedAddressScribe())
                .register(new ExtendedStructuredNameScribe())
                .all();
    }


    public static List parseXml(String str) {

        return Ezvcard.parseXml(str)
                .register(new ExtendedAddressScribe())
                .register(new ExtendedStructuredNameScribe())
                .all();
    }

    public static List parseXml(File file) throws IOException {

        return Ezvcard.parseXml(file)
                .register(new ExtendedAddressScribe())
                .register(new ExtendedStructuredNameScribe())
                .all();
    }

    public static List parseXml(Reader reader) throws IOException {

        return Ezvcard.parseXml(reader)
                .register(new ExtendedAddressScribe())
                .register(new ExtendedStructuredNameScribe())
                .all();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy