Class DocumentLoader


  • public class DocumentLoader
    extends java.lang.Object
    Resolves URLs to RemoteDocuments. 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 the CloseableHttpClient 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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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
    • Constructor Detail

      • DocumentLoader

        public DocumentLoader()
    • 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 the CloseableHttpClient 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 - The CloseableHttpClient to replace the default with.