Permalink
Browse files

* findbugs and checkstyle

* 1.5 compatibility
  • Loading branch information...
1 parent 851b8f6 commit 31dbd8d7605083df9109d0de84171fe038022501 @neurolabs committed May 3, 2009
Showing with 475 additions and 456 deletions.
  1. +11 −0 CHANGELOG
  2. +3 −3 src/henplus/Command.java
  3. +34 −35 src/henplus/CommandDispatcher.java
  4. +7 −7 src/henplus/HenPlus.java
  5. +14 −14 src/henplus/PasswordEraserThread.java
  6. +4 −4 src/henplus/SQLMetaDataBuilder.java
  7. +4 −4 src/henplus/SQLSession.java
  8. +7 −7 src/henplus/SQLStatementSeparator.java
  9. +4 −4 src/henplus/SessionManager.java
  10. +2 −2 src/henplus/SigIntHandler.java
  11. +7 −1 src/henplus/Version.java.in
  12. +2 −2 src/henplus/commands/AboutCommand.java
  13. +2 −2 src/henplus/commands/AliasCommand.java
  14. +20 −20 src/henplus/commands/ConnectCommand.java
  15. +20 −20 src/henplus/commands/DescribeCommand.java
  16. +21 −21 src/henplus/commands/DriverCommand.java
  17. +30 −33 src/henplus/commands/DumpCommand.java
  18. +19 −19 src/henplus/commands/FileCompletionIterator.java
  19. +1 −1 src/henplus/commands/HelpCommand.java
  20. +11 −11 src/henplus/commands/ImportCommand.java
  21. +11 −9 src/henplus/commands/KeyBindCommand.java
  22. +10 −10 src/henplus/commands/ListUserObjectsCommand.java
  23. +2 −2 src/henplus/commands/PluginCommand.java
  24. +49 −47 src/henplus/commands/ResultSetRenderer.java
  25. +2 −2 src/henplus/commands/SQLCommand.java
  26. +3 −3 src/henplus/commands/SetCommand.java
  27. +1 −1 src/henplus/commands/ShellCommand.java
  28. +6 −5 src/henplus/commands/SystemInfoCommand.java
  29. +3 −3 src/henplus/commands/TimeRenderer.java
  30. +10 −10 src/henplus/commands/TreeCommand.java
  31. +1 −1 src/henplus/commands/properties/AbstractPropertyCommand.java
  32. +1 −1 src/henplus/commands/properties/PropertyCommand.java
  33. +1 −1 src/henplus/importparser/ImportParser.java
  34. +3 −3 src/henplus/plugins/tablediff/ResultTablePrinter.java
  35. +6 −6 src/henplus/plugins/tablediff/TableDiffCommand.java
  36. +4 −4 src/henplus/plugins/tablediff/TableDiffResult.java
  37. +2 −2 src/henplus/property/BooleanPropertyHolder.java
  38. +4 −4 src/henplus/property/PropertyHolder.java
  39. +17 −17 src/henplus/util/DependencyResolver.java
  40. +2 −0 src/henplus/util/ListMap.java
  41. +14 −14 src/henplus/util/StringAppender.java
  42. +34 −34 src/henplus/view/Column.java
  43. +22 −22 src/henplus/view/ColumnMetaData.java
  44. +22 −22 src/henplus/view/TableRenderer.java
  45. +1 −1 src/henplus/view/util/CancelWriter.java
  46. +18 −19 src/henplus/view/util/NameCompleter.java
  47. +3 −3 src/henplus/view/util/ProgressWriter.java
