View Javadoc

1   package com.atlassian.plugin;
2   
3   import java.io.*;
4   
5   /**
6    * An XML plugin artifact that is just the atlassian-plugin.xml file
7    *
8    * @since 2.1.0
9    */
10  public class XmlPluginArtifact implements PluginArtifact
11  {
12      private final File xmlFile;
13  
14      public XmlPluginArtifact(File xmlFile)
15      {
16          this.xmlFile = xmlFile;
17      }
18  
19      /**
20       * Always returns false, since it doesn't make sense for an XML artifact
21       */
22      public boolean doesResourceExist(String name)
23      {
24          return false;
25      }
26  
27      /**
28       * Always returns null, since it doesn't make sense for an XML artifact
29       */
30      public InputStream getResourceAsStream(String name) throws PluginParseException
31      {
32          return null;
33      }
34  
35      public String getName()
36      {
37          return xmlFile.getName();
38      }
39  
40      /**
41       * @return a buffered file input stream of the file on disk. This input stream
42       * is not resettable.
43       */
44      public InputStream getInputStream()
45      {
46          try
47          {
48              return new BufferedInputStream(new FileInputStream(xmlFile));
49          }
50          catch (FileNotFoundException e)
51          {
52              throw new RuntimeException("Could not find XML file for eading: " + xmlFile, e);
53          }
54      }
55  
56      public File toFile()
57      {
58          return xmlFile;
59      }
60  
61      @Override
62      public boolean containsJavaExecutableCode()
63      {
64          return false;
65      }
66  }