ResourceManager.java

Index Score
com.limegroup.gnutella.gui
FrostWire

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
JAVA0034JAVA0034 Missing braces in if statement
DECL_COMMENTSComments in declarations
JAVA0110JAVA0110 Incorrect javadoc: no @return tag
EXITSProcedure exits
JAVA0108JAVA0108 Incorrect javadoc: no @param tag for 'parameter'
SIZESize of the file in bytes
CYCLOMATICCyclomatic complexity
LINE_COMMENTNumber of line comments
UNIQUE_OPERANDSNumber of unique operands
BLOCKSNumber of blocks
JAVA0150JAVA0150 java.lang.Error (or subclass) thrown
PROGRAM_VOCABHalstead program vocabulary
ELOCEffective lines of code
EXEC_COMMENTSComments in executable code
OPERATORSNumber of operators
LOCLines of code
PROGRAM_LENGTHHalstead program length
LINESNumber of lines in the source file
LOGICAL_LINESNumber of statements
OPERANDSNumber of operands
RETURNSNumber of return points from functions
JAVA0130JAVA0130 Non-static method does not use instance fields
DOC_COMMENTNumber of javadoc comment lines
COMPARISONSNumber of comparison operators
JAVA0170JAVA0170 Caught exception not derived from java.lang.Exception
JAVA0065JAVA0065 Unnecessary final modifier for method in final class
COMMENTSComment lines
INTERFACE_COMPLEXITYInterface complexity
FUNCTIONSNumber of function declarations
JAVA0008JAVA0008 Empty catch block
UNIQUE_OPERATORSNumber of unique operators
JAVA0143JAVA0143 Synchronized method
NEST_DEPTHMaximum nesting depth
PROGRAM_VOLUMEHalstead program volume
JAVA0136JAVA0136 N methods defined in class (maximum: M)
JAVA0035JAVA0035 Missing braces in for statement
JAVA0126JAVA0126 Method declares unchecked exception in throws
JAVA0117JAVA0117 Missing javadoc: method 'method'
JAVA0254JAVA0254 Use enhanced for loop construct instead of Iterator
JAVA0075JAVA0075 Method parameter hides field
LOOPSNumber of loops
JAVA0068JAVA0068 Modifiers not declared in recommended order
JAVA0270JAVA0270 Use Java 5.0 enhanced for loop construct to iterate over all elements in an array
JAVA0145JAVA0145 Tab character used in source file
package com.limegroup.gnutella.gui; import java.awt.Color; import java.awt.Font; import java.io.File; import java.lang.reflect.InvocationTargetException; import java.net.MalformedURLException; import java.net.URL; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Locale; import java.util.Map; import java.util.MissingResourceException; import java.util.ResourceBundle; import javax.swing.BorderFactory; import javax.swing.ImageIcon; import javax.swing.JComponent; import javax.swing.LookAndFeel; import javax.swing.SwingUtilities; import javax.swing.UIDefaults; import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; import javax.swing.plaf.ComponentUI; import javax.swing.plaf.FontUIResource; import javax.swing.plaf.metal.DefaultMetalTheme; import javax.swing.plaf.metal.MetalLookAndFeel; import javax.swing.plaf.metal.MetalTheme; import org.limewire.util.OSUtils; import org.limewire.util.StringUtils; import com.limegroup.gnutella.gui.notify.NotifyUserProxy; import com.limegroup.gnutella.gui.themes.LimeLookAndFeel; import com.limegroup.gnutella.gui.themes.LimePlasticTheme; import com.limegroup.gnutella.gui.themes.ThemeFileHandler; import com.limegroup.gnutella.gui.themes.ThemeSettings; import com.limegroup.gnutella.settings.ApplicationSettings; /** * Manages application resources, including the custom <tt>LookAndFeel</tt>, * the locale-specific <tt>String</tt> instances, and any <tt>Icon</tt> * instances needed by the application. */ // 2345678|012345678|012345678|012345678|012345678|012345678|012345678|012345678| public final class ResourceManager { /** * Instance of this <tt>ResourceManager</tt>, following singleton. */ private static ResourceManager _instance; /** * Constant for the relative path of the gui directory. */ private static final String GUI_PATH = "org/limewire/gui/"; /** * Constant for the relative path of the resources directory. */ private static final String RESOURCES_PATH = GUI_PATH + "resources/"; /** * Constant for the relative path of the images directory. */ private static final String IMAGES_PATH = GUI_PATH + "images/"; /** * Boolean status that controls whever the shared <tt>Locale</tt> instance * needs to be loaded, and locale-specific options need to be setup. */ private static boolean _localeOptionsSet; /** * Static variable for the loaded <tt>Locale</tt> instance. */ private static Locale _locale; /** * Boolean for whether or not the font-size has been reduced. */ private static boolean _fontReduced = false; /** * The default MetalTheme. */ private static MetalTheme _defaultTheme = null; /** * Whether or not LimeWire was started in the 'brushed metal' look. */ private final boolean BRUSHED_METAL; /** * Whether or not the system tray was able to load. */ private final boolean LOADED_TRAY_LIBRARY; /** * Whether or not the jdic associations were able to load. */ private final boolean LOADED_JDIC_LIBRARY; /** Cache of theme images (name as String -> image as ImageIcon) */ private static final Map<String, ImageIcon> THEME_IMAGES = new HashMap<String, ImageIcon>(); /** Marked true in the event of an error in the load/save of any settings file */ private static boolean loadFailureEncountered = false; /** * Statically initialize necessary resources. */ static { resetLocaleOptions(); } static void resetLocaleOptions() { _localeOptionsSet = false; setLocaleOptions(); } static void setLocaleOptions() { if (!_localeOptionsSet) { if (ApplicationSettings.LANGUAGE.getValue().equals("")) ApplicationSettings.LANGUAGE.setValue("en"); _locale = new Locale(ApplicationSettings.LANGUAGE.getValue(), ApplicationSettings.COUNTRY.getValue(), ApplicationSettings.LOCALE_VARIANT.getValue()); StringUtils.setLocale(_locale); I18n.setLocale(_locale); _localeOptionsSet = true; } } /** * Returns the <tt>Locale</tt> instance currently in use. * * @return the <tt>Locale</tt> instance currently in use */ static Locale getLocale() { return _locale; } /** * Indicated if a failure has occurred for delayed reporting */ public static boolean hasLoadFailure() { return loadFailureEncountered; } /** * Resets the failure flag */ public static void resetLoadFailure() { loadFailureEncountered = false; } /** * Returns the XML resource bundle for the given schema. * * @param String schema name (not the URI but name returned by * LimeXMLSchema.getDisplayString) * @return ResourceBundle */ static ResourceBundle getXMLResourceBundle(String name) { return ResourceBundle.getBundle("xml.display." + name, _locale); } /** * Serves as a single point of access for any icons that should be accessed * directly from the file system for themes. * * @param name The name of the image (excluding the extension) to locate. * @return a new <tt>ImageIcon</tt> instance for the specified file, or * <tt>null</tt> if the resource could not be loaded */ static final ImageIcon getThemeImage(final String name) { if (name == null) throw new NullPointerException("null image name"); ImageIcon icon = null; // First try to get theme image from cache icon = THEME_IMAGES.get(name); if (icon != null) return icon; File themeDir = ThemeSettings.THEME_DIR.getValue(); //System.out.println("ResourceManager.getThemeImage("+name+") Getting Theme Image from: \n" + org.limewire.util.CommonUtils.getUserSettingsDir() + "\n"); // Next try to get from themes. icon = getImageFromURL(new File(themeDir, name).getPath(), true); if (icon != null && icon.getImage() != null) { THEME_IMAGES.put(name, icon); return icon; } // Then try to get from org/limewire/gui/images resources icon = getImageFromURL(IMAGES_PATH + name, false); if (icon != null && icon.getImage() != null) { THEME_IMAGES.put(name, icon); return icon; } // no resource? error. throw new MissingResourceException( "image: " + name + " doesn't exist.", null, null); } /** * Retrieves an icon from the specified path in the filesystem. */ static final ImageIcon getImageFromResourcePath(String loc) { return getImageFromURL(loc, false); } /** * Retrieves an icon from a URL-style path. * * If 'file' is true, location is treated as a file, otherwise it is treated * as a resource. * * This tries, in order, the exact location, the location as a png, and the * location as a gif. */ private static final ImageIcon getImageFromURL(String location, boolean file) { // try exact filename first. URL img = toURL(location, file); if (img != null) return new ImageIcon(img); // try with png second img = toURL(location + ".png", file); if (img != null) return new ImageIcon(img); // try with gif third img = toURL(location + ".gif", file); if (img != null) return new ImageIcon(img); return null; } /** * Makes a URL out of a location, as either a file or a resource. */ @SuppressWarnings("deprecation") private static final URL toURL(String location, boolean file) { if (file) { File f = new File(location); if (f.exists()) { try { return f.toURL(); } catch (MalformedURLException murl) { return null; } } else { return null; } } else { return getURL(location); } } /** * Returns a new <tt>URL</tt> instance for the specified file in the * "resources" directory. * * @param FILE_NAME the name of the resource file * @return a new <tt>URL</tt> instance for the desired file, or * <tt>null</tt> if the <tt>URL</tt> could not be loaded */ static URL getURLResource(final String FILE_NAME) { return ResourceManager.getURL(RESOURCES_PATH + FILE_NAME); } /** * Returns a new <tt>URL</tt> instance for the resource at the specified * local path. The path should be the full path within the jar file, such * as: * <p> * * org/limewire/gui/images/searching.gif * <p> * * @param PATH the path to the resource file within the jar * @return a new <tt>URL</tt> instance for the desired file, or * <tt>null</tt> if the <tt>URL</tt> could not be loaded */ private static URL getURL(final String PATH) { ClassLoader cl = ResourceManager.class.getClassLoader(); if (cl == null) { return ClassLoader.getSystemResource(PATH); } URL url = cl.getResource(PATH); if (url == null) { return ClassLoader.getSystemResource(PATH); } return url; } /** * Instance accessor following singleton. */ public static synchronized final ResourceManager instance() { if (_instance == null) _instance = new ResourceManager(); return _instance; } /** * Private constructor to ensure that a <tt>ResourceManager</tt> cannot be * constructed from outside this class. */ private ResourceManager() { if (!ThemeFileHandler.isCurrent() || !ThemeSettings.isValid()) { ThemeSettings.THEME_FILE.revertToDefault(); ThemeSettings.THEME_DIR.revertToDefault(); ThemeFileHandler.reload(false); } String bMetal = System.getProperty("apple.awt.brushMetalLook"); BRUSHED_METAL = bMetal != null && bMetal.equalsIgnoreCase("true"); themeChanged(); ResourceManager.setFontSizes(ThemeSettings.FONT_SIZE_INCREMENT.getValue()); try { validateLocaleAndFonts(Locale.getDefault()); } catch (NullPointerException npe) { // ignore, can't do much about it -- internal ignorable error. } if (OSUtils.isWindows() || OSUtils.isLinux()) { boolean loaded = false; try { System.loadLibrary("tray"); loaded = true; } catch (UnsatisfiedLinkError ule) { } LOADED_TRAY_LIBRARY = loaded; loaded = false; try { System.loadLibrary("jdic"); loaded = true; } catch (UnsatisfiedLinkError ule) { } LOADED_JDIC_LIBRARY = loaded; } else { LOADED_TRAY_LIBRARY = false; LOADED_JDIC_LIBRARY = false; } } /** * Validates the locale, determining if the current locale's resources can * be displayed using the current fonts. If not, then the locale is reset to * English. * * This prevents the UI from appearing as all boxes. */ public static void validateLocaleAndFonts(Locale locale) { // OSX can always display everything, and if it can't, // we have no way of correcting things 'cause canDisplayUpTo // is broken on it. if (OSUtils.isMacOSX()) return; String s = locale.getDisplayName(); if (!checkUIFonts("dialog", s)) { // if it couldn't display, revert the locale to english. ApplicationSettings.LANGUAGE.setValue("en"); ApplicationSettings.COUNTRY.setValue(""); ApplicationSettings.LOCALE_VARIANT.setValue(""); GUIMediator.resetLocale(); } // Ensure that the Table.font can always display intl characters // since we can always get i18n stuff there, but only if we'd actually // be capable of displaying an intl character with the font... // unicode string == country name of simplified chinese String i18n = "\u4e2d\u56fd"; checkFont("TextField.font", "dialog", i18n, true); checkFont("Table.font", "dialog", i18n, true); checkFont("ProgressBar.font", "dialog", i18n, true); checkFont("TabbedPane.font", "dialog", i18n, true); } /** * Alters all Fonts in UIManager to use Dialog, to correctly display foreign * strings. */ private static boolean checkUIFonts(String newFont, String testString) { String[] comps = new String[] { "TextField.font", "PasswordField.font", "TextArea.font", "TextPane.font", "EditorPane.font", "FormattedTextField.font", "Button.font", "CheckBox.font", "RadioButton.font", "ToggleButton.font", "ProgressBar.font", "ComboBox.font", "InternalFrame.titleFont", "DesktopIcon.font", "TitledBorder.font", "Label.font", "List.font", "TabbedPane.font", "Table.font", "TableHeader.font", "MenuBar.font", "Menu.font", "Menu.acceleratorFont", "MenuItem.font", "MenuItem.acceleratorFont", "PopupMenu.font", "CheckBoxMenuItem.font", "CheckBoxMenuItem.acceleratorFont", "RadioButtonMenuItem.font", "RadioButtonMenuItem.acceleratorFont", "Spinner.font", "Tree.font", "ToolBar.font", "OptionPane.messageFont", "OptionPane.buttonFont", "ToolTip.font", }; boolean displayable = false; for (int i = 0; i < comps.length; i++) displayable |= checkFont(comps[i], newFont, testString, false); // Then do it the automagic way. // note that this could work all the time (without requiring the above) // if Java 1.4 didn't introduce Locales, and it could even still work // if they offered a way to get all the keys of possible resources. for (Map.Entry<Object, Object> next : UIManager.getDefaults().entrySet()) { if (next.getValue() instanceof Font) { Font f = (Font) next.getValue(); if (f != null && !newFont.equalsIgnoreCase(f.getName())) { if (!GUIUtils.canDisplay(f, testString)) { f = new Font(newFont, f.getStyle(), f.getSize()); if (GUIUtils.canDisplay(f, testString)) { next.setValue(f); displayable = true; } } } } } return displayable; } /** * Updates the font of a given fontName to be newName. */ private static boolean checkFont(String fontName, String newName, String testString, boolean force) { boolean displayable = true; Font f = UIManager.getFont(fontName); if (f != null && !newName.equalsIgnoreCase(f.getName())) { if (!GUIUtils.canDisplay(f, testString) || force) { f = new Font(newName, f.getStyle(), f.getSize()); if (GUIUtils.canDisplay(f, testString)) UIManager.put(fontName, f); else displayable = false; } } else if (f != null) { displayable = GUIUtils.canDisplay(f, testString); } else { displayable = false; } return displayable; } /** * Determines if the tray library has loaded. */ public boolean isTrayLibraryLoaded() { return LOADED_TRAY_LIBRARY; } /** Determines if a system tray icon is available. */ public boolean isTrayIconAvailable() { return isTrayLibraryLoaded() && NotifyUserProxy.instance().supportsSystemTray(); } /** * Determines if the jdic library has loaded. */ public boolean isJdicLibraryLoaded() { return LOADED_JDIC_LIBRARY; } /** * Determines if the brushed metal property is set. */ public boolean isBrushedMetalSet() { return BRUSHED_METAL; } /** * Updates to the current theme. */ public void themeChanged() { THEME_IMAGES.clear(); try { if (ThemeSettings.isOtherTheme()) { // in case this is using metal ... UIManager.put("swing.boldMetal", Boolean.FALSE); if (_defaultTheme != null) MetalLookAndFeel.setCurrentTheme(_defaultTheme); String other = ThemeSettings.getOtherLF(); UIManager.setLookAndFeel(other); } else if (ThemeSettings.isNativeTheme()) { if (OSUtils.isWindows() && isPlasticWindowsAvailable()) { try { UIManager.setLookAndFeel("com.jgoodies.plaf.windows.ExtWindowsLookAndFeel"); } catch (NullPointerException npe) { UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); } } else UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); if (OSUtils.isMacOSX()) { if (!_fontReduced) { _fontReduced = true; reduceFont("Label.font"); reduceFont("Table.font"); } UIManager.put("List.focusCellHighlightBorder", BorderFactory.createEmptyBorder(1, 1, 1, 1)); UIManager.put("ScrollPane.border", BorderFactory.createMatteBorder(1, 1, 1, 1, Color.lightGray)); } // HACK: On Windows sometimes, JFileChooser can't // show because some icons throw an AIOOBE // when they're retrieved. To workaround this, // we install our own version of those icons. if (OSUtils.isWindows()) { replaceIconIfFailing("FileChooser.upFolderIcon", "upFolderIconVistaFix"); replaceIconIfFailing("FileChooser.detailsViewIcon", "detailsViewIconVistaFix"); replaceIconIfFailing("FileChooser.listViewIcon", "listViewIconVistaFix"); replaceIconIfFailing("FileChooser.newFolderIcon", "newFolderIconVistaFix"); } } else { if (isPlasticAvailable()) { if (_defaultTheme == null) _defaultTheme = getDefaultTheme(); LimePlasticTheme.installThisTheme(); UIManager .setLookAndFeel("com.jgoodies.plaf.plastic.PlasticXPLookAndFeel"); LimeLookAndFeel.installUIManagerDefaults(); } else { UIManager.setLookAndFeel(new LimeLookAndFeel()); } } UIManager .put("Tree.leafIcon", UIManager.getIcon("Tree.closedIcon")); // remove split pane borders UIManager .put("SplitPane.border", BorderFactory.createEmptyBorder()); if (!OSUtils.isMacOSX()) UIManager.put("Table.focusRowHighlightBorder", UIManager .get("Table.focusCellHighlightBorder")); UIManager.put("Table.focusCellHighlightBorder", BorderFactory .createEmptyBorder(1, 1, 1, 1)); // Add a bolded text version of simple text. Font normal = UIManager.getFont("Table.font"); FontUIResource bold = new FontUIResource(normal.getName(), Font.BOLD, normal.getSize()); UIManager.put("Table.font.bold", bold); UIManager.put("Tree.rowHeight", 0); } catch (UnsupportedLookAndFeelException e) { throw new ExceptionInInitializerError(e); } catch (ClassNotFoundException e) { throw new ExceptionInInitializerError(e); } catch (InstantiationException e) { throw new ExceptionInInitializerError(e); } catch (IllegalAccessException e) { throw new ExceptionInInitializerError(e); } wrapDesktopProperties(); } private void wrapDesktopProperties() { if(!OSUtils.isWindows()) return; Class<?> desktopProperty; // See if we can get a handle to the 'DesktopProperty' class. try { desktopProperty = Class.forName("com.sun.java.swing.plaf.windows.DesktopProperty"); } catch(ClassNotFoundException cnfe) { return; } UIDefaults defaults = UIManager.getLookAndFeelDefaults(); synchronized(defaults) { for(Iterator<Map.Entry<Object, Object>> i = defaults.entrySet().iterator(); i.hasNext(); ) { Map.Entry<Object, Object> next = i.next(); Object value = next.getValue(); if(next.getValue() instanceof UIDefaults.ActiveValue) { UIDefaults.ActiveValue activeValue = (UIDefaults.ActiveValue)value; if(value != null && desktopProperty.isAssignableFrom(value.getClass())) { next.setValue(new ActiveDesktopProperty(activeValue)); } } } } } /** * Replaces an icon resource in UIManager with a different resource if the * original resource can't be retrieved correctly. * * @param resource * @param replacementName */ private void replaceIconIfFailing(String resource, String replacementName) { try { UIManager.getIcon(resource); } catch (ArrayIndexOutOfBoundsException aioobe) { UIManager.put(resource, getThemeImage(replacementName)); } } /** * Gets the current theme (or defaults to MetalTheme) if possible. */ private MetalTheme getDefaultTheme() { MetalTheme theme = null; try { theme = (MetalTheme) MetalLookAndFeel.class.getMethod( "getCurrentTheme", (Class[]) null).invoke(null, (Object[]) null); } catch (IllegalAccessException iae) { } catch (InvocationTargetException ite) { } catch (NoSuchMethodException nsme) { } if (theme == null) theme = new DefaultMetalTheme(); return theme; } /** * Determines if the PlasticXP Theme is available. */ private boolean isPlasticAvailable() { try { Class plastic = Class .forName("com.jgoodies.plaf.plastic.PlasticXPLookAndFeel"); return plastic != null; } catch (ClassNotFoundException cnfe) { return false; } } /** * Determines if the Plastic Windows Theme is available. */ private boolean isPlasticWindowsAvailable() { try { Class plastic = Class .forName("com.jgoodies.plaf.windows.ExtWindowsLookAndFeel"); return plastic != null; } catch (ClassNotFoundException cnfe) { return false; } } /** * Updates the component to use the native UI resource. */ static ComponentUI getNativeUI(JComponent c) { ComponentUI ret = null; String name = UIManager.getSystemLookAndFeelClassName(); if (name != null) { try { Class clazz = Class.forName(name); LookAndFeel lf = (LookAndFeel) clazz.newInstance(); lf.initialize(); UIDefaults def = lf.getDefaults(); ret = def.getUI(c); } catch (ExceptionInInitializerError e) { } catch (ClassNotFoundException e) { } catch (LinkageError e) { } catch (IllegalAccessException e) { } catch (InstantiationException e) { } catch (SecurityException e) { } catch (ClassCastException e) { } } // if any of those failed, default to the current UI. if (ret == null) ret = UIManager.getUI(c); return ret; } /** * Reduces the size of a font in UIManager. */ private static void reduceFont(String name) { Font oldFont = UIManager.getFont(name); FontUIResource newFont = new FontUIResource(oldFont.getName(), oldFont .getStyle(), oldFont.getSize() - 2); UIManager.put(name, newFont); } public static void setFontSizes(float fontSizeIncrement) { if (fontSizeIncrement == 0f) { return; } Map<Font, Font> newFontByOldFont = new HashMap<Font, Font>(); String[] fontKeys = new String[] { "Button.font", "CheckBox.font", "ComboBox.font", "DesktopIcon.font", "Label.font", "List.font", "ProgressBar.font", "RadioButton.font", "Slider.font", "Spinner.font", "TabbedPane.font", "TitledBorder.font", "ToggleButton.font", "CheckBoxMenuItem.font", "Menu.font", "MenuBar.font", "MenuItem.font", "PopupMenu.font", "RadioButtonMenuItem.font", "ToolBar.font", "ToolTip.font", "EditorPane.font", "FormattedTextField.font", "PasswordField.font", "Table.font", "TableHeader.font", "TextArea.font", "TextField.font", "TextPane.font", "Tree.font", "InternalFrame.titleFont", }; List<Object> props = new ArrayList<Object>(fontKeys.length * 2); for (String fontKey : fontKeys) { Font font = UIManager.getFont(fontKey); Font newFont = newFontByOldFont.get(font); if (newFont == null) { if (font == null) { continue; } newFont = new FontUIResource(font.deriveFont(font.getSize() + fontSizeIncrement)); newFontByOldFont.put(font, newFont); } props.add(fontKey); props.add(newFont); } UIManager.getDefaults().putDefaults(props.toArray()); } /** Wraps an ActiveValue to ensure creating the value is done in the Swing thread. */ private static class ActiveDesktopProperty implements UIDefaults.ActiveValue, Runnable { private final UIDefaults.ActiveValue delegate; private volatile UIDefaults table; private volatile Object result; ActiveDesktopProperty(UIDefaults.ActiveValue value) { this.delegate = value; } public Object createValue(UIDefaults table) { if(SwingUtilities.isEventDispatchThread()) { return delegate.createValue(table); } else { this.table = table; // Try to run it in the Swing thread, // but if we can't, load the value directly // (and pray). try { SwingUtilities.invokeAndWait(this); } catch (InterruptedException e) { return delegate.createValue(table); } catch (InvocationTargetException e) { return delegate.createValue(table); } return result; } } public void run() { this.result = delegate.createValue(table); } } }

The table below shows all metrics for ResourceManager.java.

MetricValueDescription
BLOCKS114.00Number of blocks
BLOCK_COMMENT 0.00Number of block comment lines
COMMENTS197.00Comment lines
COMMENT_DENSITY 0.45Comment density
COMPARISONS59.00Number of comparison operators
CYCLOMATIC117.00Cyclomatic complexity
DECL_COMMENTS43.00Comments in declarations
DOC_COMMENT163.00Number of javadoc comment lines
ELOC435.00Effective lines of code
EXEC_COMMENTS20.00Comments in executable code
EXITS99.00Procedure exits
FUNCTIONS33.00Number of function declarations
HALSTEAD_DIFFICULTY73.76Halstead difficulty
HALSTEAD_EFFORT 0.00Halstead effort
INTERFACE_COMPLEXITY83.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 3.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
JAVA003417.00JAVA0034 Missing braces in if statement
JAVA0035 1.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 1.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 5.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 1.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 1.00JAVA0075 Method parameter hides field
JAVA0076 0.00JAVA0076 Use of magic number
JAVA0077 0.00JAVA0077 Private field not used in declaring class
JAVA0078 1.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
JAVA010815.00JAVA0108 Incorrect javadoc: no @param tag for 'parameter'
JAVA0109 1.00JAVA0109 Incorrect javadoc: no parameter 'parameter'
JAVA011015.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 1.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 5.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 1.00JAVA0143 Synchronized method
JAVA0144 1.00JAVA0144 Line exceeds maximum M characters
JAVA0145 0.00JAVA0145 Tab character used in source file
JAVA0150 4.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 0.00JAVA0166 Generic exception caught
JAVA0167 0.00JAVA0167 ThreadDeath not rethrown
JAVA0169 0.00JAVA0169 Unnecessary catch block: exception 'exception'
JAVA0170 4.00JAVA0170 Caught exception not derived from java.lang.Exception
JAVA0171 0.00JAVA0171 Unused local variable
JAVA0173 0.00JAVA0173 Unused method parameter
JAVA0174 0.00JAVA0174 Assigned local variable never used
JAVA0175 1.00JAVA0175 Successive assignment to variable
JAVA0176 0.00JAVA0176 Local variable name does not have required form
JAVA0177 1.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 1.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 1.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
LINES809.00Number of lines in the source file
LINE_COMMENT34.00Number of line comments
LOC516.00Lines of code
LOGICAL_LINES238.00Number of statements
LOOPS 2.00Number of loops
NEST_DEPTH 6.00Maximum nesting depth
OPERANDS1101.00Number of operands
OPERATORS2138.00Number of operators
PARAMS23.00Number of formal parameter declarations
PROGRAM_LENGTH3239.00Halstead program length
PROGRAM_VOCAB457.00Halstead program vocabulary
PROGRAM_VOLUME 0.00Halstead program volume
RETURNS60.00Number of return points from functions
SIZE28630.00Size of the file in bytes
UNIQUE_OPERANDS403.00Number of unique operands
UNIQUE_OPERATORS54.00Number of unique operators
WHITESPACE96.00Number of whitespace lines