Package no.hasmac.jsonld.loader
Class DefaultHttpLoader
- java.lang.Object
-
- no.hasmac.jsonld.loader.DefaultHttpLoader
-
- All Implemented Interfaces:
DocumentLoader
- Direct Known Subclasses:
HttpLoader
class DefaultHttpLoader extends java.lang.Object implements DocumentLoader
-
-
Field Summary
Fields Modifier and Type Field Description private HttpClienthttpClientprivate static java.util.logging.LoggerLOGGERstatic intMAX_REDIRECTIONSprivate intmaxRedirectionsprivate static java.lang.StringPLUS_JSONprivate DocumentResolverresolver
-
Constructor Summary
Constructors Constructor Description DefaultHttpLoader(HttpClient httpClient)DefaultHttpLoader(HttpClient httpClient, int maxRedirections)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static java.lang.StringgetAcceptHeader()static java.lang.StringgetAcceptHeader(java.util.Collection<java.lang.String> profiles)DocumentloadDocument(java.net.URI uri, DocumentLoaderOptions options)Retrieve a remote document.private Documentresolve(MediaType type, java.net.URI targetUri, java.net.URI contextUrl, HttpResponse response)voidsetFallbackContentType(MediaType fallbackContentType)Set fallback content-type used when received content-type is not supported.
-
-
-
Field Detail
-
LOGGER
private static final java.util.logging.Logger LOGGER
-
MAX_REDIRECTIONS
public static final int MAX_REDIRECTIONS
- See Also:
- Constant Field Values
-
PLUS_JSON
private static final java.lang.String PLUS_JSON
- See Also:
- Constant Field Values
-
maxRedirections
private final int maxRedirections
-
httpClient
private final HttpClient httpClient
-
resolver
private final DocumentResolver resolver
-
-
Constructor Detail
-
DefaultHttpLoader
public DefaultHttpLoader(HttpClient httpClient)
-
DefaultHttpLoader
public DefaultHttpLoader(HttpClient httpClient, int maxRedirections)
-
-
Method Detail
-
loadDocument
public Document loadDocument(java.net.URI uri, DocumentLoaderOptions options) throws JsonLdError
Description copied from interface:DocumentLoaderRetrieve a remote document.- Specified by:
loadDocumentin interfaceDocumentLoader- Parameters:
uri- of the remote document to fetchoptions- to set the behavior of the loader- Returns:
Documentrepresenting a remote document- Throws:
JsonLdError
-
getAcceptHeader
public static java.lang.String getAcceptHeader()
-
getAcceptHeader
public static java.lang.String getAcceptHeader(java.util.Collection<java.lang.String> profiles)
-
resolve
private Document resolve(MediaType type, java.net.URI targetUri, java.net.URI contextUrl, HttpResponse response) throws JsonLdError, java.io.IOException
- Throws:
JsonLdErrorjava.io.IOException
-
setFallbackContentType
public void setFallbackContentType(MediaType fallbackContentType)
Set fallback content-type used when received content-type is not supported. e.g.setFallbackContentType(MediaType.JSON_LD)- Parameters:
fallbackContentType- a content type that overrides unsupported received content-type
-
-