package com.avg.zaap.crashlibrary.offline.publisher.metadata;

import com.avg.zaap.crashlibrary.ReportData;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.Reader;
import java.util.List;

/**
 * This interface denotes the common behavior for the crash meta data reader factories.
 * <p/>
 * Created by marek.osvald on 29.7.2016.
 */
public interface ICrashMetadataReaderFactory {

    /**
     * Returns an instance of crash metadata helper.
     *
     * @return an instance of crash metadata helper
     */
    ICrashMetadataHelper getCrashMetadataHelper();

    /**
     * Returns an instance of file for given directory and file name.
     *
     * @param directory file parent directory
     * @param fileName  file name
     * @return an instance of file for given directory and file name
     */
    File openFile(File directory, String fileName);

    /**
     * Returns a new instance of crash report data structure.
     *
     * @return a new instance of crash report data structure
     */
    ReportData getReportData();

    /**
     * Returns an instance of reader for given file.
     *
     * @param file file to retrieve the reader for
     * @return an instance of reader for given file
     * @throws FileNotFoundException provided that given file does not exists
     */
    Reader getReader(File file) throws FileNotFoundException;

    /**
     * Returns an instance of buffered reader for given reader.
     *
     * @param reader reader to decorate with a buffered reader
     * @return an instance of buffered reader for given reader
     */
    BufferedReader getBufferedReader(Reader reader);

    /**
     * Returns a list instance with given initial capacity.
     *
     * @param capacity initial capacity
     * @return a list instance with given initial capacity
     */
    List<String> getList(int capacity);

}
