001/**
002 * pdbconverter - Convert Palm PDB files into more common formats
003 *
004 * Copyright (C) 2009 Richard "Shred" Körber
005 *   http://pdbconverter.shredzone.org
006 *
007 * This program is free software: you can redistribute it and/or modify
008 * it under the terms of the GNU General Public License as published by
009 * the Free Software Foundation, either version 3 of the License, or
010 * (at your option) any later version.
011 *
012 * This program is distributed in the hope that it will be useful,
013 * but WITHOUT ANY WARRANTY; without even the implied warranty of
014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
015 * GNU General Public License for more details.
016 *
017 * You should have received a copy of the GNU General Public License
018 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
019 */
020package org.shredzone.pdbconverter;
021
022import org.shredzone.pdbconverter.handler.AddressXmlHandler;
023import org.shredzone.pdbconverter.handler.ExportHandler;
024import org.shredzone.pdbconverter.handler.ICalendarHandler;
025import org.shredzone.pdbconverter.handler.MdbICalendarHandler;
026import org.shredzone.pdbconverter.handler.MemoXmlHandler;
027import org.shredzone.pdbconverter.handler.NotepadHandler;
028import org.shredzone.pdbconverter.handler.TodoXmlHandler;
029import org.shredzone.pdbconverter.handler.VCardHandler;
030import org.shredzone.pdbconverter.handler.ZipHandler;
031
032/**
033 * A register of all available {@link ExportHandler}.
034 *
035 * @author Richard "Shred" Körber
036 */
037public final class ConverterRegister {
038
039    private static final ExportHandler[] HANDLERS = {
040        new AddressXmlHandler(),
041        new ICalendarHandler(),
042        new MdbICalendarHandler(),
043        new MemoXmlHandler(),
044        new NotepadHandler(),
045        new TodoXmlHandler(),
046        new VCardHandler(),
047        new ZipHandler(),
048    };
049
050    /**
051     * Utility class cannot be constructed.
052     */
053    private ConverterRegister() {}
054
055    /**
056     * Gets all registered {@link ExportHandler}.
057     *
058     * @return Array of {@link ExportHandler}
059     */
060    public static ExportHandler[] getHandlers() {
061        return HANDLERS;
062    }
063
064    /**
065     * Finds the {@link ExportHandler} for the given converter name.
066     *
067     * @param name
068     *            Converter name
069     * @return {@link ExportHandler} or {@code null} if there is none.
070     */
071    public static ExportHandler findHandler(String name) {
072        for (ExportHandler handler : HANDLERS) {
073            if (handler.getName().equalsIgnoreCase(name)) {
074                return handler;
075            }
076        }
077        return null;
078    }
079
080}