BaseFrame.java

Index Score
org.furthurnet.furi
Furthurnet

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
EXEC_COMMENTSComments in executable code
LINE_COMMENTNumber of line comments
SIZESize of the file in bytes
EXITSProcedure exits
OPERANDSNumber of operands
LOGICAL_LINESNumber of statements
PROGRAM_LENGTHHalstead program length
UNIQUE_OPERANDSNumber of unique operands
OPERATORSNumber of operators
JAVA0177JAVA0177 Variable declaration missing initializer
LOCLines of code
LINESNumber of lines in the source file
PROGRAM_VOCABHalstead program vocabulary
JAVA0034JAVA0034 Missing braces in if statement
ELOCEffective lines of code
BLOCKSNumber of blocks
CYCLOMATICCyclomatic complexity
COMPARISONSNumber of comparison operators
COMMENTSComment lines
JAVA0173JAVA0173 Unused method parameter
JAVA0082JAVA0082 Unnecessary widening cast
JAVA0117JAVA0117 Missing javadoc: method 'method'
JAVA0166JAVA0166 Generic exception caught
DOC_COMMENTNumber of javadoc comment lines
PROGRAM_VOLUMEHalstead program volume
UNIQUE_OPERATORSNumber of unique operators
JAVA0136JAVA0136 N methods defined in class (maximum: M)
JAVA0266JAVA0266 Use of System.out
JAVA0126JAVA0126 Method declares unchecked exception in throws
JAVA0110JAVA0110 Incorrect javadoc: no @return tag
WHITESPACENumber of whitespace lines
LOOPSNumber of loops
DECL_COMMENTSComments in declarations
NEST_DEPTHMaximum nesting depth
RETURNSNumber of return points from functions
JAVA0145JAVA0145 Tab character used in source file
/* * FURI - A distributed peer-to-peer file sharing system. * Copyright (C) 2000 William W. Wong * williamw@jps.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 */ package org.furthurnet.furi; import java.applet.Applet; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Component; import java.awt.Dimension; import java.awt.Insets; import java.awt.Point; import java.awt.Rectangle; import java.awt.Toolkit; import java.awt.Window; import java.awt.event.ActionEvent; import java.lang.reflect.Constructor; import java.util.Enumeration; import java.util.Hashtable; import java.util.StringTokenizer; import java.util.Vector; import javax.swing.AbstractButton; import javax.swing.Action; import javax.swing.Box; import javax.swing.ButtonGroup; import javax.swing.ImageIcon; import javax.swing.JCheckBoxMenuItem; import javax.swing.JComponent; import javax.swing.JFrame; import javax.swing.JMenu; import javax.swing.JMenuBar; import javax.swing.JMenuItem; import javax.swing.JOptionPane; import javax.swing.JPopupMenu; import javax.swing.JRadioButtonMenuItem; import javax.swing.JToggleButton; import javax.swing.JToolBar; import javax.swing.KeyStroke; import javax.swing.SwingConstants; import javax.swing.SwingUtilities; import javax.swing.UIManager; /** * The class BaseFrame provides a generic framework to support menu, toolbar, * popup menu, and action. An action can have multiple visual components * associated with it, such as a menu item, a popup menu item, or a toolbar * button. When these visual components are pressed, the action is fired. * BaseFrame has distilled all the definition of menu and toolbar and action * into the TriLife.resource file. This allows extreme flexibility and * extendibility, enabling on-the-fly adding of new operations and new * menu items. * */ public class BaseFrame extends JFrame { private static Vector sFrames = new Vector(); private Applet mApplet = null; private String mFrameType; protected Hashtable mActions; protected Hashtable mAccelerators = new Hashtable(); /** * Default constructor. Disabled. */ protected BaseFrame() { // Disabled. } /** * Constructor. Sets up the default Look and Feel, the title, * the window icon, the menu bar, the toolbar, and load the actions. * * @param frameType The frame type name used to look up the menu, * toolbar, and actions from the resource file. */ public BaseFrame(String frameType, Applet applet) { super(); // Add to frame list. sFrames.addElement(this); mFrameType = frameType; mApplet = applet; mActions = new Hashtable(); // Set up frame window title, background color, and icon. setTitle(Res.getStr(mFrameType + ".Title")); setBackground(Color.lightGray); ImageIcon frameIcon = Res.getIcon(mFrameType + ".Icon"); if (frameIcon != null) { setIconImage(frameIcon.getImage()); } // Set up menu and toolbar JMenuBar menubar = createMenubar(); setJMenuBar(menubar); JToolBar toolbar = createToolbar(); if (toolbar != null) getContentPane().add(BorderLayout.NORTH, toolbar); } public void dispose() { // Remove from frame list. sFrames.removeElement(this); super.dispose(); } public static void setupLookAndFeel() { // Retry if unsuccessful while (true) { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); break; } catch (Exception e) { int response = JOptionPane.showConfirmDialog(null, "Failed loading System Look and Feel. Retry?", "Look and Feel Error", JOptionPane.YES_NO_OPTION); if (response != JOptionPane.YES_OPTION) { System.exit(1); } } } } public void resetLookAndFeel() { SwingUtilities.updateComponentTreeUI(this); refreshAllActions(); } /** * Load an action class and create an action object from it. Cache * the action object in memory for later invocation. * * @param itemName The menu item name prefix that denotes the * action related resource. It is concatenated * with ".ActionID" to load the action ID of the * action, with ".Label" to load the menu item * label of the action, with ".Icon" to load the * icon of the action for toolbar button, with * ".ActionClass" to load the action class. * * @return The action object, or null if something goes wrong. * */ private ActionBase loadAction(String itemName) { // Get the action related resources. String actionID = Res.getStr(itemName + ".ActionID"); String label = Res.getStr(itemName + ".Label"); ImageIcon icon = Res.getIcon(itemName + ".Icon"); String actionClassName = Res.getStr(itemName + ".ActionClass"); if (actionID == null) { //System.out.println("Missing " + itemName + ".ActionID"); return null; } if (actionClassName == null) { //System.out.println("Missing " + itemName + ".ActionClass"); return null; } if (mActions.get(actionID) != null) { // System.out.println("Duplicated actionID: " + actionID + " class: " + actionClassName); return (ActionBase)mActions.get(actionID); } try { // Set up the parameters for calling the action class's constructor. Class[] classParams = new Class[3]; Object[] params = new Object[3]; classParams[0] = this.getClass().getSuperclass(); classParams[1] = Class.forName("java.lang.String"); classParams[2] = Class.forName("javax.swing.Icon"); params[0] = this; params[1] = label; params[2] = icon; // Load the action class, get it's constructor, and create new obj. Class actionClassObj = Class.forName(actionClassName); Constructor constructor = actionClassObj.getDeclaredConstructor(classParams); ActionBase action = (ActionBase)constructor.newInstance(params); mActions.put(actionID, action); return action; } catch (Exception e) { System.out.println("Fail to load " + actionClassName + ". " + e); } return null; } /** * Create the menu bar for the frame window. Get the list of menus of * the menu bar from the resource file based on the frame type of this * frame window. Create each menu in turn and attach it to the menubar. * * @return The JMenuBar object. * */ private JMenuBar createMenubar() { JMenuBar menuBar = new JMenuBar(); String menuBarList = Res.getStr(mFrameType + ".MenuBar"); if (menuBarList != null) { StringTokenizer enumMenuNames = new StringTokenizer(menuBarList); // Go through the menu items while (enumMenuNames.hasMoreTokens()) { String menuName = enumMenuNames.nextToken(); // Get the label of the menu. String label = Res.getStr(menuName + ".Label"); if (label == null) { continue; } JMenu menu = new JMenu(label); // Get the mnemoic of the menu. String menuMnemonic = Res.getStr(menuName + ".Mnemonic"); if (menuMnemonic != null) { menu.setMnemonic(menuMnemonic.charAt(0)); } // Fill up the menu with it's menu items. populateMenu(menu, menuName); menuBar.add(menu); } } return menuBar; } /** * Populate the menu with its menu items. * * @param menu The JMenu object to populate. * @param menuName The resource name for the menu. The value of the * resource is a list of menu item names of the menu. * */ private void populateMenu(JMenu menu, String menuName) { String menuItemList = Res.getStr(menuName); StringTokenizer enumItemNames = new StringTokenizer(menuItemList); String oldGroupName = ""; ButtonGroup group = null; // Go through all the menu items and create each one at a time. while (enumItemNames.hasMoreTokens()) { String itemName = enumItemNames.nextToken(); if (itemName.equals("-")) { menu.addSeparator(); } else if (Res.getStr(itemName + ".SubMenu") != null) { // See if it's a submenu JMenu submenu = new JMenu(Res.getStr(itemName + ".Label")); String menuMnemonic = Res.getStr(itemName + ".Mnemonic"); submenu.setMnemonic(menuMnemonic.charAt(0)); populateMenu(submenu, itemName); menu.add(submenu); } else { String groupName = Res.getStr(itemName + ".Radio"); // See if menu item belongs to a radio button group. if (groupName == null) { // Not a radio button at all. group = null; oldGroupName = ""; } else if (!groupName.equals(oldGroupName) || group == null) { // It is a new group. Create it. group = new ButtonGroup(); oldGroupName = groupName; } // Create the menu item. JMenuItem item = createMenuItem(itemName, group); if (item != null) { menu.add(item); } } } } /** * Create the menu bar for the frame window. Get the list of menus of * the menu bar from the resource file based on the frame type of this * frame window. Create each menu in turn and attach it to the menubar. * * @param popupMenuName The name of the popup menu resource name. * * @return The JMenuBar object. * */ public JPopupMenu createPopupMenu(String popupMenuName) { JPopupMenu popupMenu = new JPopupMenu(); populatePopupMenu(popupMenu, popupMenuName); return popupMenu; } /** * Populate the popup menu with its menu items. This basically does * the same thing as populateMenu() except the passed in parameter is * a JPopupMenu instead of JMenu. The problem of incompatible menu * classes. Doh! * * @param menu The JPopupMenu object to populate. * @param menuName The resource name for the menu. The value of the * resource is a list of menu item names of the menu. * */ void populatePopupMenu(JPopupMenu menu, String menuName) { String menuItemList = Res.getStr(menuName); if (menuItemList == null) { return; } StringTokenizer enumItemNames = new StringTokenizer(menuItemList); String oldGroupName = ""; ButtonGroup group = null; // Go through all the menu items and create each one at a time. while (enumItemNames.hasMoreTokens()) { String itemName = (String)enumItemNames.nextToken(); if (itemName.equals("-")) { menu.addSeparator(); } else { String groupName = Res.getStr(itemName + ".Radio"); // See if menu item belongs to a radio button group. if (groupName == null) { // Not a radio button at all. group = null; oldGroupName = ""; } else if (!groupName.equals(oldGroupName) || group == null) { // It is a new group. Create it. group = new ButtonGroup(); oldGroupName = groupName; } // Create the menu item. JMenuItem item = createMenuItem(itemName, group); if (item != null) { menu.add(item); } } } } /** * Create a new menu item from the resource file. * * @param itemName The resource name for the menu item. It's used * as prefix of resource name to retrieve different * resources of the menu item. * @param radioGroup The radio button group object if the menu item * belongs to a radio button group. * * @return Return the menu item. */ private JMenuItem createMenuItem(String itemName, ButtonGroup radioGroup) { String actionID = Res.getStr(itemName + ".ActionID"); if (actionID == null) { //System.out.println("Missing " + itemName + ".ActionID"); return null; } // Get the various resources for the menu item. String label = Res.getStr(itemName + ".Label"); ImageIcon icon = Res.getIcon(itemName + ".Icon"); boolean isCheckBox = (Res.getStr(itemName + ".CheckBox") != null); String itemMnemonic = Res.getStr(itemName + ".Mnemonic"); KeyStroke accel = Res.getAccelerator(itemName + ".Accelerator"); boolean radioSelected = (Res.getStr(itemName + ".Radio.Selected") != null); ActionBase action = loadAction(itemName); JMenuItem item; if (radioGroup != null) { // Create a radio button menu item. item = new JRadioButtonMenuItem(label); radioGroup.add(item); if (radioSelected) { item.setSelected(true); } } else if (isCheckBox) { // Create a checkbox menu item. item = new JCheckBoxMenuItem(label); } else { // Create a regular menu item. item = new JMenuItem(label); } if (action != null) { // Attach to action object and add itself to the action. item.addActionListener(action); ((ActionBase)action).addRefreshComponent(item); } else { // No action available. Disable the menu item. item.setEnabled(false); } if (itemMnemonic != null) { item.setMnemonic(itemMnemonic.charAt(0)); } if (accel != null) { item.setAccelerator(accel); mAccelerators.put(accel, accel); } if (icon != null && !isCheckBox) { item.setIcon(icon); item.setHorizontalTextPosition(SwingConstants.RIGHT); } return item; } /** * Create a new tool bar, with all its buttons. Note that the toolbar * has to be created after the menu bar is created. Because the menu * bar loads the actions as it sets up the menu item. * * @return Return the toolbar object. */ private JToolBar createToolbar() { JToolBar toolbar = new JToolBar(); int menuCount = 0; String toolbarList = Res.getStr(mFrameType + ".ToolBar"); if (toolbarList != null) { StringTokenizer tokenizer = new StringTokenizer(toolbarList); // Go through all the buttons on the toolbar. while (tokenizer.hasMoreTokens()) { menuCount++; String item = (String)tokenizer.nextToken(); if (item.equals("-")) { toolbar.addSeparator(); } else { boolean isCheckBox = (Res.getStr(item + ".CheckBox") != null); ActionBase action = loadAction(item); if (action == null) { System.out.println("No action class for " + item); continue; } AbstractButton button; if (isCheckBox) { ImageIcon icon = Res.getIcon(item + ".Icon"); ImageIcon iconoff = Res.getIcon(item + ".Icon.Selected"); JToggleButton jbutton = new JToggleButton(iconoff); jbutton.setSelectedIcon(icon); jbutton.addActionListener(action); toolbar.add(jbutton); button = jbutton; } else { button = toolbar.add(action); } action.addRefreshComponent(button); button.setMargin(new Insets(0, 0, 0, 0)); button.setToolTipText(Res.getStr(item + ".Tooltip")); button.setText(null); } } } if (menuCount > 0) { toolbar.add(Box.createHorizontalGlue()); return toolbar; } else { return null; } } /** * Refresh all the action objects. Call each action object's refresh() * method. This gives each action object a chance to update its * associated visual components. * */ void refreshAllActions() { Enumeration enumeration = mActions.elements(); while (enumeration.hasMoreElements()) { ActionBase action = (ActionBase)enumeration.nextElement(); action.refresh(); } } void refreshAction(String actionID) { ActionBase action = (ActionBase)mActions.get(actionID); if (action != null) action.refresh(); } /** * Perform an action, by its actionID. * * @param source The source of the action. * @param actionID The ID of the action to perform. */ protected void doAction(Component source, String actionID) { Action action = (Action)mActions.get(actionID); if (action == null) { JOptionPane.showMessageDialog(this, "No action defined for " + actionID, "Error", JOptionPane.ERROR_MESSAGE); return; } action.actionPerformed(new ActionEvent(source, ActionEvent.ACTION_PERFORMED, actionID)); } protected void addRefreshComponent(String actionID, JComponent compToAdd) { ActionBase action = (ActionBase)mActions.get(actionID); if (action != null) action.addRefreshComponent(compToAdd); } /** * Set the global fonts for different components * */ public void setFonts() { UIManager.getDefaults().put("Table.font", ServiceManager.getCfg().mFontTable); UIManager.getDefaults().put("TextPane.font", ServiceManager.getCfg().mFontTable); UIManager.getDefaults().put("TextArea.font", ServiceManager.getCfg().mFontTable); UIManager.getDefaults().put("TextField.font", ServiceManager.getCfg().mFontTable); UIManager.getDefaults().put("PasswordField.font", ServiceManager.getCfg().mFontTable); UIManager.getDefaults().put("EditorPane.font", ServiceManager.getCfg().mFontTable); UIManager.getDefaults().put("ProgressBar.font", ServiceManager.getCfg().mFontTable); UIManager.getDefaults().put("MenuBar.font", ServiceManager.getCfg().mFontMenu); UIManager.getDefaults().put("Menu.font", ServiceManager.getCfg().mFontMenu); UIManager.getDefaults().put("MenuItem.font", ServiceManager.getCfg().mFontMenu); UIManager.getDefaults().put("PopupMenu.font", ServiceManager.getCfg().mFontMenu); UIManager.getDefaults().put("CheckBoxMenuItem.font", ServiceManager.getCfg().mFontMenu); UIManager.getDefaults().put("RadioButtonMenuItem.font", ServiceManager.getCfg().mFontMenu); UIManager.getDefaults().put("CheckBox.font", ServiceManager.getCfg().mFontLabel); UIManager.getDefaults().put("ComboBox.font", ServiceManager.getCfg().mFontLabel); UIManager.getDefaults().put("Button.font", ServiceManager.getCfg().mFontLabel); UIManager.getDefaults().put("Tree.font", ServiceManager.getCfg().mFontLabel); UIManager.getDefaults().put("ScrollPane.font", ServiceManager.getCfg().mFontLabel); UIManager.getDefaults().put("TabbedPane.font", ServiceManager.getCfg().mFontLabel); UIManager.getDefaults().put("TitledBorder.font", ServiceManager.getCfg().mFontLabel); UIManager.getDefaults().put("OptionPane.font", ServiceManager.getCfg().mFontLabel); UIManager.getDefaults().put("ToolBar.font", ServiceManager.getCfg().mFontLabel); UIManager.getDefaults().put("RadioButton.font", ServiceManager.getCfg().mFontLabel); UIManager.getDefaults().put("ToggleButton.font", ServiceManager.getCfg().mFontLabel); UIManager.getDefaults().put("ToolTip.font", ServiceManager.getCfg().mFontLabel); UIManager.getDefaults().put("TableHeader.font", ServiceManager.getCfg().mFontLabel); UIManager.getDefaults().put("Panel.font", ServiceManager.getCfg().mFontLabel); UIManager.getDefaults().put("List.font", ServiceManager.getCfg().mFontLabel); UIManager.getDefaults().put("ColorChooser.font", ServiceManager.getCfg().mFontLabel); UIManager.getDefaults().put("Label.font", ServiceManager.getCfg().mFontLabel); UIManager.getDefaults().put("Viewport.font", ServiceManager.getCfg().mFontLabel); } /** * See if we are running as an applet. * * @return true = is an applet, false = not an applet. */ public boolean isApplet() { return (mApplet != null); } /** * Center the window on the screen * * @param win The window object to position. * @param offset The amount to offset from the center of the screen. */ static void centerWindow(Window win, Point offset) { Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); Dimension winSize = win.getSize(); Rectangle rect = new Rectangle( (screenSize.width - winSize.width) / 2 + offset.x, (screenSize.height - winSize.height) / 2 + offset.y, winSize.width, winSize.height); win.setBounds(rect); } // Center Window on screen // ** Probably not used anymore ** Replaced by setWindowGeometry() static void centerAndSizeWindow(Window win, int fraction, int base) { Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); // JMA - changed size int width = 820; //screenSize.width * fraction / base; int height = 560; //screenSize.height * fraction / base; if (width > screenSize.width) width = screenSize.width; if (height > screenSize.height) height = screenSize.height; Rectangle rect = new Rectangle((screenSize.width - width) / 2, (screenSize.height - height) / 2, width, height); win.setBounds(rect); } public void setWindowGeometry() { Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); int width, height, x, y; // If no values saved (ie: first run), use default size, and centered on screen if (ServiceManager.getCfg().frameWidth < 0) { width = Math.round(screenSize.width * 0.8f); height = Math.round(screenSize.height * 0.8f); x = (screenSize.width - width) / 2; y = (screenSize.height - height) / 2; } else { width = ServiceManager.getCfg().frameWidth; height = ServiceManager.getCfg().frameHeight; x = ServiceManager.getCfg().frameLocationX; y = ServiceManager.getCfg().frameLocationY; } // Set window bounds this.setBounds(new Rectangle(x, y, width, height)); // Can only set maximized state with Java 1.4+ String javaver = System.getProperty("java.version"); if (ServiceManager.getCfg().frameMaximized && javaver != null && javaver.compareTo("1.4.0") >= 0) this.setExtendedState(JFrame.MAXIMIZED_BOTH); } public void saveGUIPrefs() { // Saving of the window size will only work with java versions greater // than 1.4.0 since getExtendedState() is only available in 1.4+ String javaver = System.getProperty("java.version"); if (javaver != null && javaver.compareTo("1.4.0") >= 0) { // If maximized, remember it as maximized and keep normal // size and placement the same as it was previously. if (this.getExtendedState() == JFrame.MAXIMIZED_BOTH) { ServiceManager.getCfg().frameMaximized = true; } else { ServiceManager.getCfg().frameMaximized = false; ServiceManager.getCfg().frameWidth = this.getWidth(); ServiceManager.getCfg().frameHeight = this.getHeight(); ServiceManager.getCfg().frameLocationX = this.getLocation().x; ServiceManager.getCfg().frameLocationY = this.getLocation().y; } } } static void setToolTipText(JComponent comp, String tooltip) { if (ServiceManager.getCfg().mUIDisplayTooltip) { comp.setToolTipText(tooltip); } } public String getFrameType() { return mFrameType; } }

The table below shows all metrics for BaseFrame.java.

MetricValueDescription
BLOCKS79.00Number of blocks
BLOCK_COMMENT19.00Number of block comment lines
COMMENTS182.00Comment lines
COMMENT_DENSITY 0.51Comment density
COMPARISONS51.00Number of comparison operators
CYCLOMATIC80.00Cyclomatic complexity
DECL_COMMENTS17.00Comments in declarations
DOC_COMMENT118.00Number of javadoc comment lines
ELOC355.00Effective lines of code
EXEC_COMMENTS41.00Comments in executable code
EXITS79.00Procedure exits
FUNCTIONS24.00Number of function declarations
HALSTEAD_DIFFICULTY82.30Halstead difficulty
HALSTEAD_EFFORT 0.00Halstead effort
INTERFACE_COMPLEXITY58.00Interface complexity
JAVA0001 0.00JAVA0001 Package name does not contain only lower case letters
JAVA0002 0.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 0.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 0.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 6.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 1.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 1.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
JAVA0068 0.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 1.00JAVA0079 Use of instance to reference static member
JAVA0080 0.00JAVA0080 Import declaration not used
JAVA0081 0.00JAVA0081 Boolean literal in comparison
JAVA0082 3.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 1.00JAVA0108 Incorrect javadoc: no @param tag for 'parameter'
JAVA0109 0.00JAVA0109 Incorrect javadoc: no parameter 'parameter'
JAVA0110 0.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 1.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 6.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 0.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 0.00JAVA0144 Line exceeds maximum M characters
JAVA014512.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 0.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 2.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
JAVA0173 2.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 6.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 1.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 2.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
LINES795.00Number of lines in the source file
LINE_COMMENT45.00Number of line comments
LOC502.00Lines of code
LOGICAL_LINES259.00Number of statements
LOOPS 6.00Number of loops
NEST_DEPTH 5.00Maximum nesting depth
OPERANDS1207.00Number of operands
OPERATORS2109.00Number of operators
PARAMS22.00Number of formal parameter declarations
PROGRAM_LENGTH3316.00Halstead program length
PROGRAM_VOCAB400.00Halstead program vocabulary
PROGRAM_VOLUME 0.00Halstead program volume
RETURNS36.00Number of return points from functions
SIZE28870.00Size of the file in bytes
UNIQUE_OPERANDS352.00Number of unique operands
UNIQUE_OPERATORS48.00Number of unique operators
WHITESPACE111.00Number of whitespace lines