Package com.github.jsonldjava.core
Class DocumentLoader
- java.lang.Object
-
- com.github.jsonldjava.core.DocumentLoader
-
public class DocumentLoader extends java.lang.Object
Resolves URLs toRemoteDocument
s. Subclass this class to change the behaviour of loadDocument to suit your purposes.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
DISALLOW_REMOTE_CONTEXT_LOADING
Identifies a system property that can be set to "true" in order to disallow remote context loading.private org.apache.http.impl.client.CloseableHttpClient
httpClient
private java.util.Map<java.lang.String,java.lang.Object>
m_injectedDocs
-
Constructor Summary
Constructors Constructor Description DocumentLoader()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DocumentLoader
addInjectedDoc(java.lang.String url, java.lang.String doc)
Avoid resolving a document by instead using the given serialised representation.org.apache.http.impl.client.CloseableHttpClient
getHttpClient()
Get theCloseableHttpClient
which will be used by this DocumentLoader to resolve HTTP and HTTPS resources.RemoteDocument
loadDocument(java.lang.String url)
Loads the URL if possible, returning it as a RemoteDocument.void
setHttpClient(org.apache.http.impl.client.CloseableHttpClient nextHttpClient)
Call this method to override the default CloseableHttpClient provided by JsonUtils.getDefaultHttpClient.
-
-
-
Field Detail
-
m_injectedDocs
private final java.util.Map<java.lang.String,java.lang.Object> m_injectedDocs
-
DISALLOW_REMOTE_CONTEXT_LOADING
public static final java.lang.String DISALLOW_REMOTE_CONTEXT_LOADING
Identifies a system property that can be set to "true" in order to disallow remote context loading.- See Also:
- Constant Field Values
-
httpClient
private volatile org.apache.http.impl.client.CloseableHttpClient httpClient
-
-
Method Detail
-
addInjectedDoc
public DocumentLoader addInjectedDoc(java.lang.String url, java.lang.String doc) throws JsonLdError
Avoid resolving a document by instead using the given serialised representation.- Parameters:
url
- The URL this document represents.doc
- The serialised document as a String- Returns:
- This object for fluent addition of other injected documents.
- Throws:
JsonLdError
- If loading of the document failed for any reason.
-
loadDocument
public RemoteDocument loadDocument(java.lang.String url) throws JsonLdError
Loads the URL if possible, returning it as a RemoteDocument.- Parameters:
url
- The URL to load- Returns:
- The resolved URL as a RemoteDocument
- Throws:
JsonLdError
- If there are errors loading or remote context loading has been disallowed.
-
getHttpClient
public org.apache.http.impl.client.CloseableHttpClient getHttpClient()
Get theCloseableHttpClient
which will be used by this DocumentLoader to resolve HTTP and HTTPS resources.- Returns:
- The
CloseableHttpClient
which this DocumentLoader uses.
-
setHttpClient
public void setHttpClient(org.apache.http.impl.client.CloseableHttpClient nextHttpClient)
Call this method to override the default CloseableHttpClient provided by JsonUtils.getDefaultHttpClient.- Parameters:
nextHttpClient
- TheCloseableHttpClient
to replace the default with.
-
-