View Javadoc
1   package com.atlassian.plugin.servlet;
2   
3   import com.atlassian.plugin.Plugin;
4   import com.atlassian.plugin.elements.ResourceLocation;
5   
6   import java.io.IOException;
7   import java.io.InputStream;
8   
9   /**
10   * A DownloadableResource with no content
11   *
12   * @since v3.0
13   */
14  public class EmptyDownloadableResource extends AbstractDownloadableResource {
15      private static final InputStream EMPTY_INPUT_STREAM = new EmptyInputStream();
16  
17      private static class EmptyInputStream extends InputStream {
18          @Override
19          public int read() throws IOException {
20              return -1;
21          }
22      }
23  
24      /**
25       * @param plugin           used to find last modified date and plugin key
26       * @param resourceLocation used to get content type for the resource
27       */
28      public EmptyDownloadableResource(Plugin plugin, ResourceLocation resourceLocation) {
29          super(plugin, resourceLocation, null);
30      }
31  
32      @Override
33      protected InputStream getResourceAsStream(String resourceLocation) {
34          return EMPTY_INPUT_STREAM;
35      }
36  }