Class MemoryURLConnectionFactory

java.lang.Object
org.faceless.publisher.resource.MemoryURLConnectionFactory
All Implemented Interfaces:
URLConnectionFactory

public class MemoryURLConnectionFactory extends Object implements URLConnectionFactory
A general purpose URLConnectionFactory which can be used to map particular URLs to a preloaded byte array, known as a "Blob" (after the same term in web browsers).

An instance of this can be used to override any URL - it can be added to the ReportFactory or a single Report by calling the getURLConnectionFactories() method on either class. If it is to override URLs that would be handled normally, eg "http" or "file" URLs, it should be put at the start of the list to ensure it has the highest-priority.


  MemoryURLConnectionFactory factory = new MemoryURLConnectionFactory();
  Map<URL2,AbstractBlob> map = factory.getMap();
  ByteBuffer data = ...;       // your data, from any source
  URL2 url = URL2.parse("https://example.com/foo");
  Blob blob = new Blob(url, MediaType.parse("text/html"), data, 0);
  map.put(blob.getURL(), blob);

  Report report = reportfactory.createReport();
  report.getURLConnectionFactories().add(0, myhandler);
  report.load(...);
 
  • Constructor Details

    • MemoryURLConnectionFactory

      public MemoryURLConnectionFactory()
      Create a new MemoryURLConnectionFactory
    • MemoryURLConnectionFactory

      public MemoryURLConnectionFactory(Map<? extends URL2,? extends AbstractBlob> map)
      Create a new MemoryURLConnectionFactory. The supplied map will be copied to the map returned by getMap()
      Parameters:
      map - the map to copy to the internal map.
  • Method Details