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 HttpClient
httpClient
private static java.util.logging.Logger
LOGGER
static int
MAX_REDIRECTIONS
private int
maxRedirections
private static java.lang.String
PLUS_JSON
private DocumentResolver
resolver
-
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.String
getAcceptHeader()
static java.lang.String
getAcceptHeader(java.util.Collection<java.lang.String> profiles)
Document
loadDocument(java.net.URI uri, DocumentLoaderOptions options)
Retrieve a remote document.private Document
resolve(MediaType type, java.net.URI targetUri, java.net.URI contextUrl, HttpResponse response)
void
setFallbackContentType(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:DocumentLoader
Retrieve a remote document.- Specified by:
loadDocument
in interfaceDocumentLoader
- Parameters:
uri
- of the remote document to fetchoptions
- to set the behavior of the loader- Returns:
Document
representing 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:
JsonLdError
java.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
-
-