View Javadoc

1   package com.atlassian.plugin;
2   
3   import java.io.InputStream;
4   import java.io.File;
5   
6   /**
7    * Allows the retrieval of files and/or an input stream of a plugin artifact. Implementations
8    * must allow multiple calls to {@link #getInputStream()}.
9    *
10   * @see PluginController
11   * @since 2.0.0
12   */
13  public interface PluginArtifact
14  {
15      /**
16       * @return true if the resource exists in this artifact, otherwise false
17       * @since 2.2.0
18       */
19      boolean doesResourceExist(String name);
20  
21      /**
22       * @return an input stream of the resource specified inside the artifact.  Null if the resource cannot be found.
23       * @throws PluginParseException if the there was an exception retrieving the resource from the artifact
24       */
25      InputStream getResourceAsStream(String name) throws PluginParseException;
26  
27      /**
28       * @return the original name of the plugin artifact file. Typically used
29       * for persisting it to disk with a meaningful name.
30       */
31      String getName();
32  
33      /**
34       * @return an InputStream for the entire plugin artifact. Calling this
35       * multiple times will return a fresh input stream each time.
36       */
37      InputStream getInputStream();
38  
39      /**
40       * @return the artifact as a file, or its underlying file if it is already one
41       * @since 2.2.0
42       */
43      File toFile();
44  }