DawnParser.java

Index Score
org.jext.dawn
Jext

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
CYCLOMATICCyclomatic complexity
RETURNSNumber of return points from functions
DOC_COMMENTNumber of javadoc comment lines
JAVA0115JAVA0115 Incorrect javadoc: no @throws or @exception tag for 'exception'
INTERFACE_COMPLEXITYInterface complexity
COMMENTSComment lines
LINESNumber of lines in the source file
FUNCTIONSNumber of function declarations
SIZESize of the file in bytes
COMPARISONSNumber of comparison operators
LOCLines of code
JAVA0266JAVA0266 Use of System.out
OPERATORSNumber of operators
LOGICAL_LINESNumber of statements
ELOCEffective lines of code
PROGRAM_LENGTHHalstead program length
EXITSProcedure exits
OPERANDSNumber of operands
BLOCKSNumber of blocks
LINE_COMMENTNumber of line comments
UNIQUE_OPERANDSNumber of unique operands
PROGRAM_VOCABHalstead program vocabulary
JAVA0108JAVA0108 Incorrect javadoc: no @param tag for 'parameter'
PARAMSNumber of formal parameter declarations
JAVA0177JAVA0177 Variable declaration missing initializer
WHITESPACENumber of whitespace lines
JAVA0123JAVA0123 Use all three components of for loop
JAVA0007JAVA0007 Should not declare public field
UNIQUE_OPERATORSNumber of unique operators
JAVA0116JAVA0116 Missing javadoc: field 'field'
JAVA0117JAVA0117 Missing javadoc: method 'method'
NEST_DEPTHMaximum nesting depth
PROGRAM_VOLUMEHalstead program volume
JAVA0136JAVA0136 N methods defined in class (maximum: M)
JAVA0032JAVA0032 Switch statement missing default
JAVA0174JAVA0174 Assigned local variable never used
JAVA0176JAVA0176 Local variable name does not have required form
JAVA0126JAVA0126 Method declares unchecked exception in throws
JAVA0179JAVA0179 Local variable hides visible field
EXEC_COMMENTSComments in executable code
LOOPSNumber of loops
JAVA0100JAVA0100 Class contains N non-final fields (maximum: M)
JAVA0267JAVA0267 Use of System.err
JAVA0075JAVA0075 Method parameter hides field
JAVA0145JAVA0145 Tab character used in source file
/* * 11:58:05 07/08/00 * * DawnParser.java - Dawn is a RPN based scripting language * Copyright (C) 2000 Romain Guy * romain.guy@jext.org * www.jext.org * * 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 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.jext.dawn; import java.io.*; import java.util.Stack; import java.util.Vector; import java.util.Hashtable; import java.util.Enumeration; /** * <code>DawnParser</code> is the Dawn scripting language interpreter. * Dawn is a language based on RPN. Dawn is also a very modulary language. * Basic usage of Dawn is:<br> * <pre> * DawnParser.init(); * // code is a String containing the script * DawnParser parser = new DawnParser(new StringReader(code)); * try * { * parser.exec(); * } catch (DawnRuntimeException dre) { * System.err.println(dre.getMessage()); * } * </pre><p> * Note the call to <code>init()</code>. You may not want to call this method, * but if you don't, then Dawn will provide NO FUNCTION AT ALL. Even basic ones, * like + - * drop sto rcl, won't work !! This is due to the fact Dawn can be * entirely customized.<br> * In fact, <code>init()</code> simply install basic packages (loop, test, * util, stack, math, err, io, string, naming). But you can load only one, or * many, of them and also install your own packages to replace default ones.<br> * You may also load extra packages with the: <code>installPackage()</code> method.<p> * Read the documentation for further informations. * @author Romain Guy * @version 1.1.1 */ public class DawnParser { /** Gives Dawn interpreter version numbering */ public static final String DAWN_VERSION = "Dawn v1.1.1 final [$12:12:55 07/08/00]"; /** Identifier for a stack element containing a numeric value */ public static final int DAWN_NUMERIC_TYPE = 0; /** Identifier for a stack element containing a string */ public static final int DAWN_STRING_TYPE = 1; /** Identifier for a stack element defining a literal (variable name) */ public static final int DAWN_LITERAL_TYPE = 2; /** Identifier for a stack element defining an array */ public static final int DAWN_ARRAY_TYPE = 3; // global functions loaded from packages private static Hashtable functions = new Hashtable(200); // global variables private static Hashtable variables = new Hashtable(); // installed packages private static Vector installedPackages = new Vector(); private static Vector installedRuntimePackages = new Vector(); // init flag private static boolean isInited = false; // it true, the parser stops private boolean stopped = false; // properties set private Hashtable properties = new Hashtable(); // stream tokenizer: this is Dawn parser engine private StreamTokenizer st; // the stack where datas are put private Stack stack; // functions created on runtime private Hashtable runtimeFunctions; // variables created on runtime private Hashtable runtimeVariables; // line number in the script public int lineno = 1; // standard streams public PrintStream out = System.out; public PrintStream err = System.err; public InputStream in = System.in ; /** * Initializes Dawn default packages. This is strongly recommended * to call this method before any use of the parser. */ public static void init() { System.out.println(DAWN_VERSION); installPackage("dawn.array"); installPackage("dawn.err"); installPackage("dawn.io"); installPackage("dawn.javaccess"); installPackage("dawn.loop"); installPackage("dawn.math"); installPackage("dawn.naming"); installPackage("dawn.stack"); installPackage("dawn.string"); installPackage("dawn.test"); installPackage("dawn.util"); System.out.println(); isInited = true; } /** * Returns true if the parser has already been initialized. * Dawn is considered initialized when a call to <code>init()</code> * has been made. */ public static boolean isInitialized() { return isInited; } /** * Installs a package from Dawn archive. * @param packageName The package to load */ public static void installPackage(String packageName) { installPackage(DawnParser.class, packageName, null); } /** * Installs a package specific to a given class. The class will give infos * to both load the package file and the package classes. * @param loader The <code>Class</code> which calls this, if the class is * not part of Dawn standard package * @param packageName The package to load */ public static void installPackage(Class loader, String packageName) { installPackage(loader, packageName, null); } /** * Installs a package specific to a given class. The class will give infos * to both load the package file and the package classes. * @param loader The <code>Class</code> which calls this, if the class is * not part of Dawn standard package * @param packageName The package to load * @param parser If this parameter is not set to null, the package is loaded * as runtime package */ public static void installPackage(Class loader, String packageName, DawnParser parser) { if (packageName == null || loader == null) return; // check first if the package is already installed // (case of packages dependencies) if (installedPackages.contains(packageName)) { System.out.println("Dawn:<installPackage>:package " + packageName + " is already installed"); return; } // get classes to be loaded String[] classes = getClasses(loader, packageName); if (classes == null) { System.out.println("Dawn:<installPackage:err>:couldn't install " + packageName); return; } Object obj = null; Class _class = null; String className = null; Function _function = null; CodeSnippet _codeFunction = null; // ClassLoader classLoader = loader.getClassLoader(); try { // load classes for (int i = 0; i < classes.length; i++) { className = classes[i]; _class = Class.forName(className); //, true, classLoader); if (_class == null) { // if class is null, we get rid of it System.out.println("Dawn:<installPackage:err>:couldn't find class " + className + " in package " + packageName); continue; } // we create an instance of the class to check it obj = _class.newInstance(); if (obj instanceof Function) { // if it is a function, then we add it to the list _function = (Function) obj; (parser == null ? functions : parser.getRuntimeFunctions()).put(_function.getName(), _function); } else if (obj instanceof CodeSnippet) { // it is a coded function, we build it _codeFunction = (CodeSnippet) obj; if (parser == null) createGlobalFunction(_codeFunction.getName(), _codeFunction.getCode()); else parser.createRuntimeFunction(_codeFunction.getName(), _codeFunction.getCode()); } } } catch(Exception e) { System.out.println("Dawn:<installPackage:err>:couldn't load class " + className + " from package " + packageName); System.out.println("Dawn:<installPackage:err>:package " + packageName + " wasn't loaded"); return; } System.out.println("Dawn:<installPackage>:\t" + packageName + (packageName.length() < 8 ? "\t\t" : "\t") + "successfully installed"); (parser == null ? installedPackages : installedRuntimePackages).addElement(packageName); } // reads a package file and get classes-to-be-loaded names. it also checks package // dependencies. if a dependency is found, requested package is loaded private static String[] getClasses(Class loader, String packageName) { Vector buf = new Vector(); InputStream _in = loader.getResourceAsStream(packageName); if (_in == null) return null; BufferedReader in = new BufferedReader(new InputStreamReader(_in)); String line; try { while ((line = in.readLine()) != null) { line = line.trim(); if (line.length() == 0) continue; if (line.charAt(0) == '#') continue; else if (line.startsWith("needs")) { int index = line.indexOf(' '); if (index == -1 || index + 1 == line.length()) { System.out.println("Dawn:<installPackage:err>:package " + packageName + " contains a bad \'needs\' statement"); continue; } installPackage(loader, line.substring(index + 1), null); } else buf.addElement(line); } in.close(); } catch (IOException ioe) { return null; } if (buf.size() > 0) { String[] classes = new String[buf.size()]; buf.copyInto(classes); buf = null; return classes; } else return null; } /** * Creates a new parser. * @param in A <code>Reader</code> which will deliver the script to the parser */ public DawnParser(Reader in) { st = createTokenizer(in); stack = new Stack(); runtimeFunctions = new Hashtable(); runtimeVariables = new Hashtable(); } /** * Sets the parser print stream. Default packages may * pass informations through this stream (println function * for instance). * @param out The new <code>PrintStream</code> */ public void setOut(PrintStream out) { this.out = out; } /** * Sets the parser error print stream. Default packages may * pass informations through this stream. * @param err The new <code>PrintStream</code> used for errors */ public void setErr(PrintStream err) { this.err = err; } /** * Sets the parser input stream. Default packages may * pass informations through this stream (inputLine...) * @param out The new <code>OutputStream</code> */ public void setIn(InputStream in) { this.in = in; } /** * Sets the <code>StreamTokenizer</code> used to execute a script. * It is HIGHLY recommended NOT TO CALL this without a very good * reason. * @param _st The new stream where to get the script from */ public void setStream(StreamTokenizer _st) { st = _st; } /** * Returns current <code>StreamTokenizer</code>. It is mostly used * by functions to parse the script further. 'if' statement from * test package is a good example (see also for and while from the * loop package). */ public StreamTokenizer getStream() { return st; } /** * Creates a new StreamTokenizer, setting its properties according to * the Dawn scripting language specifications. the stream is built * from a Reader which is most of the time a StringReader. * @param in The <code>Reader</code> which will deliver the script */ public StreamTokenizer createTokenizer(Reader in) { StreamTokenizer st = new StreamTokenizer(in); st.resetSyntax(); st.eolIsSignificant(true); st.whitespaceChars(0, ' '); st.wordChars(' ' + 1, 255); st.quoteChar('"'); st.quoteChar('\''); st.commentChar('#'); st.parseNumbers(); st.eolIsSignificant(true); return st; } /** * Returns an Hashtable containing all the current global functions. */ public static Hashtable getFunctions() { return functions; } /** * Returns the set of runtimes functions. This is needed by installPackage() * when the keyword 'needsGlobal' is used in a script. */ public Hashtable getRuntimeFunctions() { return runtimeFunctions; } /** * Returns the stack which containes all the current availables datas. */ public Stack getStack() { return stack; } /** * Checks if a given variable name is valid or not. * @parma function The <code>Function</code> which called this method * @param var The variable name to be tested */ public void checkVarName(Function function, String var) throws DawnRuntimeException { if (var.equals("needs") || var.equals("needsGlobal")) throw new DawnRuntimeException(function, this, "you cannot use reserved keyword" + "\'needs\' or \'needsGlobal\'"); boolean word = false; for (int i = 0; i < var.length(); i++) { if (Character.isDigit(var.charAt(i)) && !word) { throw new DawnRuntimeException(function, this, "bad variable/function name:" + var); } else word = true; } } /** * Checks if stack contains enough datas to feed a function. * @parma function The <code>Function</code> which called this method * @param nb The amount of arguments needed */ public void checkArgsNumber(Function function, int nb) throws DawnRuntimeException { if (stack.size() < nb) throw new DawnRuntimeException(function, this, "bad arguments number, " + nb + " are required"); } /** * Checks if the stack is empty. * @parma function The <code>Function</code> which called this method */ public void checkEmpty(Function function) throws DawnRuntimeException { if (stack.isEmpty()) throw new DawnRuntimeException(function, this, "empty stack"); } /** * Checks if a given level is bound in the limits of the stack. * @parma function The <code>Function</code> which called this method * @param level The level to be tested */ public void checkLevel(Function function, int level) throws DawnRuntimeException { if (level >= stack.size() || level < 0) throw new DawnRuntimeException(function, this, "stack level out of bounds:" + level); } /** * Sets a property in the parser. Properties are used by external functions * to store objects they may need later. * @param name An <code>Object</code> describing the property. It stands for the key * @param property The property value */ public void setProperty(Object name, Object property) { if (name == null || property == null) return; properties.put(name, property); } /** * Returns a property according a given key. * @param name The property key */ public Object getProperty(Object name) { if (name == null) return null; return properties.get(name); } /** * Unsets (remove) a given property. */ public void unsetProperty(Object name) { properties.remove(name); } /** * Stops the parser. */ public void stop() { stopped = true; } /** * Executes loaded script. */ public void exec() throws DawnRuntimeException { if (st == null) throw new DawnRuntimeException(this, "parser cannot execute a non-existent script"); try { for( ; ; ) { if (stopped) return; switch(st.nextToken()) { case StreamTokenizer.TT_EOL: lineno++; break; case StreamTokenizer.TT_EOF: // end of script return; case StreamTokenizer.TT_NUMBER: stack.push(new Double(st.nval)); break; case StreamTokenizer.TT_WORD: if (st.sval.equals("needs") || st.sval.equals("needsGlobal")) { int keyWord = (st.sval.equals("needs") ? 0 : 1); if (st.nextToken() == StreamTokenizer.TT_WORD) { if (keyWord == 1) installPackage(st.sval); else installPackage(DawnParser.class, st.sval, this); break; } else { st.pushBack(); throw new DawnRuntimeException(this, "bad usage of \'needs\' or \'needsGlobal\'" + "reserved keyword"); } } Function func = (Function) functions.get(st.sval); if (func != null) func.invoke(this); else { func = (Function) runtimeFunctions.get(st.sval); if (func != null) func.invoke(this); else stack.push(st.sval); } break; case '-': Function fc; if (st.nextToken() == StreamTokenizer.TT_WORD) { fc = (Function) functions.get('-' + st.sval); if (fc == null) { fc = (Function) runtimeFunctions.get('-' + st.sval); if (fc == null) { st.pushBack(); fc = (Function) functions.get("-"); } } } else { st.pushBack(); fc = (Function) functions.get("-"); } if (fc != null) fc.invoke(this); break; case '"': case '\'': pushString(st.sval); break; } } } catch (IOException ioe) { throw new DawnRuntimeException(this, "unexpected error occured during parsing"); } } /** * Returns the <code>Hashtable</code> which contains the local variables. */ public Hashtable getVariables() { return runtimeVariables; } /** * Returns the <code>Hashtable</code> which contains the global variables. */ public Hashtable getGlobalVariables() { return variables; } /** * Returns the value of a given variable. Note that global variables got * priority on runtime ones. * @param var The variable to be recalled */ public Object getVariable(String var) { Object obj = variables.get(var); if (obj == null) obj = runtimeVariables.get(var); return obj; } /** * Sets a runtime variable. Runtime variables are stored temporarily. After * the execution of the script, they are flushed. * @param var The variable name * @param value An <code>Object</code> containg the variable value */ public void setVariable(String var, Object value) { if (value == null) runtimeVariables.remove(var); else if (!functions.contains(var) && !runtimeFunctions.contains(var)) runtimeVariables.put(var, value); } /** * Sets a global variable. Global variables are stored permanently, until the * JVM is killed or until the method <code>clearGlobalVariables()</code> is called. * @param var The variable name * @param value An <code>Object</code> containg the variable value */ public static void setGlobalVariable(String var, Object value) { if (value == null) variables.remove(var); else if (!functions.contains(var)) variables.put(var, value); } /** * Clears all the global variables. */ public static void clearGlobalVariables() { variables.clear(); } /** * Returns current line number in the script. */ public int lineno() { // return st.lineno(); return lineno; } /** * Returns a <code>String</code> containing a simple description of the current stack * state. All the levels are shown, each labeled by its level number. */ public String dump() { Object o; StringBuffer buf = new StringBuffer(); for (int i = 0; i < stack.size(); i++) { buf.append(stack.size() - 1 - i).append(':'); o = stack.elementAt(i); if (o instanceof Vector) buf.append("array[").append(((Vector) o).size()).append(']'); else buf.append(o); buf.append('\n'); } return buf.toString(); } /** * Get topmost element of the stack and return is as a double value * if it can. Otherwise, an exception is thrown. In any case, the * element is removed from the stack. */ public double popNumber() throws DawnRuntimeException { checkEmpty(null); Object obj = stack.pop(); if (!(obj instanceof Double)) { throw new DawnRuntimeException(this, "bad argument type"); } return ((Double) obj).doubleValue(); } /** * Get topmost element of the stack and return is as a double value * if it can. Otherwise, an exception is thrown. */ public double peekNumber() throws DawnRuntimeException { checkEmpty(null); Object obj = stack.peek(); if (!(obj instanceof Double)) { throw new DawnRuntimeException(this, "bad argument type"); } return ((Double) obj).doubleValue(); } /** * Pushes a number on top of the stack. * @param number The number to be put on the stack */ public void pushNumber(double number) { stack.push(new Double(number)); } /** * Get the topmost element of the stack and returns it as * a <code>String</code>. If the string is enclosed by " quote * characters, they are removed. The element is removed from the stack. */ public String popString() throws DawnRuntimeException { checkEmpty(null); String str = stack.pop().toString(); if (str.length() != 0 && str.startsWith("\"") && str.endsWith("\"")) str = str.substring(1, str.length() - 1); return str; } /** * Get the topmost element of the stack and returns it as * a <code>String</code>. If the string is enclosed by " quote * characters, they are removed. */ public String peekString() throws DawnRuntimeException { checkEmpty(null); String str = stack.peek().toString(); if (str.length() != 0 && str.startsWith("\"") && str.endsWith("\"")) str = str.substring(1, str.length() - 1); return str; } /** * Puts a <code>String</code> on top of the stack. * @param str The string to be put on the stack */ public void pushString(String str) { if (str.length() == 2 && str.charAt(0) == '\"' && str.charAt(1) == '\"') stack.push("\"\""); else stack.push('"' + str + '"'); } /** * Gets topmost stack element and returns it as a <code>Vector</code> * which is the Java object for Dawn arrays. The element is removed * from the stack. */ public Vector popArray() throws DawnRuntimeException { checkEmpty(null); Object obj = stack.pop(); if (!(obj instanceof Vector)) { throw new DawnRuntimeException(this, "bad argument type"); } return (Vector) obj; } /** * Gets topmost stack element and returns it as a <code>Vector</code> * which is the Java object for Dawn arrays. */ public Vector peekArray() throws DawnRuntimeException { checkEmpty(null); Object obj = stack.peek(); if (!(obj instanceof Vector)) { throw new DawnRuntimeException(this, "bad argument type"); } return (Vector) obj; } /** * Pushes an array on top of the stack. * @param array The array to be put on the stack */ public void pushArray(Vector array) { stack.push(array); } /** * Returns topmost objet of the stack and remove it. */ public Object pop() throws DawnRuntimeException { checkEmpty(null); return stack.pop(); } /** * Returns topmost object of the stack. */ public Object peek() throws DawnRuntimeException { checkEmpty(null); return stack.peek(); } /** * Puts an object on the top of the stack. * @param obj The object to be put on the top */ public void push(Object obj) { stack.push(obj); } /** * Tells wether topmost object is a numeric value or not. */ public boolean isTopNumeric() { return stack.peek() instanceof Double; } /** * Tells wether topmost object is a string or not. */ public boolean isTopString() { Object obj = stack.peek(); if (obj instanceof String) { String str = (String) obj; if (str.startsWith("\"") && str.endsWith("\"")) return true; } return false; } /** * Tells wether topmost object is an array or not. */ public boolean isTopArray() { return stack.peek() instanceof Vector; } /** * Tells wether topmost object is a literal identifier or not. */ public boolean isTopLiteral() { return !isTopString() && !isTopNumeric() && !isTopArray(); } /** * Returns topmost stack element type. */ public int getTopType() { if (isTopNumeric()) return DAWN_NUMERIC_TYPE; else if (isTopString()) return DAWN_STRING_TYPE; else if (isTopArray()) return DAWN_ARRAY_TYPE; else return DAWN_LITERAL_TYPE; } /** * Adds given function to the global functions list. * @param function The <code>Function</code> to be added */ public static void addGlobalFunction(Function function) { if (function == null) return; String name = function.getName(); if (!name.equals("needs") && !name.equals("needsGlobal")) functions.put(name, function); } /** * Adds given function to the runtime functions list. * @param function The <code>Function</code> to be added */ public void addRuntimeFunction(Function function) { if (function == null) return; String name = function.getName(); if (!name.equals("needs") && !name.equals("needsGlobal")) runtimeFunctions.put(name, function); } /** * Creates dynamically a function which can execute the Dawn script * passed in parameter. * @param code The Dawn code which will be executed by the returned * function on invoke() call */ public Function createOnFlyFunction(final String code) { return new Function() { public void invoke(DawnParser parser) throws DawnRuntimeException { StreamTokenizer _st = st; Hashtable _variables = (Hashtable) runtimeVariables.clone(); st = createTokenizer(new StringReader(code)); exec(); st = _st; // copy changed variables String _varName; for (Enumeration e = runtimeVariables.keys(); e.hasMoreElements(); ) { _varName = (String) e.nextElement(); if (_variables.get(_varName) != null) { _variables.put(_varName, runtimeVariables.get(_varName)); } } runtimeVariables = (Hashtable) _variables.clone(); } }; } /** * Creates dynamically a function which can execute the Dawn script * passed in parameter. The function is added to the global functions * list and not returned. * @param name Function Dawn name * @param code The Dawn code which will be executed by function */ public static void createGlobalFunction(String name, final String code) { if (name == null || name.length() == 0 || name.equals("needs") || name.equals("needsGlobal") || code == null) return; functions.put(name, new Function(name) { public void invoke(DawnParser parser) throws DawnRuntimeException { StreamTokenizer _st = parser.getStream(); parser.setStream(parser.createTokenizer(new StringReader(code))); parser.exec(); parser.setStream(_st); } }); } /** * Creates dynamically a function which can execute the Dawn script * passed in parameter. The function is added to the runtime functions * list and not returned. * @param name Function Dawn name * @param code The Dawn code which will be executed by function */ public void createRuntimeFunction(String name, final String code) { if (name == null || name.length() == 0 || name.equals("needs") || name.equals("needsGlobal") || code == null) return; runtimeFunctions.put(name, new Function(name) { public void invoke(DawnParser parser) throws DawnRuntimeException { StreamTokenizer _st = st; st = createTokenizer(new StringReader(code)); exec(); st = _st; } }); } } // End of DawnParser.java

The table below shows all metrics for DawnParser.java.

MetricValueDescription
BLOCKS93.00Number of blocks
BLOCK_COMMENT22.00Number of block comment lines
COMMENTS322.00Comment lines
COMMENT_DENSITY 0.79Comment density
COMPARISONS87.00Number of comparison operators
CYCLOMATIC160.00Cyclomatic complexity
DECL_COMMENTS75.00Comments in declarations
DOC_COMMENT273.00Number of javadoc comment lines
ELOC406.00Effective lines of code
EXEC_COMMENTS11.00Comments in executable code
EXITS70.00Procedure exits
FUNCTIONS58.00Number of function declarations
HALSTEAD_DIFFICULTY94.50Halstead difficulty
HALSTEAD_EFFORT 0.00Halstead effort
INTERFACE_COMPLEXITY147.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 1.00JAVA0005 Imports not in specified order
JAVA0006 0.00JAVA0006 Empty finally block
JAVA0007 4.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 1.00JAVA0032 Switch statement missing default
JAVA0033 0.00JAVA0033 default: not last case in switch statement
JAVA003445.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 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 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 1.00JAVA0075 Method parameter hides field
JAVA0076 0.00JAVA0076 Use of magic number
JAVA0077 0.00JAVA0077 Private field not used in declaring class
JAVA0078 0.00JAVA0078 Floating point values compared with ==
JAVA0079 0.00JAVA0079 Use of instance to reference static member
JAVA0080 0.00JAVA0080 Import declaration not used
JAVA0081 0.00JAVA0081 Boolean literal in comparison
JAVA0082 0.00JAVA0082 Unnecessary widening cast
JAVA0083 0.00JAVA0083 Unnecessary instanceof test
JAVA0084 0.00JAVA0084 Should use compound assignment operator
JAVA0085 0.00JAVA0085 Use of sun.* class
JAVA0087 0.00JAVA0087 Use of Thread.sleep()
JAVA0089 0.00JAVA0089 Use of restricted package
JAVA0092 0.00JAVA0092 Use of restricted type
JAVA0093 0.00JAVA0093 Redundant assignment
JAVA0094 0.00JAVA0094 Field hides a superclass field
JAVA0095 0.00JAVA0095 Uninitialized private field
JAVA0096 0.00JAVA0096 Field in nested class hides outer field
JAVA0098 0.00JAVA0098 Minimize use of implicit field initializers
JAVA0100 1.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 6.00JAVA0108 Incorrect javadoc: no @param tag for 'parameter'
JAVA0109 1.00JAVA0109 Incorrect javadoc: no parameter 'parameter'
JAVA011026.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 0.00JAVA0114 Incorrect javadoc: no @version tag
JAVA011513.00JAVA0115 Incorrect javadoc: no @throws or @exception tag for 'exception'
JAVA0116 4.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 2.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 1.00JAVA0166 Generic exception caught
JAVA0167 0.00JAVA0167 ThreadDeath not rethrown
JAVA0169 0.00JAVA0169 Unnecessary catch block: exception 'exception'
JAVA0170 0.00JAVA0170 Caught exception not derived from java.lang.Exception
JAVA0171 0.00JAVA0171 Unused local variable
JAVA0173 0.00JAVA0173 Unused method parameter
JAVA0174 1.00JAVA0174 Assigned local variable never used
JAVA0175 0.00JAVA0175 Successive assignment to variable
JAVA0176 9.00JAVA0176 Local variable name does not have required form
JAVA0177 4.00JAVA0177 Variable declaration missing initializer
JAVA0179 1.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 1.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 4.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()
JAVA026610.00JAVA0266 Use of System.out
JAVA0267 1.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
LINES1050.00Number of lines in the source file
LINE_COMMENT27.00Number of line comments
LOC584.00Lines of code
LOGICAL_LINES257.00Number of statements
LOOPS 6.00Number of loops
NEST_DEPTH 6.00Maximum nesting depth
OPERANDS1085.00Number of operands
OPERATORS2201.00Number of operators
PARAMS44.00Number of formal parameter declarations
PROGRAM_LENGTH3286.00Halstead program length
PROGRAM_VOCAB364.00Halstead program vocabulary
PROGRAM_VOLUME 0.00Halstead program volume
RETURNS103.00Number of return points from functions
SIZE28729.00Size of the file in bytes
UNIQUE_OPERANDS310.00Number of unique operands
UNIQUE_OPERATORS54.00Number of unique operators
WHITESPACE144.00Number of whitespace lines