All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.jayway.jsonpath.spi.HttpProviderFactory Maven / Gradle / Ivy

There is a newer version: 2.9.0
Show newest version
package com.jayway.jsonpath.spi;

import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;

/**
 * Created by IntelliJ IDEA.
 * User: kallestenflo
 * Date: 3/10/12
 * Time: 7:39 AM
 */
public abstract class HttpProviderFactory {

    public static HttpProviderFactory factory = new HttpProviderFactory() {
        @Override
        protected HttpProvider create() {
            return new HttpProvider() {
                @Override
                public InputStream get(URL url) throws IOException {
                    URLConnection connection = url.openConnection();
                    connection.setRequestProperty("Accept", "application/json");
                    return connection.getInputStream();
                }
            };
        }
    };

    public static HttpProvider getProvider(){
        return factory.create();
    }


    protected abstract HttpProvider create();
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy