View Javadoc
1   package com.github.celldynamics.quimp.plugin.engine;
2   
3   import java.io.File;
4   
5   import com.github.celldynamics.quimp.plugin.IQuimpCorePlugin;
6   
7   /**
8    * Store basic plugin properties read from jar file and jar instance.
9    * 
10   * @author p.baniukiewicz
11   *
12   */
13  public class PluginProperties {
14    private File file; // handle to file on disk
15    private int type; // type of plugin
16    private String className; // name of plugin class
17    private String version; // version returned from plugin
18    private IQuimpCorePlugin ref = null; // reference of plugin - loaded jar
19  
20    /**
21     * Version getter.
22     * 
23     * @return the version
24     */
25    public String getVersion() {
26      return version;
27    }
28  
29    /**
30     * getClassName.
31     * 
32     * @return the className
33     */
34    public String getClassName() {
35      return className;
36    }
37  
38    /**
39     * Construct plugin properties object.
40     * 
41     * @param file Reference to plugin file
42     * @param className Qualified class name of plugin
43     * @param type Type of plugin returned by IQuimpPlugin.setup() method
44     * @param version Version of plugin returned from IQuimpPlugin.getVersion() method
45     */
46    public PluginProperties(final File file, final String className, int type, final String version) {
47      this.file = file;
48      this.type = type;
49      this.className = className;
50      if (version == null) {
51        this.version = "";
52      } else {
53        this.version = version;
54      }
55    }
56  
57    /**
58     * File getter.
59     * 
60     * @return File object
61     */
62    public File getFile() {
63      return file;
64    }
65  
66    /**
67     * Type getter.
68     * 
69     * @return Type of File plugin
70     */
71    public int getType() {
72      return type;
73    }
74  
75    @Override
76    public String toString() {
77      return "ClassName: " + className + " path: " + file + " type: " + type + " ver: " + version;
78    }
79  
80    /**
81     * Return reference of loaded plugin or null if plugin is not used.
82     * 
83     * @return reference or null
84     */
85    public IQuimpCorePlugin getRef() {
86      return ref;
87    }
88  
89    /**
90     * Set reference to plugin. If plugin is used at any frame reference is remembered here and
91     * returned on demand for each other frame.
92     * 
93     * @param ref plugin reference returned by PluginFactory.getPluginInstance
94     */
95    public void setRef(IQuimpCorePlugin ref) {
96      this.ref = ref;
97    }
98  }