Class DocumentLoader
java.lang.Object
com.github.jsonldjava.core.DocumentLoader
Resolves URLs to
RemoteDocuments. Subclass this class to change the
behaviour of loadDocument to suit your purposes.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringIdentifies a system property that can be set to "true" in order to disallow remote context loading.private org.apache.http.impl.client.CloseableHttpClient -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddInjectedDoc(String url, String doc) Avoid resolving a document by instead using the given serialised representation.org.apache.http.impl.client.CloseableHttpClientGet theCloseableHttpClientwhich will be used by this DocumentLoader to resolve HTTP and HTTPS resources.loadDocument(String url) Loads the URL if possible, returning it as a RemoteDocument.voidsetHttpClient(org.apache.http.impl.client.CloseableHttpClient nextHttpClient) Call this method to override the default CloseableHttpClient provided by JsonUtils.getDefaultHttpClient.
-
Field Details
-
m_injectedDocs
-
DISALLOW_REMOTE_CONTEXT_LOADING
Identifies a system property that can be set to "true" in order to disallow remote context loading.- See Also:
-
httpClient
private volatile org.apache.http.impl.client.CloseableHttpClient httpClient
-
-
Constructor Details
-
DocumentLoader
public DocumentLoader()
-
-
Method Details
-
addInjectedDoc
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
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 theCloseableHttpClientwhich will be used by this DocumentLoader to resolve HTTP and HTTPS resources.- Returns:
- The
CloseableHttpClientwhich 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- TheCloseableHttpClientto replace the default with.
-