File Source: Plugin.java
/*
P/P * Method: com.dmdirc.plugins.Plugin__static_init
*/
1 /*
2 * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 * SOFTWARE.
21 */
22
23 package com.dmdirc.plugins;
24
25 import com.dmdirc.config.prefs.PreferencesManager;
26 import com.dmdirc.config.prefs.validator.ValidationResponse;
27
28 /**
29 * Defines the standard methods that should be implemented by plugins.
30 */
/*
P/P * Method: int compareTo(Object)
*
* Preconditions:
* x0 != null
*
* Postconditions:
* init'ed(return_value)
*/
31 public abstract class Plugin implements Comparable<Plugin> {
32 /** Domain name for the settings in this plugin. */
33 private String myDomain = "plugin-unknown";
34
35 /** Has the domain been set? */
36 private boolean domainSet = false;
37
38 /**
39 * Called when the plugin is constructed.
40 */
/*
P/P * Method: void com.dmdirc.plugins.Plugin()
*
* Postconditions:
* this.domainSet == 0
* this.myDomain == &"plugin-unknown"
*/
41 public Plugin() { }
42
43 /**
44 * Called by PluginInfo to set the domain name.
45 * This can only be called once, all other attempts will be ignored.
46 *
47 * @param newDomain Domain name for plugin settings
48 */
49 public void setDomain(final String newDomain) {
/*
P/P * Method: void setDomain(String)
*
* Preconditions:
* init'ed(this.domainSet)
*
* Postconditions:
* this.domainSet == 1
* this.myDomain == One-of{old this.myDomain, newDomain}
*
* Test Vectors:
* this.domainSet: {1}, {0}
*/
50 if (!domainSet) {
51 domainSet = true;
52 myDomain = newDomain;
53 domainUpdated();
54 }
55 }
56
57 /**
58 * Get the domain name settings for this plugin should be stored in.
59 *
60 * @return Domain name for plugin settings
61 */
62 public String getDomain() {
/*
P/P * Method: String getDomain()
*
* Preconditions:
* init'ed(this.myDomain)
*
* Postconditions:
* return_value == this.myDomain
* init'ed(return_value)
*/
63 return myDomain;
64 }
65
66 /**
67 * Called when the domain for plugin settings has been set.
68 * This will only be called once (either when the plugin is loading, or when
69 * its config is being shown).
70 */
/*
P/P * Method: void domainUpdated()
*/
71 public void domainUpdated() { }
72
73 /**
74 * Called when the plugin is loaded.
75 */
76 public abstract void onLoad();
77
78 /**
79 * Check any further Prerequisites for this plugin to load that can not be
80 * checked using metainfo.
81 *
82 * @return ValidationResponse detailign if the plugin passes any extra checks
83 * that plugin.info can't handle
84 */
/*
P/P * Method: ValidationResponse checkPrerequisites()
*
* Postconditions:
* return_value == &new ValidationResponse(checkPrerequisites#1)
* new ValidationResponse(checkPrerequisites#1) num objects == 1
*/
85 public ValidationResponse checkPrerequisites() { return new ValidationResponse(); }
86
87 /**
88 * Called when the plugin is about to be unloaded.
89 */
90 public abstract void onUnload();
91
92 /**
93 * Called to allow plugins to add their configuration options to the manager.
94 *
95 * @param manager The preferences manager that configuration options
96 * need to be added to.
97 */
/*
P/P * Method: void showConfig(PreferencesManager)
*/
98 public void showConfig(final PreferencesManager manager) { }
99
100 /**
101 * Compares this object with the specified object for order.
102 * Returns a negative integer, zero, or a positive integer as per String.compareTo();
103 *
104 * @param o Object to compare to
105 * @return a negative integer, zero, or a positive integer.
106 */
107 @Override
108 public int compareTo(final Plugin o) {
/*
P/P * Method: int compareTo(Plugin)
*
* Preconditions:
* o != null
*
* Postconditions:
* init'ed(return_value)
*/
109 return toString().compareTo(o.toString());
110 }
111 }
SofCheck Inspector Build Version : 2.17854
| Plugin.java |
2009-Jun-25 01:54:24 |
| Plugin.class |
2009-Sep-02 17:04:13 |