View
@@ -0,0 +1,11 @@
+In this file, for every release we collect notable changes. These are then used
+for e.g. release notes.
+
+next release:
+
+* bumped java compatibility from 1.3 to 1.5
+
+0.9.8:
+
+* bugfix to cli parsing code
+* lots of untracked changes
View
@@ -34,21 +34,21 @@
* constant returned by the {@link #execute(SQLSession,String,String)}
* method, if everything went fine.
*/
- public final static int SUCCESS = 0;
+ public static final int SUCCESS = 0;
/**
* constant returned by the {@link #execute(SQLSession,String,String)} if
* the command could not be executed because of an syntax error. In that
* case, the CommandDispatcher will display the synopsis of that command.
*/
- public final static int SYNTAX_ERROR = 1;
+ public static final int SYNTAX_ERROR = 1;
/**
* constant returned by the {@link #execute(SQLSession,String,String)} if
* the command could not be executed because of some problem, that is not a
* syntax error.
*/
- public final static int EXEC_FAILED = 2;
+ public static final int EXEC_FAILED = 2;
/**
* returns the prefices of all command-strings this command can handle. The
@@ -10,7 +10,6 @@
import henplus.commands.SetCommand;
import java.util.ArrayList;
-import java.util.Enumeration;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -24,43 +23,43 @@
* The Command Dispatcher for all commands.
*/
public class CommandDispatcher implements ReadlineCompleter {
- private final static boolean verbose = false; // debug
- private final List/* <Command> */commands; // commands in seq. of addition.
- private final SortedMap commandMap;
- private final SetCommand setCommand;
- private final List/* <ExecutionL<Listener> */executionListeners;
+ private static final boolean VERBOSE = false; // debug
+ private final List<Command> _commands; // commands in seq. of addition.
+ private final SortedMap<String, Command> _commandMap;
+ private final SetCommand _setCommand;
+ private final List<ExecutionListener> _executionListeners;
private int _batchCount;
public CommandDispatcher(final SetCommand sc) {
- commandMap = new TreeMap();
- commands = new ArrayList();
- executionListeners = new ArrayList();
+ _commandMap = new TreeMap<String, Command>();
+ _commands = new ArrayList<Command>();
+ _executionListeners = new ArrayList<ExecutionListener>();
_batchCount = 0;
- setCommand = sc;
+ _setCommand = sc;
// FIXME: remove cyclic dependency..
- setCommand.registerLastCommandListener(this);
+ _setCommand.registerLastCommandListener(this);
}
/**
* returns the commands in the sequence they have been added.
*/
public Iterator getRegisteredCommands() {
- return commands.iterator();
+ return _commands.iterator();
}
/**
* returns a sorted list of command names.
*/
public Iterator getRegisteredCommandNames() {
- return commandMap.keySet().iterator();
+ return _commandMap.keySet().iterator();
}
/**
* returns a sorted list of command names, starting with the first entry
* matching the key.
*/
public Iterator getRegisteredCommandNames(final String key) {
- return commandMap.tailMap(key).keySet().iterator();
+ return _commandMap.tailMap(key).keySet().iterator();
}
/*
@@ -80,29 +79,29 @@ public boolean isInBatch() {
}
public void register(final Command c) {
- commands.add(c);
+ _commands.add(c);
final String[] cmdStrings = c.getCommandList();
for (int i = 0; i < cmdStrings.length; ++i) {
- if (commandMap.containsKey(cmdStrings[i])) {
+ if (_commandMap.containsKey(cmdStrings[i])) {
throw new IllegalArgumentException(
"attempt to register command '" + cmdStrings[i]
+ "', that is already used");
}
- commandMap.put(cmdStrings[i], c);
+ _commandMap.put(cmdStrings[i], c);
}
}
// methods to make aliases work.
public boolean containsCommand(final String cmd) {
- return commandMap.containsKey(cmd);
+ return _commandMap.containsKey(cmd);
}
public void registerAdditionalCommand(final String cmd, final Command c) {
- commandMap.put(cmd, c);
+ _commandMap.put(cmd, c);
}
public void unregisterAdditionalCommand(final String cmd) {
- commandMap.remove(cmd);
+ _commandMap.remove(cmd);
}
/**
@@ -112,8 +111,8 @@ public void unregisterAdditionalCommand(final String cmd) {
* plugin-mechanism does this) .. we don't care.
*/
public void unregister(final Command c) {
- commands.remove(c);
- final Iterator entries = commandMap.entrySet().iterator();
+ _commands.remove(c);
+ final Iterator entries = _commandMap.entrySet().iterator();
while (entries.hasNext()) {
final Map.Entry e = (Map.Entry) entries.next();
if (e.getValue() == c) {
@@ -145,7 +144,7 @@ public String getCommandNameFrom(final String completeCmd) {
}
// ok, fallback: grab the first whitespace delimited part.
if (longestMatch == null) {
- final Enumeration tok = new StringTokenizer(completeCmd, " ;\t\n\r\f");
+ final StringTokenizer tok = new StringTokenizer(completeCmd, " ;\t\n\r\f");
if (tok.hasMoreElements()) {
return (String) tok.nextElement();
}
@@ -161,21 +160,21 @@ private Command getCommandFromCooked(final String completeCmd) {
if (completeCmd == null) {
return null;
}
- Command c = (Command) commandMap.get(completeCmd);
+ Command c = _commandMap.get(completeCmd);
if (c == null) {
- c = (Command) commandMap.get(""); // "" matches everything.
+ c = _commandMap.get(""); // "" matches everything.
}
return c;
}
public void shutdown() {
- final Iterator i = commands.iterator();
+ final Iterator i = _commands.iterator();
while (i.hasNext()) {
final Command c = (Command) i.next();
try {
c.shutdown();
} catch (final Exception e) {
- if (verbose) {
+ if (VERBOSE) {
e.printStackTrace();
}
}
@@ -190,8 +189,8 @@ public void shutdown() {
* an Execution Listener
*/
public void addExecutionListener(final ExecutionListener listener) {
- if (!executionListeners.contains(listener)) {
- executionListeners.add(listener);
+ if (!_executionListeners.contains(listener)) {
+ _executionListeners.add(listener);
}
}
@@ -203,19 +202,19 @@ public void addExecutionListener(final ExecutionListener listener) {
* @return true, if this has been successful.
*/
public boolean removeExecutionListener(final ExecutionListener listener) {
- return executionListeners.remove(listener);
+ return _executionListeners.remove(listener);
}
private void informBeforeListeners(final SQLSession session, final String cmd) {
- final Iterator it = executionListeners.iterator();
+ final Iterator it = _executionListeners.iterator();
while (it.hasNext()) {
final ExecutionListener listener = (ExecutionListener) it.next();
listener.beforeExecution(session, cmd);
}
}
private void informAfterListeners(final SQLSession session, final String cmd, final int result) {
- final Iterator it = executionListeners.iterator();
+ final Iterator it = _executionListeners.iterator();
while (it.hasNext()) {
final ExecutionListener listener = (ExecutionListener) it.next();
listener.afterExecution(session, cmd, result);
@@ -289,7 +288,7 @@ public void execute(final SQLSession session, final String givenCommand) {
/* nope */
}
} catch (final Throwable e) {
- if (verbose) {
+ if (VERBOSE) {
e.printStackTrace();
}
HenPlus.msg().println(e.toString());
@@ -328,7 +327,7 @@ public String completer(String text, final int state) {
if (state == 0) {
variablePrefix = text.substring(0, pos);
final String varname = text.substring(pos);
- possibleValues = setCommand.completeUserVar(varname);
+ possibleValues = _setCommand.completeUserVar(varname);
}
if (possibleValues.hasNext()) {
return variablePrefix + (String) possibleValues.next();
@@ -349,7 +348,7 @@ else if (completeCommandString.equals(text)) {
continue;
}
if (text.length() < 1) {
- final Command c = (Command) commandMap.get(nextKey);
+ final Command c = _commandMap.get(nextKey);
if (!c.participateInCommandCompletion()) {
continue;
}
View
@@ -52,7 +52,7 @@
public final class HenPlus implements Interruptable {
private static final String HISTORY_NAME = "history";
- public static final boolean verbose = false; // debug.
+ public static final boolean VERBOSE = false; // debug.
private static final String HENPLUSDIR = ".henplus";
private static final String PROMPT = "Hen*Plus> ";
@@ -97,8 +97,8 @@ private HenPlus(final String argv[]) throws IOException {
try {
Readline.load(ReadlineLibrary.GnuReadline);
- } catch (final UnsatisfiedLinkError ignore_me) {
- System.err.println("no readline found (" + ignore_me.getMessage()
+ } catch (final UnsatisfiedLinkError ignoreMe) {
+ System.err.println("no readline found (" + ignoreMe.getMessage()
+ "). Using simple stdin.");
}
@@ -213,7 +213,7 @@ public void initializeCommands(final String argv[]) {
try {
line = parser.parse(availableOptions, argv);
for (final Iterator it = _dispatcher.getRegisteredCommands(); it
- .hasNext();) {
+ .hasNext(); ) {
final Command element = (Command) it.next();
element.setOptions(availableOptions);
element.handleCommandline(line);
@@ -395,7 +395,7 @@ public void run() {
break; // last session closed -> exit.
}
} catch (final Exception e) {
- if (verbose) {
+ if (VERBOSE) {
e.printStackTrace();
}
}
@@ -652,7 +652,7 @@ public static OutputDevice msg() {
return getInstance().getMessageDevice();
}
- public static final void main(final String argv[]) throws Exception {
+ public static void main(final String argv[]) throws Exception {
instance = new HenPlus(argv);
instance.initializeCommands(argv);
instance.run();
@@ -715,7 +715,7 @@ private File getConfigDir() {
_configDir.toString() };
Runtime.getRuntime().exec(params);
} catch (final Exception e) {
- if (verbose) {
+ if (VERBOSE) {
e.printStackTrace();
}
}
@@ -17,9 +17,9 @@
* second. However, this is better than nothing, right ?
*/
class PasswordEraserThread extends Thread {
- private final String eraser;
- private boolean running;
- private boolean onHold;
+ private final String _eraser;
+ private boolean _running;
+ private boolean _onHold;
/**
*@param prompt
@@ -30,26 +30,26 @@ public PasswordEraserThread(final String prompt) {
* we are erasing by writing the prompt followed by spaces from the
* beginning of the line
*/
- eraser = "\r" + prompt + " \r" + prompt;
- running = true;
- onHold = true;
+ _eraser = "\r" + prompt + " \r" + prompt;
+ _running = true;
+ _onHold = true;
}
/**
* Begin masking until asked to stop.
*/
@Override
public void run() {
- while (running) {
- if (onHold) {
+ while (_running) {
+ if (_onHold) {
try {
synchronized (this) {
wait();
}
} catch (final InterruptedException iex) {
// ignore.
}
- if (onHold) {
+ if (_onHold) {
continue;
}
}
@@ -59,25 +59,25 @@ public void run() {
} catch (final InterruptedException iex) {
// ignore
}
- if (running && !onHold) {
- System.out.print(eraser);
+ if (_running && !_onHold) {
+ System.out.print(_eraser);
}
System.out.flush();
}
}
public synchronized void holdOn() {
- onHold = true;
+ _onHold = true;
notify();
}
public synchronized void goOn() {
- onHold = false;
+ _onHold = false;
notify();
}
public synchronized void done() {
- running = false;
+ _running = false;
notify();
}
}
Oops, something went wrong.

0 comments on commit 31dbd8d

Please sign in to comment.