package org.atea.nlptools.macroniser.monogram.plugin;

import java.io.File;

/**
 * @author University of Waikato - Te Whare Wānanga o Waikato
 * @version 1.0
 * @since   2014-11-20 
 */
public class PluginManager implements IPlugin
{
    private File tmpdir;

    public PluginManager(File tmpdir) {
        this.tmpdir = tmpdir;
    }

    public File run(PluginConfiguration fileView)
        throws UnsupportedOperationException, Exception
    {
        IPlugin plugin = null;

        String fileType = fileView.getFileType().toLowerCase();
        switch (fileType) {
            case ".txt":
                plugin = new TxtPlugin(tmpdir);
                break;
            case ".docx":
                plugin = new DocxPlugin(tmpdir);
                break;
            case ".odt":
                plugin = new OdtPlugin(tmpdir);
                break;
            case ".pptx":
                plugin = new PptxPlugin(tmpdir);
                break;
            case ".xlsx":
                plugin = new XlsxPlugin(tmpdir);
                break;
            default:
                throw new UnsupportedOperationException("Not supported yet.");
        }

        return plugin.run(fileView);
    }
}
