package com.avg.zaap.crashlibrary.publish.cap.http;

import com.avg.zaap.crashlibrary.publish.cap.http.boundary.BoundaryGenerator;
import com.avg.zaap.crashlibrary.publish.cap.http.boundary.IBoundaryGenerator;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.io.Writer;
import java.net.MalformedURLException;
import java.net.URL;

/**
 * This class serves as the CAP request default dependency factory.
 * <p/>
 * Created by marek.osvald on 7.6.2016.
 */
public class CapRequestFactory implements ICapRequestFactory {

    @Override
    public IBoundaryGenerator getBoundaryGenerator() {
        return new BoundaryGenerator();
    }

    @Override
    public URL openURL(String url) throws MalformedURLException {
        return new URL(url);
    }

    @Override
    public Writer getPrintWriter(OutputStream outputStream) {
        return new PrintWriter(outputStream);
    }

    @Override
    public File openFile(String filePath) {
        return new File(filePath);
    }

    @Override
    public InputStreamReader getInputStreamReader(InputStream inputStream) {
        return new InputStreamReader(inputStream);
    }

    @Override
    public FileInputStream getFileInputStream(File file) throws FileNotFoundException {
        return new FileInputStream(file);
    }

    @Override
    public Writer getStringWriter() {
        return new StringWriter();
    }

}
