Plugin.java

Index Score
devplugin
TV-Browser

View: Reasons, Metrics, Source Code

These are the metrics that contribute to the Enerjy Score for this file, ranked by impact. So the metrics listed at the top influence the score to a greater extent that the metrics listed at the bottom.

MetricDescription
DOC_COMMENTNumber of javadoc comment lines
COMMENTSComment lines
DECL_COMMENTSComments in declarations
SIZESize of the file in bytes
FUNCTIONSNumber of function declarations
LINESNumber of lines in the source file
JAVA0173JAVA0173 Unused method parameter
JAVA0068JAVA0068 Modifiers not declared in recommended order
RETURNSNumber of return points from functions
INTERFACE_COMPLEXITYInterface complexity
BLOCKSNumber of blocks
JAVA0160JAVA0160 Method does not throw specified exception
CYCLOMATICCyclomatic complexity
JAVA0144JAVA0144 Line exceeds maximum M characters
PARAMSNumber of formal parameter declarations
EXITSProcedure exits
UNIQUE_OPERANDSNumber of unique operands
PROGRAM_VOCABHalstead program vocabulary
JAVA0034JAVA0034 Missing braces in if statement
EXEC_COMMENTSComments in executable code
WHITESPACENumber of whitespace lines
JAVA0117JAVA0117 Missing javadoc: method 'method'
JAVA0177JAVA0177 Variable declaration missing initializer
PROGRAM_VOLUMEHalstead program volume
JAVA0136JAVA0136 N methods defined in class (maximum: M)
JAVA0126JAVA0126 Method declares unchecked exception in throws
LOCLines of code
OPERATORSNumber of operators
LOOPSNumber of loops
JAVA0108JAVA0108 Incorrect javadoc: no @param tag for 'parameter'
UNIQUE_OPERATORSNumber of unique operators
JAVA0145JAVA0145 Tab character used in source file
PROGRAM_LENGTHHalstead program length
ELOCEffective lines of code
/* * TV-Browser * Copyright (C) 04-2003 Martin Oberhauser (darras@users.sourceforge.net) * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * CVS information: * $RCSfile$ * $Source$ * $Date: 2008-05-24 20:30:27 -0400 (Sat, 24 May 2008) $ * $Author: ds10 $ * $Revision: 4719 $ */ package devplugin; import tvbrowser.core.Settings; import tvbrowser.core.icontheme.IconLoader; import tvbrowser.core.plugin.PluginProxyManager; import tvdataservice.MutableChannelDayProgram; import util.exc.TvBrowserException; import util.ui.FixedSizeIcon; import util.ui.ImageUtilities; import javax.swing.AbstractAction; import javax.swing.Action; import javax.swing.Icon; import javax.swing.ImageIcon; import java.awt.Dimension; import java.awt.Frame; import java.awt.Window; import java.awt.event.ActionEvent; import java.io.BufferedInputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.util.Properties; import java.util.jar.JarFile; /** * Superclass for all Java-TV-Browser plugins. * <p> * To create a plugin do the following: * <ol> * <li>Create a class that extends this class and name its package equal to the * class name but with lowercase letters. * E.g. <code>myplugin.MyPlugin</code>.</li> * <li>Write your plugin code in that class.</li> * <li>Pack your plugin class including all needed ressources in a jar file * named equal to your class. E.g. <code>MyPlugin.jar</code>. * <li>Put the jar in the <code>plugin</code> directory of your TV-Browser * installation. * </ol> * * @author Martin Oberhauser * @author Til Schneider, www.murfman.de */ abstract public class Plugin implements Marker, ContextMenuIf, ProgramReceiveIf { /** * The name to use for the big icon (the 24x24 one for the toolbar) of the * button action. * * @see #getButtonAction() */ public static final String BIG_ICON = "BigIcon"; /** The name to use for disabling a menu part for * showing in ProgramInfo. * @since 2.6 */ public static final String DISABLED_ON_TASK_MENU = "DISABLED_ON_TASK_MENU"; /** * The waiting time for single click performing. * @since 2.7 */ public static final int SINGLE_CLICK_WAITING_TIME = 200; /** The localizer used by this class. */ private static final util.ui.Localizer mLocalizer = util.ui.Localizer.getLocalizerFor(Plugin.class ); /** The jar file of this plugin. May be used to load ressources. */ private JarFile mJarFile; private PluginTreeNode mRootNode; /** * The plugin manager. It's the plugin's connection to TV-Browser. * <p> * Every communication between TV-Browser and the plugin is either initiated * by TV-Browser or made by using the plugin manager. */ private static PluginManager mPluginManager; /** The parent frame. May be used for dialogs. */ private Frame mParentFrame; /** The cached icon to use for marking programs. */ private Icon mMarkIcon; /** * The old member for the parent frame. * <p> * Some old plugin may still directly access it. * * @deprecated Use method {@link #getParentFrame()} instead. */ protected Frame parent; /** * Called by the host-application to provide access to the plugin manager. * * @param manager The plugin manager the plugins should use. */ final public static void setPluginManager(PluginManager manager) { if (mPluginManager == null ) { mPluginManager = manager; } } /** * Use this method to call methods of the plugin manager. * <p> * The plugin manager is your connection to TV-Browser. Every communication * between TV-Browser and the plugin is either initiated by TV-Browser or made * by using the plugin manager. * * @return The plugin manager. */ final public static PluginManager getPluginManager() { return mPluginManager; } /** * Called by the host-application to provide the jar file. * * @param jarFile The jar file of this plugin. * @throws TvBrowserException If the given file is no jar file. */ final public void setJarFile(File jarFile) throws TvBrowserException { try { mJarFile = new JarFile(jarFile); } catch (java.io.IOException exc) { throw new TvBrowserException(getClass(), "error.1", "Setting file failed!\n({0})", exc); } } /** * Gets the jar file of this plugin. May be used to load ressources. * * @return The jar file of this plugin. */ final protected JarFile getJarFile() { return mJarFile; } /** * Gets the ID of this plugin. * * @return The ID of this plugin. */ final public String getId() { return getPluginManager().getJavaPluginId(this); } /** * Called by the host-application to provide the parent frame. * * @param parent The parent frame. */ final public void setParent(Frame parent) { this.mParentFrame = parent; this.parent=parent; } /** * Gets the parent frame. * <p> * The parent frame may be used for showing dialogs. * * @return The parent frame. */ final protected Frame getParentFrame() { return mParentFrame; } /** * Helper method that loads an ImageIcon from the plugin jar file and returns * it. * * @param fileName The name of the icon file. * @return The icon. */ final protected ImageIcon createImageIcon(String fileName) { return ImageUtilities.createImageIconFromJar(fileName, getClass()); } /** * Helper method that loads an ImageIcon from the file system and returns * it. * * @param fileName The name of the icon file. * @return The icon. * @since 2.3 */ final protected ImageIcon createImageIconForFileName(String fileName) { return ImageUtilities.createImageIconFromJar(fileName, null); } /** * Helper method that Loads an ImageIcon from the IconTheme * * @param category Category the Icon resists in * @param icon Icon to load (without extension) * @param size Size of the Icon * @return The Icon * @since 2.2 */ final public ImageIcon createImageIcon(String category, String icon, int size) { return getPluginManager().getIconFromTheme(this, category, icon, size); } /** * Helper method that Loads an ImageIcon from the IconTheme * * @param icon Icon to load * * @return The Icon * @since 2.2 */ final public ImageIcon createImageIcon(ThemeIcon icon) { return getPluginManager().getIconFromTheme(this, icon); } /** * Called by the host-application during start-up. * <p> * Override this method to load any objects from the file system. * * @param in The stream to read the objects from. * @throws IOException If reading failed. * @throws ClassNotFoundException If an object could not be casted correctly. * * @see #writeData(ObjectOutputStream) */ public void readData(ObjectInputStream in) throws IOException, ClassNotFoundException { } /** * Counterpart to loadData. Called when the application shuts down. * <p> * Override this method to store any objects to the file system. * ATTENTION: Don't use any logger, thread or access to Frames in this method. * * @param out The stream to write the objects to * @throws IOException If writing failed. * * @see #readData(ObjectInputStream) */ public void writeData(ObjectOutputStream out) throws IOException { } /** * Called by the host-application during start-up. * <p> * Override this method to load your plugins settings from the file system. * * @param settings The settings for this plugin (May be empty). */ public void loadSettings(Properties settings) { } /** * Called by the host-application during shut-down. * <p> * Override this method to store your plugins settings to the file system. * ATTENTION: Don't use any logger, thread or access to Frames in this method. * * @return The settings for this plugin or <code>null</code> if this plugin * does not need to save any settings. */ public Properties storeSettings() { return null; } /** * Gets the version of this plugin. * <p> * Override this to provide a check of the plugin * for the version to load from main plugins dir * or the user plugins dir. The plugin with the highest * version will be loaded. * * @return The version of this plugin. * @since 2.6 */ public static Version getVersion() { return new Version(0, 0); } /** * Gets the meta information about the plugin. * <p> * Override this method to provide information about your plugin. * * @return The meta information about the plugin. */ public PluginInfo getInfo() { String name = mLocalizer.msg( "unkown" ,"Unknown" ); String desc = mLocalizer.msg( "noDescription" ,"No description" ); String author = mLocalizer.msg( "noAuthor" ,"No author given" ); return new PluginInfo(name, desc, author, getVersion()); } /** * Gets whether the plugin supports receiving programs from other plugins. * <p> * Override this method and return <code>true</code>, if your plugin is able * to receive programs from other plugins. * * @return Whether the plugin supports receiving programs from other plugins. * @see #receivePrograms(Program[]) * @deprecated Since 2.5 Use {@link #canReceiveProgramsWithTarget()} instead. */ public boolean canReceivePrograms() { // Call the old and deprecated method return supportMultipleProgramExecution(); } /** * Receives a list of programs from another plugin. * <p> * Override this method to receive programs from other plugins. * * @param programArr The programs passed from the other plugin. * @see #canReceivePrograms() * @deprecated Since 2.5 Use {@link #receivePrograms(Program[],ProgramReceiveTarget)} instead. */ public void receivePrograms(Program[] programArr) { // Call the old and deprecated method execute(programArr); } /** * Gets the actions for the context menu of a program. * <p> * Override this method to provide context menu items for programs (e.g. in * the program table). If your plugin shows a context menu only for some * programs, but not for all, then you should explicitly return a non-<code>null</code> * menu for the example program. Otherwise your context menu will not be shown * in the settings dialog for the context menu order. * <p> * The following action values will be used: * <ul> * <li><code>Action.NAME</code>: The text for the context menu item.</li> * <li><code>Action.SMALL_ICON</code>: The icon for the context menu item. * Should be 16x16.</li> * </ul> * * @param program * The program the context menu will be shown for. * @return the actions this plugin provides for the given program or * <code>null</code> if the plugin does not provide this feature. * * @see #getProgramFromContextMenuActionEvent(ActionEvent) */ public ActionMenu getContextMenuActions(final Program program) { // Check whether the old and deprecated methods are used String contextMenuItemText = getContextMenuItemText(); if (contextMenuItemText != null) { // The old and deprecated methods are used -> create an action for them AbstractAction action = new AbstractAction() { public void actionPerformed(ActionEvent evt) { execute(program); } }; action.putValue(Action.NAME, contextMenuItemText); action.putValue(Action.SMALL_ICON, getMarkIcon()); //return new Action[] { action }; return new ActionMenu(action); } else { // This plugin supports no context menus return null; } } /** * Gets the Program from the ActionEvent that was passed to a context menu * action * <p> * NOTE: At the moment the Program is passed as ActionEvent source. Please * use this method to get the program and not directly the ActionEvent * source. Because in future versions of TV-Browser the Program may be * passed in another way!! * * @param evt The ActionEvent to get the Program from. * @return The Program from the ActionEvent. * * @see #getContextMenuActions(Program) */ protected final Program getProgramFromContextMenuActionEvent(ActionEvent evt) { return (Program) evt.getSource(); } /** * Gets the action to use for the main menu and the toolbar. * <p> * Override this method to provide a menu item in the main menu and a toolbar * button. * <p> * The following action values will be used: * <ul> * <li><code>Action.NAME</code>: The text for the main menu item and the * toolbar button.</li> * <li><code>Action.SHORT_DESCRIPTION</code>: The description for the button * action. Used as tooltip and for the status bar.</li> * <li><code>Action.SMALL_ICON</code>: The icon for the main menu item. Should * be 16x16.</li> * <li><code>BIG_ICON</code>: The icon for the toolbar button. Should be * 24x24.</li> * </ul> * * @return the action to use for the menu and the toolbar or <code>null</code> * if the plugin does not provide this feature. */ public ActionMenu getButtonAction() { // Check whether the old and deprecated methods are used String buttonText = getButtonText(); if (buttonText != null) { // The old and deprecated methods are used -> create an action for them AbstractAction action = new AbstractAction() { public void actionPerformed(ActionEvent evt) { execute(); } }; action.putValue(Action.NAME, buttonText); action.putValue(Action.SHORT_DESCRIPTION, getInfo().getDescription()); String iconFileName = getButtonIconName(); if (iconFileName != null) { Icon icon = ImageUtilities.createImageIconFromJar(iconFileName, getClass()); if (icon != null) { action.putValue(Action.SMALL_ICON, icon); action.putValue(BIG_ICON, new FixedSizeIcon(24, 24, icon)); } } return new ActionMenu(action); } else { // This plugin supports no button return null; } } /** * Gets the description text for the program table icons provided by this * Plugin. * <p> * Override this method if your plugin provides icons for the program table * (shown below the start time). The returned String will be shown in settings * dialog (german: Aussehen->Sendungsanzeige->Plugin-Icons). * * @return The description text for the program table icons or * <code>null</code> if the plugin does not provide this feature. * * @see #getProgramTableIcons(Program) */ public String getProgramTableIconText() { return null; } /** * Gets the icons this Plugin provides for the given program. These icons will * be shown in the program table under the start time. * <p> * Override this method to return the icons for the program table (shown below * the start time). * <p> * This method is only called, if the option to show program table icons for * this plugin is set in the options. * * @param program The programs to get the icons for. * @return The icons for the given program or <code>null</code> if the plugin * does not provide this feature. * * @see #getProgramTableIconText() */ public Icon[] getProgramTableIcons(Program program) { return null; } /** * Gets the SettingsTab object, which is added to the settings-window. * <p> * Override this method to provide a settings tab. The settings tab will be * shown in the settings dialog in the plugin section. * * @return the SettingsTab object or <code>null</code> if the plugin does not * provide this feature. */ public SettingsTab getSettingsTab() { return null; } /** * Gets the icon used for marking programs in the program table. * * @return the icon to use for marking programs in the program table. * * @see #getMarkIconName() */ public final Icon getMarkIcon() { if (mMarkIcon== null ) { ThemeIcon icon = getMarkIconFromTheme(); if (icon != null) { mMarkIcon = IconLoader.getInstance().getIconFromTheme(this, icon); } if (mMarkIcon == null) { String iconFileName = getMarkIconName(); if (iconFileName != null) { mMarkIcon = ImageUtilities.createImageIconFromJar(iconFileName, getClass()); } } } return mMarkIcon; } /** * Gets the icons used for marking programs in the program table. * * @return the icons to use for marking programs in the program table. * * @since 2.5 */ public final Icon[] getMarkIcons(Program p) { if(getMarkIcon() != null) return new Icon[] {getMarkIcon()}; Icon[] icon = getMarkIconsForProgram(p); if(icon == null) return new Icon[0]; else return icon; } /** * This gets the mark icons for a Program. * * Please cache the icons in the Plugin. * * @param p The Program to get the icons for. * @return The icons for the Program. * @since 2.5 */ public Icon[] getMarkIconsForProgram(Program p) { return null; } /** * This gets the ThemeIcon containg your mark icon. * * This Function uses the Icon-Theme-Function of the TV-Browser. For details see {@link PluginManager#getIconFromTheme(Plugin, String, String, int)} * * @return ThemeIcon that identifies the Icon in the Theme * @since 2.2 */ public ThemeIcon getMarkIconFromTheme() { return null; } /** * Gets the name of the file, containing your mark icon (in the jar-File). * Should be 16x16. * <p> * This icon is used for marking programs in the program table. * <p> * Override this method if your plugin is able to mark programs * * As an alternative you can use an Icon from the Icon-Theme using {@link #getMarkIconFromTheme()} * * @return the name of the file, containing your icon for the toolbar or * <code>null</code> if the plugin does not provide this feature. * * @see #getMarkIcon() * @see Program#mark(Plugin) * @see Program#unmark(Plugin) */ protected String getMarkIconName() { return null; } /** * This method is automatically called, when the TV data update is finished. * <p> * Override this method to react on this event. * * If you want to read data from the internet use this method to track if a * connection was established. * ATTENTION: If you do so take care of the TV-Browser start, at the start this * method mustn't use an internet connection. Use the method handleTvBrowserStartFinished() * to track if the TV-Browser start was finished before allowing access to the * internet in this method. * * @see #handleTvBrowserStartFinished() * @see #handleTvDataAdded(ChannelDayProgram) * @see #handleTvDataDeleted(ChannelDayProgram) * @see devplugin.Plugin#handleTvDataChanged() */ public void handleTvDataUpdateFinished() { // Call the old and deprecated method handleTvDataChanged(); } /** * This method is automatically called, when TV data was added. * (E.g. after an update). * <p> * The TV data can be modified by the plugin! * <p> * Override this method if you want to change/add data. * Don't do other things than changing/adding data, * use {@link #handleTvDataAdded(ChannelDayProgram)} istead. * * @param newProg The new ChannelDayProgram. * @see #handleTvDataDeleted(ChannelDayProgram) * @see #handleTvDataChanged() */ public void handleTvDataAdded(MutableChannelDayProgram newProg) { } /** * This method is automatically called, when TV data was added. * (E.g. after an update). * <p> * The TV data cannot be changed in here because the saving of * the data was allready done. * <p> * So use this method if you want to mark or do something else * than changing with the program. If you want to change/add data * use {@link #handleTvDataAdded(MutableChannelDayProgram)} instead. * * @param newProg The new ChannelDayProgram. * @see #handleTvDataDeleted(ChannelDayProgram) * @see #handleTvDataChanged() */ public void handleTvDataAdded(ChannelDayProgram newProg) { // Call the old and deprecated method handleTvDataChanged(newProg); } /** * This method is automatically called, when TV data was deleted. * (E.g. after an update). * <p> * Override this method to react on this event. * * @param oldProg The old ChannelDayProgram which was deleted. * @see #handleTvDataAdded(ChannelDayProgram) * @see #handleTvDataChanged() */ public void handleTvDataDeleted(ChannelDayProgram oldProg) { } // The old and deprecated methods /** * Gets whether the plugin supports execution of multiple programs. * * @return Whether the plugin supports execution of multiple programs. * * @see #execute(Program[]) * @deprecated Since 1.1. Use {@link #canReceivePrograms()} instead. */ public boolean supportMultipleProgramExecution() { return canReceiveProgramsWithTarget(); } /** * This method is invoked for multiple program execution. * * @param programArr The programs to execute this plugins with. * * @see #supportMultipleProgramExecution() * @deprecated Since 1.1. Use {@link #receivePrograms(Program[])} instead. */ public void execute(Program[] programArr) { if(canReceiveProgramsWithTarget()) receivePrograms(programArr, ProgramReceiveTarget.createDefaultTargetArrayForProgramReceiveIf(this)[0]); } /** * Gets the text to use for the context menu. * <p> * This method is called by the host-application to show the plugin in the * context menu. * <p> * Return <code>null</code> if your plugin does not provide this feature. * * @return the text to use for the context menu or <code>null</code> if the * plugin does not provide this feature. * * @deprecated Since 1.1. Use {@link #getContextMenuActions(Program)} instead. */ public String getContextMenuItemText() { return null; } /** * This method is invoked by the host-application if the user has choosen your * plugin from the context menu. * * @param program The program from whichs context menu the plugin was chosen. * * @deprecated Since 1.1. Use {@link #getContextMenuActions(Program)} instead. */ public void execute(Program program) { } /** * Gets the text to use for the main menu or the toolbar. * <p> * This method is called by the host-application to show the plugin in the * menu or in the toolbar. * * @return the text to use for the menu or the toolbar or <code>null</code> if * the plugin does not provide this feature. * * @deprecated Since 1.1. Use {@link #getButtonAction()} instead. */ protected String getButtonText() { return null; } /** * Returns the name of the file, containing your button icon (in the jar-File). * <p> * This icon is used for the toolbar and the menu. Return <code>null</code> * if your plugin does not provide this feature. * * @return the name of the file, containing your icon for the main menu and * the toolbar. * * @deprecated Since 1.1. Use {@link #getButtonAction()} instead. */ protected String getButtonIconName() { return null; } /** * This method is invoked by the host-application if the user has choosen your * plugin from the menu or the toolbar. * * @deprecated Since 1.1. Use {@link #getButtonAction()} instead. */ public void execute() { } /** * This method is automatically called, when the TV data update is finished. * <p> * Does by default nothing. * * @see #handleTvDataAdded(ChannelDayProgram) * @see #handleTvDataDeleted(ChannelDayProgram) * @deprecated Since 1.1. Use {@link #handleTvDataUpdateFinished()} instead. */ public void handleTvDataChanged() { } /** * This method is automatically called, when the TV data has changed. * (E.g. after an update). * <p> * The TV data may be modified by the plugin! * <p> * Does by default nothing. * * @param newProg The new ChannelDayProgram. * * @deprecated Since 0.9.7.2. Use * {@link #handleTvDataAdded(ChannelDayProgram)} instead. */ public void handleTvDataChanged(ChannelDayProgram newProg) { } /** * This method is automatically called immediatly before the plugin gets * activated. * * @since 1.1 */ public void onActivation() { } /** * This method is automatically called immediatly after deactivating * the plugin. * ATTENTION: Don't use any logger, thread or access to Frames in this method. * * @since 1.1 */ public void onDeactivation() { } /** * Signal whether this plugin participates in the plugin tree view or not. * @see #getRootNode() * @return true, if the programs of this plugin are handled by the plugin * tree view * @since 1.1 */ public boolean canUseProgramTree() { return false; } /** * This method is called when the TV-Browser start is finished. * @since 2.2 */ public void handleTvBrowserStartFinished() { } /** * Gets the root node of the plugin for the plugin tree. * @see #canUseProgramTree() * * @return The root node. */ public PluginTreeNode getRootNode() { if (mRootNode == null) { mRootNode = new PluginTreeNode(this); ObjectInputStream in; File f = new File(Settings.getUserSettingsDirName(),getId()+".node"); try { in = new ObjectInputStream(new BufferedInputStream(new FileInputStream(f), 0x2000)); mRootNode.load(in); in.close(); } catch (FileNotFoundException e) { // ignore } catch (Exception e) { util.exc.ErrorHandler.handle(mLocalizer.msg("error.couldNotReadFile","Reading file '{0}' failed.", f.getAbsolutePath()), e); } } return mRootNode; } /** * Saves the entries under the root node in a file. */ public void storeRootNode() { ObjectOutputStream out; File f = new File(Settings.getUserSettingsDirName(),getId()+".node"); try { out = new ObjectOutputStream(new FileOutputStream(f)); if (mRootNode != null) { mRootNode.store(out); } out.close(); } catch (IOException e) { util.exc.ErrorHandler.handle(mLocalizer.msg("error.couldNotWriteFile","Storing file '{0}' failed.", f.getAbsolutePath()), e); } } /** * Gets whether the ProgramReceiveIf supports receiving programs from other plugins with a special target. * * @return Whether the ProgramReceiveIf supports receiving programs from other plugins with a special target. * * @see #receivePrograms(Program[],ProgramReceiveTarget) * @since 2.5 */ public boolean canReceiveProgramsWithTarget() { return false; } /** * Receives a list of programs from another plugin with a target. * * @param programArr The programs passed from the other plugin. * @param receiveTarget The receive target of the programs. * * @see #canReceiveProgramsWithTarget() * @since 2.5 */ public boolean receivePrograms(Program[] programArr, ProgramReceiveTarget receiveTarget) { // check if this should call the old method if((receiveTarget == null || ProgramReceiveTarget.isDefaultProgramReceiveTargetForProgramReceiveIf(this,receiveTarget)) && canReceivePrograms()) { receivePrograms(programArr); return true; } return false; } /** * Receives a list of Strings from another plugin with a target. * * @param values The value array passed from the other plugin. * @param receiveTarget The receive target of the programs. * @return <code>True</code> if the value array was handled correct, * </code>false</code> otherwise. * * @see #canReceiveProgramsWithTarget() * @since 2.7 */ public boolean receiveValues(String[] values, ProgramReceiveTarget receiveTarget) { return false; } /** * Returns an array of receive target or <code>null</code> if there is no target * * @return The supported receive targets. * @see #canReceiveProgramsWithTarget() * @see #receivePrograms(Program[],ProgramReceiveTarget) * @since 2.5 */ public ProgramReceiveTarget[] getProgramReceiveTargets() { return ProgramReceiveTarget.createDefaultTargetArrayForProgramReceiveIf(this); } /** * Returns the available program filters that the plugin supports. * @since 2.5 * * @return The available program filters that the plugin supports or <code>null</code> if it supports no filter. */ public PluginsProgramFilter[] getAvailableFilter() { return null; } /** * Is used to track if a program filter be deleted. * Should be make sure only the plugin itself can delete program filters. * * @param programFilter The program filter to delete. * @return True if the program filter component can be deleted. */ public boolean isAllowedToDeleteProgramFilter(PluginsProgramFilter programFilter) { return false; } public String toString() { return getInfo().getName(); } /** * Returns the available plugins filter component classes. * <br> * ATTENTON: Use return <code>(Class<? extends PluginsFilterComponent>[]) new Class[] {MyFilterComponent1.class,MyFilterComponent2.class};</code> * because the creation of a class array with generic type didn't work. * * @return The available plugins filter components classes or <code>null</code> if no plugins filter components are supported. * @since 2.5 */ public Class<? extends PluginsFilterComponent>[] getAvailableFilterComponentClasses() { return null; } /** * Gets the mark priority for the given program that this Plugin uses. * <p> * The mark priority can be {@link Program#NO_MARK_PRIORITY}, {@link Program#MIN_MARK_PRIORITY}, {@link Program#LOWER_MEDIUM_MARK_PRIORITY}, * {@link Program#MEDIUM_MARK_PRIORITY}, {@link Program#HIGHER_MEDIUM_MARK_PRIORITY} or * {@link Program#MAX_MARK_PRIORITY}. * <p> * @param p The program to get the mark prioriy for. * @return The mark priority for the given program for this plugin. * @since 2.5.1 */ public int getMarkPriorityForProgram(Program p) { return Settings.propProgramPanelUsedDefaultMarkPriority.getInt(); } /** * Says the plugin proxy manager to store the settings and data of this plugin. * <p> * @return <code>True</code> if the settings could be saved successfully. * @since 2.5.3 */ protected final boolean saveMe() { return PluginProxyManager.getInstance().saveSettings(PluginProxyManager.getInstance().getActivatedPluginForId(getId())); } /** * Sets the window position and size for the given window from remembered values for that id. * @param windowId The relative id of the window. The ID only needs to unique for this plugin. * @param window The window to layout. * * @since 2.7 */ public final void layoutWindow(String windowId, Window window) { layoutWindow(windowId, window, null); } /** * Sets the window position and size for the given window from remembered values for that id. * @param windowId The relative id of the window. The ID only needs to unique for this plugin. * @param window The window to layout. * @param defaultSize The default size for the window. * * @since 2.7 */ public final void layoutWindow(String windowId, Window window, Dimension defaultSize) { Settings.layoutWindow(getId() + "." + windowId, window, defaultSize); } /** * If this plugin can rate programs, this interface makes it possible to offer this ratings * to other plugins. You can get all ProgramRatingIfs of all plugins using {@link PluginManager#getAllProgramRatingIfs()} * * The plugin can return more than one ratingif, e.g. average ratings, user rating ... * * @return the RatingIfs of this plugin * @since 2.7 */ public ProgramRatingIf[] getRatingInterfaces() { return null; } }

The table below shows all metrics for Plugin.java.

MetricValueDescription
BLOCKS85.00Number of blocks
BLOCK_COMMENT25.00Number of block comment lines
COMMENTS657.00Comment lines
COMMENT_DENSITY 2.95Comment density
COMPARISONS20.00Number of comparison operators
CYCLOMATIC85.00Cyclomatic complexity
DECL_COMMENTS73.00Comments in declarations
DOC_COMMENT618.00Number of javadoc comment lines
ELOC223.00Effective lines of code
EXEC_COMMENTS13.00Comments in executable code
EXITS53.00Procedure exits
FUNCTIONS64.00Number of function declarations
HALSTEAD_DIFFICULTY49.52Halstead difficulty
HALSTEAD_EFFORT 0.00Halstead effort
INTERFACE_COMPLEXITY107.00Interface complexity
JAVA0001 0.00JAVA0001 Package name does not contain only lower case letters
JAVA0002 1.00JAVA0002 Package name does not begin with a top level domain name or country code
JAVA0003 0.00JAVA0003 Minimize use of on-demand (.*) imports
JAVA0004 0.00JAVA0004 Unnecessary import from java.lang
JAVA0005 1.00JAVA0005 Imports not in specified order
JAVA0006 0.00JAVA0006 Empty finally block
JAVA0007 0.00JAVA0007 Should not declare public field
JAVA0008 0.00JAVA0008 Empty catch block
JAVA0009 0.00JAVA0009 Protected member in final class
JAVA0010 0.00JAVA0010 Non-instantiable class does not contain a non-private static member
JAVA0011 1.00JAVA0011 Abstract class does not contain an abstract method
JAVA0012 0.00JAVA0012 Non-constructor method with same name as declaring class
JAVA0013 0.00JAVA0013 Non-blank final field is not static
JAVA0014 0.00JAVA0014 Class with only static members has non-private constructor
JAVA0015 0.00JAVA0015 Package class contains public nested type
JAVA0016 0.00JAVA0016 Abstract class contains public constructor
JAVA0017 0.00JAVA0017 Class name does not have required form
JAVA0018 0.00JAVA0018 Method name does not have required form
JAVA0019 0.00JAVA0019 Interface name does not have required form
JAVA0020 0.00JAVA0020 Field name does not have required form
JAVA0021 0.00JAVA0021 Interface method name does not have required form
JAVA0022 0.00JAVA0022 Static final field name does not have required form
JAVA0023 0.00JAVA0023 Empty finalize method
JAVA0024 0.00JAVA0024 Empty class
JAVA0025 0.00JAVA0025 Method override is empty
JAVA0026 0.00JAVA0026 Finalize method with parameters
JAVA0029 0.00JAVA0029 Private method not used
JAVA0030 0.00JAVA0030 Private field not used
JAVA0031 0.00JAVA0031 Case statement not properly closed
JAVA0032 0.00JAVA0032 Switch statement missing default
JAVA0033 0.00JAVA0033 default: not last case in switch statement
JAVA0034 4.00JAVA0034 Missing braces in if statement
JAVA0035 0.00JAVA0035 Missing braces in for statement
JAVA0036 0.00JAVA0036 Missing braces in while statement
JAVA0038 0.00JAVA0038 Non-case label in switch statement
JAVA0039 0.00JAVA0039 Break statement with label
JAVA0040 0.00JAVA0040 Switch statement contains N cases (maximum: M)
JAVA0041 0.00JAVA0041 Nested synchronized block
JAVA0042 0.00JAVA0042 Empty synchronized statement
JAVA0043 0.00JAVA0043 Inner class does not use outer class
JAVA0044 0.00JAVA0044 Serializable class with no instance variables
JAVA0045 0.00JAVA0045 Serializable class with only transient fields
JAVA0046 0.00JAVA0046 Name of class not derived from Exception ends with 'Exception'
JAVA0047 0.00JAVA0047 Serializable class derives from invalid base class
JAVA0048 0.00JAVA0048 Name of class derived from Exception does not end with 'Exception'
JAVA0049 0.00JAVA0049 Nested block at depth N (maximum: M)
JAVA0050 0.00JAVA0050 Class derives from java.lang.Error
JAVA0051 0.00JAVA0051 Class derives from java.lang.RuntimeException
JAVA0052 0.00JAVA0052 Class derives from java.lang.Throwable
JAVA0053 0.00JAVA0053 Unused label
JAVA0054 0.00JAVA0054 Inheritance depth N exceeds maximum M
JAVA0055 0.00JAVA0055 Class should be interface
JAVA0056 0.00JAVA0056 Unnecessary abstract modifier for interface or annotation
JAVA0057 0.00JAVA0057 Unnecessary default constructor
JAVA0058 0.00JAVA0058 Constructor calls super()
JAVA0059 0.00JAVA0059 Method override only calls super()
JAVA0061 0.00JAVA0061 Inaccessible member in anonymous class
JAVA0062 0.00JAVA0062 Public class missing public member or protected constructor
JAVA0063 0.00JAVA0063 Identifier name should not contain '$'
JAVA0064 0.00JAVA0064 N variations of identifier name (maximum: M)
JAVA0065 0.00JAVA0065 Unnecessary final modifier for method in final class
JAVA0066 0.00JAVA0066 Unnecessary modifier for interface nested type
JAVA0067 0.00JAVA0067 Array descriptor on identifier name
JAVA006812.00JAVA0068 Modifiers not declared in recommended order
JAVA0071 0.00JAVA0071 Strings compared with ==
JAVA0073 0.00JAVA0073 Integer division in floating-point context
JAVA0074 0.00JAVA0074 Use of Object.notify()
JAVA0075 0.00JAVA0075 Method parameter hides field
JAVA0076 2.00JAVA0076 Use of magic number
JAVA0077 0.00JAVA0077 Private field not used in declaring class
JAVA0078 0.00JAVA0078 Floating point values compared with ==
JAVA0079 0.00JAVA0079 Use of instance to reference static member
JAVA0080 0.00JAVA0080 Import declaration not used
JAVA0081 0.00JAVA0081 Boolean literal in comparison
JAVA0082 0.00JAVA0082 Unnecessary widening cast
JAVA0083 0.00JAVA0083 Unnecessary instanceof test
JAVA0084 0.00JAVA0084 Should use compound assignment operator
JAVA0085 0.00JAVA0085 Use of sun.* class
JAVA0087 0.00JAVA0087 Use of Thread.sleep()
JAVA0089 0.00JAVA0089 Use of restricted package
JAVA0092 0.00JAVA0092 Use of restricted type
JAVA0093 0.00JAVA0093 Redundant assignment
JAVA0094 0.00JAVA0094 Field hides a superclass field
JAVA0095 0.00JAVA0095 Uninitialized private field
JAVA0096 0.00JAVA0096 Field in nested class hides outer field
JAVA0098 0.00JAVA0098 Minimize use of implicit field initializers
JAVA0100 0.00JAVA0100 Class contains N non-final fields (maximum: M)
JAVA0101 0.00JAVA0101 Unnecessary modifier for field in interface
JAVA0102 0.00JAVA0102 Last statement in finalize() not super.finalize()
JAVA0103 0.00JAVA0103 Explicit call to finalize()
JAVA0104 0.00JAVA0104 finalize() only calls super.finalize()
JAVA0105 0.00JAVA0105 Duplicate import declaration
JAVA0106 0.00JAVA0106 Unnecessary import from current package
JAVA0108 0.00JAVA0108 Incorrect javadoc: no @param tag for 'parameter'
JAVA0109 0.00JAVA0109 Incorrect javadoc: no parameter 'parameter'
JAVA0110 1.00JAVA0110 Incorrect javadoc: no @return tag
JAVA0111 0.00JAVA0111 Incorrect javadoc: @return tag for void method
JAVA0112 0.00JAVA0112 Incorrect javadoc: no exception 'exception' in throws
JAVA0113 0.00JAVA0113 Incorrect javadoc: no @author tag
JAVA0114 1.00JAVA0114 Incorrect javadoc: no @version tag
JAVA0115 0.00JAVA0115 Incorrect javadoc: no @throws or @exception tag for 'exception'
JAVA0116 0.00JAVA0116 Missing javadoc: field 'field'
JAVA0117 0.00JAVA0117 Missing javadoc: method 'method'
JAVA0118 0.00JAVA0118 Missing javadoc: type 'type'
JAVA0119 0.00JAVA0119 Control variable changed within body of for loop
JAVA0123 0.00JAVA0123 Use all three components of for loop
JAVA0125 0.00JAVA0125 Continue statement with label
JAVA0126 0.00JAVA0126 Method declares unchecked exception in throws
JAVA0128 0.00JAVA0128 Public constructor in non-public class
JAVA0130 0.00JAVA0130 Non-static method does not use instance fields
JAVA0131 0.00JAVA0131 Compatible method does not override base
JAVA0132 1.00JAVA0132 Method overload with compatible signature
JAVA0133 0.00JAVA0133 Non-synchronized method overrides synchronized method
JAVA0135 0.00JAVA0135 Only one of Object.equals and Object.hashCode defined: missing 'method'
JAVA0136 1.00JAVA0136 N methods defined in class (maximum: M)
JAVA0137 0.00JAVA0137 Non-abstract class missing constructor
JAVA0138 0.00JAVA0138 N parameters defined for method (maximum: M)
JAVA0139 0.00JAVA0139 Definition of main other than public static void main(java.lang.String[])
JAVA0141 0.00JAVA0141 Unnecessary modifier for method in interface
JAVA0143 0.00JAVA0143 Synchronized method
JAVA0144 4.00JAVA0144 Line exceeds maximum M characters
JAVA0145 0.00JAVA0145 Tab character used in source file
JAVA0150 0.00JAVA0150 java.lang.Error (or subclass) thrown
JAVA0153 0.00JAVA0153 Inefficient conversion of integer to string
JAVA0159 0.00JAVA0159 Inefficient conversion of string to integer
JAVA0160 3.00JAVA0160 Method does not throw specified exception
JAVA0161 0.00JAVA0161 Conditional wait() not in loop
JAVA0163 0.00JAVA0163 Empty statement
JAVA0165 0.00JAVA0165 Conflicting return statement in finally block
JAVA0166 1.00JAVA0166 Generic exception caught
JAVA0167 0.00JAVA0167 ThreadDeath not rethrown
JAVA0169 0.00JAVA0169 Unnecessary catch block: exception 'exception'
JAVA0170 0.00JAVA0170 Caught exception not derived from java.lang.Exception
JAVA0171 0.00JAVA0171 Unused local variable
JAVA017310.00JAVA0173 Unused method parameter
JAVA0174 0.00JAVA0174 Assigned local variable never used
JAVA0175 0.00JAVA0175 Successive assignment to variable
JAVA0176 0.00JAVA0176 Local variable name does not have required form
JAVA0177 2.00JAVA0177 Variable declaration missing initializer
JAVA0179 0.00JAVA0179 Local variable hides visible field
JAVA0233 0.00JAVA0233 Definition of serialVersionUID other than 'private static final long serialVersionUID'
JAVA0234 0.00JAVA0234 Class is Serializable but does not define serialVersionUID
JAVA0235 0.00JAVA0235 Class defines serialVersionUID but does not implement Serializable
JAVA0236 0.00JAVA0236 Attempt to clone an object which does not implement Cloneable
JAVA0237 0.00JAVA0237 Class implements Cloneable but does not have public clone method
JAVA0238 0.00JAVA0238 Clone method does not call super.clone()
JAVA0239 0.00JAVA0239 Class declares 'readObject' or 'writeObject' but does not implement Serializable
JAVA0240 0.00JAVA0240 Serializable class which declares readObject or writeObject but not both
JAVA0241 0.00JAVA0241 'readObject' or 'writeObject' should be declared private in Serializable class
JAVA0242 0.00JAVA0242 Transient field in non-Serializable class
JAVA0243 0.00JAVA0243 'readResolve' or 'writeReplace' should be declared private or protected
JAVA0244 0.00JAVA0244 Field or method name in subclass differs only by case from inherited field or method
JAVA0245 0.00JAVA0245 JUnit TestCase with non-trivial constructor
JAVA0246 0.00JAVA0246 JUnit assertXXX statement missing message parameter
JAVA0247 0.00JAVA0247 JUnit 'setUp()' and 'tearDown()' should call super method
JAVA0248 0.00JAVA0248 JUnit method 'setUp' or 'tearDown' with incorrect signature
JAVA0249 0.00JAVA0249 JUnit TestCase 'suite()' should be declared static
JAVA0250 0.00JAVA0250 JUnit TestCase declares testXXX method with incorrect signature
JAVA0251 0.00JAVA0251 Use '%n' for line breaks in printf/format for platform independence
JAVA0252 0.00JAVA0252 'enum' is a Java 1.5 reserved word
JAVA0253 0.00JAVA0253 Not all enum constants consumed in switch statement
JAVA0254 0.00JAVA0254 Use enhanced for loop construct instead of Iterator
JAVA0255 0.00JAVA0255 Result of method invocation not used
JAVA0256 0.00JAVA0256 Assignment of external collection/array to field
JAVA0257 0.00JAVA0257 Use of 'Constant Interface' anti-pattern
JAVA0258 0.00JAVA0258 Implement Iterable for foreach compatibility
JAVA0259 0.00JAVA0259 Return of collection/array field
JAVA0260 0.00JAVA0260 Use 'enum' instead of Enumerated Type pattern
JAVA0261 0.00JAVA0261 Use specialized Enum collection types
JAVA0262 0.00JAVA0262 Use of char in integer context
JAVA0263 0.00JAVA0263 Long literal ends with 'l' instead of 'L'
JAVA0264 0.00JAVA0264 Integer math in long context - check for overflow
JAVA0265 0.00JAVA0265 Use of Throwable.printStackTrace()
JAVA0266 0.00JAVA0266 Use of System.out
JAVA0267 0.00JAVA0267 Use of System.err
JAVA0269 0.00JAVA0269 Contents of StringBuffer never used
JAVA0270 0.00JAVA0270 Use Java 5.0 enhanced for loop construct to iterate over all elements in an array
JAVA0271 0.00JAVA0271 Minimize use of on-demand (.*) static imports
JAVA0272 0.00JAVA0272 Thread.run() called
JAVA0273 0.00JAVA0273 Non-final derivative of Thread calls start() in constructor
JAVA0274 0.00JAVA0274 Serializable class has a synchronized readObject()
JAVA0275 0.00JAVA0275 Serializable class has a synchronized writeObject() and no other synchronized methods
JAVA0276 0.00JAVA0276 Unnecessary use of String constructor
JAVA0277 0.00JAVA0277 Iterator.next() implementation does not throw NoSuchElementException
JAVA0278 0.00JAVA0278 Unnecessary use of Boolean constructor
JAVA0279 0.00JAVA0279 Serialization method readObject or readObjectNoData calls an overridable method
JAVA0280 0.00JAVA0280 IllegalMonitorStateException caught
JAVA0281 0.00JAVA0281 Iterator.next() not called in loop
JAVA0282 0.00JAVA0282 Call to Iterator.next() in loop which does not test Iterator.hasNext()
JAVA0283 0.00JAVA0283 Control variable not updated in loop body
JAVA0284 0.00JAVA0284 Explicit garbage collection
JAVA0285 0.00JAVA0285 Dereference of potentially null variable
JAVA0286 0.00JAVA0286 Dereference of null variable
JAVA0287 0.00JAVA0287 Unnecessary null check
JAVA0288 0.00JAVA0288 Inconsistent null check
LINES1085.00Number of lines in the source file
LINE_COMMENT14.00Number of line comments
LOC304.00Lines of code
LOGICAL_LINES128.00Number of statements
LOOPS 0.00Number of loops
NEST_DEPTH 4.00Maximum nesting depth
OPERANDS565.00Number of operands
OPERATORS1224.00Number of operators
PARAMS37.00Number of formal parameter declarations
PROGRAM_LENGTH1789.00Halstead program length
PROGRAM_VOCAB295.00Halstead program vocabulary
PROGRAM_VOLUME 0.00Halstead program volume
RETURNS70.00Number of return points from functions
SIZE33371.00Size of the file in bytes
UNIQUE_OPERANDS251.00Number of unique operands
UNIQUE_OPERATORS44.00Number of unique operators
WHITESPACE124.00Number of whitespace lines