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

net.sf.aguacate.connector.spi.ConnectorHttpGet Maven / Gradle / Ivy

There is a newer version: 0.10.9
Show newest version
package net.sf.aguacate.connector.spi;

import java.io.IOException;
import java.net.URI;
import java.util.Collection;
import java.util.Map;

import net.sf.aguacate.util.codec.bridge.CodecBridge;
import net.sf.aguacate.util.codec.bridge.CodecCoupling;
import net.sf.aguacate.util.http.bridge.HttpCoupling;

public class ConnectorHttpGet extends ConnectorHttp {

	public ConnectorHttpGet(String base, String expectedMimeType, Map headers,
			Collection parameters) {
		super(false, base, expectedMimeType, headers, parameters);
	}

	@Override
	protected CodecBridge getCodecBridge(String mimeType) {
		CodecBridge jsonCodec = CodecCoupling.jsonCodecBridge();
		if (jsonCodec.support(mimeType)) {
			return jsonCodec;
		} else {
			throw new IllegalArgumentException(mimeType);
		}
	}

	@Override
	protected Object execute0(URI uri, Map headers, CodecBridge codec)
			throws IOException {
		return HttpCoupling.defaultInstance().readFromGet(uri, headers, codec);
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy