UiUtilities.java

Index Score
util.ui
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
EXEC_COMMENTSComments in executable code
EXITSProcedure exits
DOC_COMMENTNumber of javadoc comment lines
COMMENTSComment lines
LINE_COMMENTNumber of line comments
OPERANDSNumber of operands
LOGICAL_LINESNumber of statements
UNIQUE_OPERANDSNumber of unique operands
SIZESize of the file in bytes
PROGRAM_LENGTHHalstead program length
PROGRAM_VOCABHalstead program vocabulary
OPERATORSNumber of operators
LINESNumber of lines in the source file
PARAMSNumber of formal parameter declarations
ELOCEffective lines of code
DECL_COMMENTSComments in declarations
JAVA0034JAVA0034 Missing braces in if statement
LOCLines of code
BLOCKSNumber of blocks
COMPARISONSNumber of comparison operators
INTERFACE_COMPLEXITYInterface complexity
JAVA0076JAVA0076 Use of magic number
JAVA0177JAVA0177 Variable declaration missing initializer
CYCLOMATICCyclomatic complexity
LOOPSNumber of loops
JAVA0285JAVA0285 Dereference of potentially null variable
UNIQUE_OPERATORSNumber of unique operators
RETURNSNumber of return points from functions
JAVA0117JAVA0117 Missing javadoc: method 'method'
JAVA0166JAVA0166 Generic exception caught
PROGRAM_VOLUMEHalstead program volume
JAVA0136JAVA0136 N methods defined in class (maximum: M)
JAVA0174JAVA0174 Assigned local variable never used
JAVA0126JAVA0126 Method declares unchecked exception in throws
JAVA0110JAVA0110 Incorrect javadoc: no @return tag
FUNCTIONSNumber of function declarations
JAVA0265JAVA0265 Use of Throwable.printStackTrace()
JAVA0173JAVA0173 Unused method parameter
JAVA0108JAVA0108 Incorrect javadoc: no @param tag for 'parameter'
JAVA0145JAVA0145 Tab character used in source file
/* * TV-Browser * Copyright (C) 04-2003 Martin Oberhauser (martin_oat@yahoo.de) * * 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-06-06 19:24:15 -0400 (Fri, 06 Jun 2008) $ * $Author: ds10 $ * $Revision: 4801 $ */ package util.ui; import tvbrowser.ui.mainframe.MainFrame; import util.browserlauncher.Launch; import util.misc.OperatingSystem; import javax.swing.AbstractAction; import javax.swing.Action; import javax.swing.BorderFactory; import javax.swing.DefaultListModel; import javax.swing.Icon; import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JComponent; import javax.swing.JDialog; import javax.swing.JEditorPane; import javax.swing.JLabel; import javax.swing.JList; import javax.swing.JOptionPane; import javax.swing.JTextArea; import javax.swing.KeyStroke; import javax.swing.border.Border; import javax.swing.event.HyperlinkEvent; import javax.swing.event.HyperlinkListener; import java.awt.Color; import java.awt.Component; import java.awt.Cursor; import java.awt.Dialog; import java.awt.Dimension; import java.awt.Font; import java.awt.FontMetrics; import java.awt.Frame; import java.awt.Graphics2D; import java.awt.GraphicsConfiguration; import java.awt.GraphicsDevice; import java.awt.GraphicsEnvironment; import java.awt.Image; import java.awt.Insets; import java.awt.Point; import java.awt.RenderingHints; import java.awt.Toolkit; import java.awt.Window; import java.awt.event.ActionEvent; import java.awt.event.InputEvent; import java.awt.event.KeyEvent; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.geom.AffineTransform; import java.awt.image.BufferedImage; import java.net.URL; /** * Provides utilities for UI stuff. * * @author Til Schneider, www.murfman.de */ public class UiUtilities { /** The helper label. */ private static final JLabel HELPER_LABEL = new JLabel(); /** The border to use for dialogs. */ public static final Border DIALOG_BORDER = BorderFactory.createEmptyBorder( 10, 10, 0, 10); public static final Insets ZERO_INSETS = new Insets(0, 0, 0, 0); /** * Centers a window to its parent frame and shows it. * <p> * If the window has no parent frame it will be centered to the screen. * * @param win * The window to center and show. */ public static void centerAndShow(Window win) { Dimension wD = win.getSize(); Dimension frameD; Point framePos; Frame frame = JOptionPane.getFrameForComponent(win); // Should this window be centered to its parent frame? boolean centerToParentFrame = (frame != null) && (frame != win) && frame.isShowing(); // Center to parent frame or to screen if (centerToParentFrame) { frameD = frame.getSize(); framePos = frame.getLocation(); } else { GraphicsEnvironment ge = GraphicsEnvironment .getLocalGraphicsEnvironment(); GraphicsDevice[] gs = ge.getScreenDevices(); // dual head, use first screen if (gs.length > 1) { try { GraphicsDevice gd = gs[0]; GraphicsConfiguration config = gd.getConfigurations()[0]; frameD = config.getBounds().getSize(); framePos = config.getBounds().getLocation(); } catch (RuntimeException e) { frameD = Toolkit.getDefaultToolkit().getScreenSize(); framePos = new Point(0, 0); } } // single screen only else { frameD = Toolkit.getDefaultToolkit().getScreenSize(); framePos = new Point(0, 0); } } Point wPos = new Point(framePos.x + (frameD.width - wD.width) / 2, framePos.y + (frameD.height - wD.height) / 2); wPos.x = Math.max(0, wPos.x); // Make x > 0 wPos.y = Math.max(0, wPos.y); // Make y > 0 win.setLocation(wPos); win.setVisible(true); } /** * Der {@link JDialog} hat einen Riesennachteil: er hat zwei verschiedenen * Konstrukturen: einer fÔøΩr einen Frame als Besitzer und einer fÔøΩr einen * Dialog als Besitzer. Wenn man nun das ÔøΩberliegende Fenster gar nicht * kennt, dann hat man ein Problem (Z.B. Wenn man einen Button schreibt, der * manchmal eine Fehlermeldung zeigt). Bisher habe ich einfach den * Component-Pfad bis zum obersten Frame verfolgt (@link * UiToolkit#getFrameFor(Component)). Das ganze wird dann zum Problem, wenn * man in einem modalen Dialog einen nicht-modalen Dialog zeigt. Denn dann * kann man den nicht-modalen Dialog nÔøΩmlich erst dann wieder bedienen, wenn * der modale zu ist. * * @param parent * A component in the component tree where the dialog should be * created for. * @param modal * Should the new dialog be modal? * @return A new JDialog. */ public static JDialog createDialog(Component parent, boolean modal) { Window parentWin = getBestDialogParent(parent); JDialog dlg; if ((parentWin instanceof Frame) || (parentWin == null)) { dlg = new JDialog((Frame) parentWin, modal); } else if (parentWin instanceof Dialog) { dlg = new JDialog((Dialog) parentWin, modal); } else { throw new IllegalArgumentException("parent has surrounding Window of " + "unknown type: " + parentWin.getClass()); } return dlg; } /** * Gets the best dialog parent for a new JDialog. The best parent is the last * visible modal dialog in the component tree. * <p> * If there is no visible modal dialog the root frame will be returned. * * @param parent * One component of the component tree. * @return the best dialog parent for a new JDialog. */ public static Window getBestDialogParent(Component parent) { Frame root = JOptionPane.getFrameForComponent(parent); return getLastModalChildOf(root); } /** * Gets the last visible modal child dialog of the specified window. * <p> * If there is no visible modal child the window itself will be returned. * * @param parent * The window to get the child from. * @return the last visible modal child dialog of the specified window. */ public static Window getLastModalChildOf(Window parent) { Window[] children = parent.getOwnedWindows(); for (Window child : children) { if (child instanceof Dialog) { Dialog dlg = (Dialog) child; if (dlg.isVisible() && dlg.isModal()) { return getLastModalChildOf(dlg); } } } // this is the last window return parent; } /** * Gets if a dialog child of the given window is modal. * * @param parent * The window to check the children of. * @return <code>True</code> if a child is modal, <code>false</code> * otherwise. * * @since 2.7 */ public static boolean containsModalDialogChild(Window parent) { Window[] children = parent.getOwnedWindows(); for (Window child : children) { if (containsModalDialogChild(child)) { return true; } } return (parent instanceof JDialog && parent.isVisible() && ((JDialog) parent) .isModal()); } /** * Gibt einen Button mit Icon und Schrift zurÔøΩck, der so initialisiert ist, * daÔøΩ man ihn gut fÔøΩr Symbolleisten nutzen kann (Rahmen nur bei Rollover * sichtbar usw.). * <P> * Wenn text und iconDateiname angegeben sind, dann wird text als TooltipText * gesetzt. * * @param text * Der Text des Buttons (Kann null sein, wenn der Button keinen Text * enthalten soll) * @param icon * Das Icon des Buttons (Kann ebenfalls null sein, wenn der Button * kein Icon enthalten soll). * @return button */ public static JButton createToolBarButton(String text, Icon icon) { final JButton btn; if (icon == null) { btn = new JButton(text); } else { btn = new JButton(icon); btn.setToolTipText(text); btn.setBorderPainted(false); btn.setMargin(ZERO_INSETS); btn.addMouseListener(new MouseAdapter() { @Override public void mouseEntered(MouseEvent e) { if (btn.isEnabled()) { btn.setBorderPainted(true); } } @Override public void mouseExited(MouseEvent e) { btn.setBorderPainted(false); } }); } btn.setFocusPainted(false); return btn; } /** * Gets the width of the specified String. * * @param str * The String to get the width for. * @param font * The font being the base of the measure. * @return the width of the specified String. */ public static int getStringWidth(Font font, String str) { if (str == null) { return 0; } FontMetrics metrics = HELPER_LABEL.getFontMetrics(font); return metrics.stringWidth(str); } /** * Gets the width of the specified char array. * * @param chars * The char array to get the width for. * @param offset * The offset where to start. * @param length * The length of the measure. * @param font * The font being the base of the measure. * @return the width of the specified char array. */ public static int getCharsWidth(Font font, char[] chars, int offset, int length) { if (chars == null) { return 0; } FontMetrics metrics = HELPER_LABEL.getFontMetrics(font); return metrics.charsWidth(chars, offset, length); } /** * Creates a text area that holds a help text. * * @param msg * The help text. * @return A text area containing the help text. */ public static JTextArea createHelpTextArea(String msg) { JTextArea descTA = new JTextArea(msg); descTA.setBorder(BorderFactory.createEmptyBorder()); descTA.setFont(new JLabel().getFont()); descTA.setEditable(false); descTA.setOpaque(false); descTA.setWrapStyleWord(true); descTA.setLineWrap(true); descTA.setFocusable(false); return descTA; } /** * Creates a Html EditorPane that holds a HTML-Help Text * * Links will be displayed and are clickable * * @param html * HTML-Text to display * @return EditorPane that holds a Help Text * @since 2.2 */ public static JEditorPane createHtmlHelpTextArea(String html) { return createHtmlHelpTextArea(html, new HyperlinkListener() { private String mTooltip; public void hyperlinkUpdate(HyperlinkEvent evt) { JEditorPane pane = (JEditorPane) evt.getSource(); if (evt.getEventType() == HyperlinkEvent.EventType.ENTERED) { mTooltip = pane.getToolTipText(); pane.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); if (evt.getURL() != null) { pane.setToolTipText(evt.getURL().toExternalForm()); } } if (evt.getEventType() == HyperlinkEvent.EventType.EXITED) { pane.setCursor(Cursor.getDefaultCursor()); pane.setToolTipText(mTooltip); } if (evt.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { URL url = evt.getURL(); if (url != null) { Launch.openURL(url.toString()); } } } }); } /** * Creates a Html EditorPane that holds a HTML-Help Text. * * Add a Listener if you want to have clickable Links * * @param html * HTML-Text to display * @param listener * Link-Listener for this HelpText * @return EditorPane that holds a Help Text * @since 2.2 */ public static JEditorPane createHtmlHelpTextArea(String html, HyperlinkListener listener) { // Quick "hack". Remove HTML-Code and replace it with Code that includes the // correct Font if (html.indexOf("<html>") >= 0) { html = html .substring(html.indexOf("<html>") + 6, html.indexOf("</html>")); } Font font = new JLabel().getFont(); html = "<html><div style=\"color:#000000;font-family:" + font.getName() + "; font-size:" + font.getSize() + ";\">" + html + "</div></html>"; final JEditorPane pane = new JEditorPane("text/html", html); pane.setBorder(BorderFactory.createEmptyBorder()); pane.setEditable(false); pane.setFont(font); pane.setOpaque(false); pane.setFocusable(false); if (listener != null) { pane.addHyperlinkListener(listener); } return pane; } /** * Moves Selected Items from one List to another * * @param fromList * Move from this List * @param toList * Move into this List * @return Moved Elements */ public static Object[] moveSelectedItems(JList fromList, JList toList) { DefaultListModel fromModel = (DefaultListModel) fromList.getModel(); DefaultListModel toModel = (DefaultListModel) toList.getModel(); // get the selection int[] selection = fromList.getSelectedIndices(); if (selection.length == 0) { return new Object[] {}; } Object[] objects = new Object[selection.length]; for (int i = 0; i < selection.length; i++) { objects[i] = fromModel.getElementAt(selection[i]); } // get the target insertion position int targetPos = toList.getMaxSelectionIndex(); if (targetPos == -1) { targetPos = toModel.getSize(); } else { targetPos++; } // suppress updates on both lists if (selection.length >= 5) { fromList.setModel(new DefaultListModel()); toList.setModel(new DefaultListModel()); } // move the elements for (int i = selection.length - 1; i >= 0; i--) { Object value = fromModel.remove(selection[i]); toModel.add(targetPos, value); } if (selection.length >= 5) { fromList.setModel(fromModel); toList.setModel(toModel); } // change selection of the fromList if (fromModel.getSize() > 0) { int newSelection = selection[0]; if (newSelection >= fromModel.getSize()) { newSelection = fromModel.getSize() - 1; } fromList.setSelectedIndex(newSelection); } if (selection.length >= 5) { fromList.repaint(); fromList.revalidate(); toList.repaint(); toList.revalidate(); } // change selection of the toList toList.setSelectionInterval(targetPos, targetPos + selection.length - 1); // ensure the selection is visible toList.ensureIndexIsVisible(toList.getMaxSelectionIndex()); toList.ensureIndexIsVisible(toList.getMinSelectionIndex()); return objects; } /** * Moves Selected Items from one List to another * * @param fromList * Move from this List * @param toList * Move into this List * @param row * The target row where to insert * @return Moved Elements */ public static Object[] moveSelectedItems(JList fromList, JList toList, int row) { DefaultListModel fromModel = (DefaultListModel) fromList.getModel(); DefaultListModel toModel = (DefaultListModel) toList.getModel(); // get the selection int[] selection = fromList.getSelectedIndices(); if (selection.length == 0) { return new Object[] {}; } Object[] objects = new Object[selection.length]; for (int i = 0; i < selection.length; i++) { objects[i] = fromModel.getElementAt(selection[i]); } // move the elements for (int i = selection.length - 1; i >= 0; i--) { Object value = fromModel.remove(selection[i]); toModel.insertElementAt(value, row); } // change selection of the fromList if (fromModel.getSize() > 0) { int newSelection = selection[0]; if (newSelection >= fromModel.getSize()) { newSelection = fromModel.getSize() - 1; } // fromList.setSelectedIndex(-1); } // change selection of the toList toList.setSelectionInterval(row, row + selection.length - 1); // ensure the selection is visible toList.ensureIndexIsVisible(toList.getMaxSelectionIndex()); toList.ensureIndexIsVisible(toList.getMinSelectionIndex()); return objects; } /** * Move selected Items in the JList * * @param list * Move Items in this List * @param row * The target row where to insert * @param sort * Dummy parameter, does nothing */ public static void moveSelectedItems(JList list, int row, boolean sort) { DefaultListModel model = (DefaultListModel) list.getModel(); // get the selection int[] selection = list.getSelectedIndices(); if (selection.length == 0) { return; } boolean lower = false; // Remove the selected items Object[] items = new Object[selection.length]; for (int i = selection.length - 1; i >= 0; i--) { if (selection[i] < row && !lower) { row = row - i - 1; lower = true; } items[i] = model.remove(selection[i]); } for (int i = items.length - 1; i >= 0; i--) { model.insertElementAt(items[i], row); } // change selection of the toList list.setSelectionInterval(row, row + selection.length - 1); // ensure the selection is visible list.ensureIndexIsVisible(list.getMaxSelectionIndex()); list.ensureIndexIsVisible(list.getMinSelectionIndex()); } /** * Move selected Items in the JList * * @param list * Move Items in this List * @param nrRows * Move Items nrRows up/down */ public static void moveSelectedItems(JList list, int nrRows) { DefaultListModel model = (DefaultListModel) list.getModel(); // get the selection int[] selection = list.getSelectedIndices(); if (selection.length == 0) { return; } // Remove the selected items Object[] items = new Object[selection.length]; for (int i = selection.length - 1; i >= 0; i--) { items[i] = model.remove(selection[i]); } // insert the elements at the target position int targetPos = selection[0] + nrRows; targetPos = Math.max(targetPos, 0); targetPos = Math.min(targetPos, model.getSize()); for (int i = 0; i < items.length; i++) { model.add(targetPos + i, items[i]); } // change selection of the toList list.setSelectionInterval(targetPos, targetPos + selection.length - 1); // ensure the selection is visible list.ensureIndexIsVisible(list.getMaxSelectionIndex()); list.ensureIndexIsVisible(list.getMinSelectionIndex()); } /** * Scale Icons to a specific width. The aspect ratio is kept. * * @param icon * The icon to scale. * @param newWidth * The new width of the icon. * @return The scaled Icon. */ public static Icon scaleIcon(Icon icon, int newWidth) { return scaleIcon(icon, newWidth, (int) ((newWidth / (float) icon .getIconWidth()) * icon.getIconHeight())); } /** * Scales Icons to a specific size * * @param icon * Icon that should be scaled * @param x * new X-Value * @param y * new Y-Value * @return Scaled Icon */ public static Icon scaleIcon(Icon icon, int x, int y) { int currentWidth = icon.getIconWidth(); int currentHeight = icon.getIconHeight(); if ((currentWidth == x) && (currentHeight == y)) { return icon; } try { // Create Image with Icon BufferedImage iconimage = new BufferedImage(x, y, BufferedImage.TYPE_INT_ARGB); Graphics2D g2 = iconimage.createGraphics(); g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC); g2.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); AffineTransform z = g2.getTransform(); z.scale((double) x / currentWidth, (double) y / currentHeight); g2.setTransform(z); icon.paintIcon(null, g2, 0, 0); g2.dispose(); // Return new Icon return new ImageIcon(iconimage); } catch (Exception ex) { ex.printStackTrace(); } return icon; } /** * Scales an image to a specific size and returns an BufferedImage * * @param img * Scale this IMage * @param x * new X-Value * @param y * new Y-Value * @return Scaled BufferedImage * * @since 2.5 */ public static BufferedImage scaleIconToBufferedImage(BufferedImage img, int x, int y) { return scaleIconToBufferedImage(img, x, y, img.getType()); } /** * Scales an image to a specific size and returns an BufferedImage * * @param img * Scale this IMage * @param x * new X-Value * @param y * new Y-Value * @param type The type of the image. * @return Scaled BufferedImage * * @since 2.7 */ public static BufferedImage scaleIconToBufferedImage(BufferedImage img, int x, int y, int type) { // Scale Image Image image = img.getScaledInstance(x, y, Image.SCALE_SMOOTH); BufferedImage im = new BufferedImage(x, y, type); Graphics2D g2 = im.createGraphics(); g2.drawImage(image, null, null); g2.dispose(); im.flush(); return im; } /** * Creates a scaled Version of the Icon. * * The scaled Version will have a Background and a Border. * * @param ic * @return ImageIcon * @since 2.1 */ public static ImageIcon createChannelIcon(Icon ic) { BufferedImage img = new BufferedImage(42, 22, BufferedImage.TYPE_INT_RGB); if (ic == null) { ic = new ImageIcon("./imgs/tvbrowser16.png"); } int height = 20; int width = 40; if ((ic.getIconWidth() != 0) && (ic.getIconHeight() != 0)) { double iWidth = ic.getIconWidth(); double iHeight = ic.getIconHeight(); if (iWidth / iHeight < 2.0) { width = new Double(iWidth * (20.0 / iHeight)).intValue(); } else { height = new Double(iHeight * (40.0 / iWidth)).intValue(); } } ic = scaleIcon(ic, width, height); Graphics2D g = img.createGraphics(); g.setColor(Color.WHITE); g.fillRect(1, 1, 40, 20); int x = 1 + 20 - ic.getIconWidth() / 2; int y = 1 + 10 - ic.getIconHeight() / 2; ic.paintIcon(null, g, x, y); g.setColor(Color.BLACK); g.drawRect(0, 0, 42, 22); return new ImageIcon(img); } /** * Registers the escape key as close key for a component. * * @param component * The component to close on pressing escape key. */ public static void registerForClosing(final WindowClosingIf component) { Action a = new AbstractAction() { private static final long serialVersionUID = 1L; public void actionPerformed(ActionEvent e) { component.close(); } }; if (OperatingSystem.isMacOs()) { // Add MacOS Apple+W for Closing of Dialogs KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_W, InputEvent.META_DOWN_MASK); component.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW) .put(stroke, "CLOSE_ON_APPLE_W"); component.getRootPane().getActionMap().put("CLOSE_ON_APPLE_W", a); stroke = KeyStroke.getKeyStroke(KeyEvent.VK_Q, InputEvent.META_DOWN_MASK); component.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW) .put(stroke, "CLOSE_COMPLETE_ON_APPLE"); component.getRootPane().getActionMap().put("CLOSE_COMPLETE_ON_APPLE", new AbstractAction() { public void actionPerformed(ActionEvent e) { MainFrame.getInstance().quit(); } }); } KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0); component.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put( stroke, "CLOSE_ON_ESCAPE"); component.getRootPane().getActionMap().put("CLOSE_ON_ESCAPE", a); } /** * set the size of a dialog, but never sizes it smaller than the preferred * size * * @param dialog * dialog to be sized * @param width * wanted width * @param height * wanted height */ public static void setSize(JDialog dialog, int width, int height) { dialog.pack(); Dimension size = dialog.getMinimumSize(); if (width > size.width) { size.width = width; } if (height > size.height) { size.height = height; } dialog.setSize(size); } }

The table below shows all metrics for UiUtilities.java.

MetricValueDescription
BLOCKS85.00Number of blocks
BLOCK_COMMENT25.00Number of block comment lines
COMMENTS299.00Comment lines
COMMENT_DENSITY 0.80Comment density
COMPARISONS60.00Number of comparison operators
CYCLOMATIC82.00Cyclomatic complexity
DECL_COMMENTS26.00Comments in declarations
DOC_COMMENT241.00Number of javadoc comment lines
ELOC372.00Effective lines of code
EXEC_COMMENTS32.00Comments in executable code
EXITS107.00Procedure exits
FUNCTIONS27.00Number of function declarations
HALSTEAD_DIFFICULTY86.71Halstead difficulty
HALSTEAD_EFFORT 0.00Halstead effort
INTERFACE_COMPLEXITY92.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 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 1.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 0.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
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
JAVA007610.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 1.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 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 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 1.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 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
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 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 1.00JAVA0173 Unused method parameter
JAVA0174 1.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 4.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 1.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 2.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
LINES844.00Number of lines in the source file
LINE_COMMENT33.00Number of line comments
LOC450.00Lines of code
LOGICAL_LINES275.00Number of statements
LOOPS 8.00Number of loops
NEST_DEPTH 4.00Maximum nesting depth
OPERANDS1284.00Number of operands
OPERATORS2244.00Number of operators
PARAMS50.00Number of formal parameter declarations
PROGRAM_LENGTH3528.00Halstead program length
PROGRAM_VOCAB437.00Halstead program vocabulary
PROGRAM_VOLUME 0.00Halstead program volume
RETURNS42.00Number of return points from functions
SIZE25178.00Size of the file in bytes
UNIQUE_OPERANDS385.00Number of unique operands
UNIQUE_OPERATORS52.00Number of unique operators
WHITESPACE95.00Number of whitespace lines