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   * @since v3.0
12   */
13  public class EmptyDownloadableResource extends AbstractDownloadableResource
14  {
15      private static final InputStream EMPTY_INPUT_STREAM = new EmptyInputStream();
16  
17      private static class EmptyInputStream extends InputStream
18      {
19          @Override
20          public int read() throws IOException
21          {
22              return -1;
23          }
24      }
25  
26      /**
27       * @param plugin used to find last modified date and plugin key
28       * @param resourceLocation used to get content type for the resource
29       */
30      public EmptyDownloadableResource(Plugin plugin, ResourceLocation resourceLocation)
31      {
32          super(plugin, resourceLocation, null);
33      }
34  
35      @Override
36      protected InputStream getResourceAsStream(String resourceLocation)
37      {
38          return EMPTY_INPUT_STREAM;
39      }
40  }