public abstract class AbstractOEmbedProvider extends Object implements OEmbedProvider
| Modifier and Type | Field and Description |
|---|---|
protected okhttp3.OkHttpClient |
httpClient |
protected com.fasterxml.jackson.databind.ObjectMapper |
mapper |
| Constructor and Description |
|---|
AbstractOEmbedProvider()
Makes an instance using default HTTP client and Jackson ObjectMapper.
|
AbstractOEmbedProvider(okhttp3.OkHttpClient httpClient,
com.fasterxml.jackson.databind.ObjectMapper mapper)
Makes an instance using supplied httpClient and mapper.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
checkEmbedForErrors(OEmbed e)
Some oEmbed providers return errors in response fields instead of using
HTTP response error codes.
|
<T extends OEmbed> |
get(String url,
Class<T> embedClass)
Makes HTTP request expecting oEmbed response.
|
protected Class<? extends BasicOEmbed> |
getEmbedClass(ProviderEndpoint endpoint)
Get's
BasicOEmbed subclass to use for mapping response. |
protected abstract ProviderEndpoint |
getProviderEndpointFor(String url)
Returns ProviderEndpoint to use for given resource url.
|
protected void |
prepareRequestURI(okhttp3.HttpUrl.Builder builder,
String url,
Integer... maxSize)
Prepares URL prior to making request.
|
OEmbed |
resolve(String url,
Integer... maxSize)
Resolves oEmbed data from passed resource URL.
|
OEmbed |
resolve(String url,
ProviderEndpoint provider,
Integer... maxSize)
Makes oEmebed request for url using provider.
|
protected final okhttp3.OkHttpClient httpClient
protected final com.fasterxml.jackson.databind.ObjectMapper mapper
public AbstractOEmbedProvider()
public AbstractOEmbedProvider(okhttp3.OkHttpClient httpClient,
com.fasterxml.jackson.databind.ObjectMapper mapper)
httpClient - OkHTTP clientmapper - Jackson ObjectMapper instancepublic <T extends OEmbed> T get(String url, Class<T> embedClass) throws IOException
T - oEmbed subclass to map data onurl - oEmbed URLembedClass - OEmbed implementation classIOException - if HTTP request or mapping failpublic OEmbed resolve(String url, Integer... maxSize) throws IOException
OEmbedProviderresolve in interface OEmbedProviderurl - resource URLmaxSize - optional width and height in pxIOException - if oEmbed data can't be resolvedOEmbedProvider.resolve(java.lang.String,
java.lang.Integer[])public OEmbed resolve(String url, ProviderEndpoint provider, Integer... maxSize) throws IOException
url - url to embedprovider - oEmbed provider endpointmaxSize - max width and heightIOException - if oEmbed data can't be fetchedprotected void checkEmbedForErrors(OEmbed e) throws IOException
e - returned instanceIOException - if error is found on oEmbed instanceprotected Class<? extends BasicOEmbed> getEmbedClass(ProviderEndpoint endpoint)
BasicOEmbed subclass to use for mapping response.endpoint - endpoint used for requestprotected abstract ProviderEndpoint getProviderEndpointFor(String url)
url - resource URLCopyright © 2017. All rights reserved.