/*
 * CodecFactory.java
 *
 * Created on March 14, 2003, 9:34 PM
 */

package com.jscape.inet.util;

import java.util.Locale;

/**
 * Factory class for looking up a Codec based on it's name.
 */
public class CodecFactory {

    private CodecFactory() {
    }


    /**
     * Gets codec based on name.
     * Valid codec names are base64, quoted-printable and uuencode
     *
     * @param name the coded name
     *
     * @return a Codec
     *
     * @see com.jscape.inet.util.Codec
     */
    public static Codec getCodec(String name) {

        // check if null
        if (name == null) {
            return null;
        }
        String c = name.toLowerCase(Locale.ENGLISH);
        Codec codec = null;
        if (c.equals("base64")) {
            codec = new Base64();
        } else if (c.equals("quoted-printable")) {
            codec = new QuotedPrintable();
        } else if (c.equals("uuencode")) {
            codec = new Uuencode();
        } else if (c.equals("b")) {
            codec = new Base64();
        } else if (c.equals("q")) {
            codec = new QuotedPrintable();
        }
        return codec;
    }

}
