Package com.nardoz.restopengov.standalone.utils

Source Code of com.nardoz.restopengov.standalone.utils.FileReader

package com.nardoz.restopengov.standalone.utils;

import com.nardoz.restopengov.standalone.models.RemoteFile;
import com.nardoz.restopengov.utils.CSVFetcher;
import com.nardoz.restopengov.utils.ICSVFetcherResult;
import com.nardoz.restopengov.utils.IFormatReader;

public class FileReader {

    private static String[] handledFormats = new String[] {
        "csv"
    };

    public static IFormatReader read(RemoteFile file, ICSVFetcherResult callback) throws Exception {

        if(file.format.toLowerCase().matches("csv")) {
            return new CSVFetcher(callback);
        } else {
            throw new Exception("FileReader: Unhandled format " + file.format + " for file " + file.url);
        }

    }

    public static boolean handles(String format) {

        boolean result = false;

        for(String fmt : handledFormats) {
            if(format.equals(fmt)) {
                result = true;
                break;
            }
        }

        return result;
    }

}
TOP

Related Classes of com.nardoz.restopengov.standalone.utils.FileReader

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.