[Cherbot-commit] SF.net SVN: cherbot: [32] trunk/src/net/sf/cherbot
Status: Alpha
Brought to you by:
christianhujer
|
From: <chr...@us...> - 2006-10-29 14:03:13
|
Revision: 32
http://svn.sourceforge.net/cherbot/?rev=32&view=rev
Author: christianhujer
Date: 2006-10-29 06:02:55 -0800 (Sun, 29 Oct 2006)
Log Message:
-----------
Declared exception variables final, improved some I/O code.
Modified Paths:
--------------
trunk/src/net/sf/cherbot/CherBot.java
trunk/src/net/sf/cherbot/CherBotSecurityManager.java
trunk/src/net/sf/cherbot/EmotesManager.java
trunk/src/net/sf/cherbot/ExampleTester.java
trunk/src/net/sf/cherbot/MailManager.java
trunk/src/net/sf/cherbot/Manager.java
trunk/src/net/sf/cherbot/ManagerDocumenter.java
trunk/src/net/sf/cherbot/NoobManager.java
trunk/src/net/sf/cherbot/PlayerManager.java
trunk/src/net/sf/cherbot/PollManager.java
trunk/src/net/sf/cherbot/TimeManager.java
Modified: trunk/src/net/sf/cherbot/CherBot.java
===================================================================
--- trunk/src/net/sf/cherbot/CherBot.java 2006-10-29 13:49:33 UTC (rev 31)
+++ trunk/src/net/sf/cherbot/CherBot.java 2006-10-29 14:02:55 UTC (rev 32)
@@ -378,7 +378,7 @@
private static void switchColor(final int n) {
try {
System.out.print(colors[n]);
- } catch (ArrayIndexOutOfBoundsException e) {
+ } catch (final ArrayIndexOutOfBoundsException e) {
System.err.println("Unknown color number: " + n);
}
}
@@ -440,9 +440,9 @@
break;
}
}
- } catch (CherBotException e) {
+ } catch (final CherBotException e) {
answer("I can't: " + e.getMessage());
- } catch (SecurityException e) {
+ } catch (final SecurityException e) {
answer("I don't want to: " + e.getMessage());
}
}
@@ -515,7 +515,7 @@
try {
save();
answer("Saved all modules.");
- } catch (Exception e) {
+ } catch (final Exception e) {
answer("Save failed: " + e);
}
}
@@ -529,9 +529,9 @@
try {
managerMap.get(module).save();
answer("Saved module " + module + '.');
- } catch (NullPointerException e) {
+ } catch (final NullPointerException e) {
answer("No such module.");
- } catch (Exception e) {
+ } catch (final Exception e) {
answer("Error while saving module " + module + ": " + e);
}
}
@@ -544,7 +544,7 @@
try {
load();
answer("Loaded.");
- } catch (Exception e) {
+ } catch (final Exception e) {
answer("Save failed: " + e);
}
}
@@ -558,9 +558,9 @@
try {
managerMap.get(module).load();
answer("Loaded module " + module + '.');
- } catch (NullPointerException e) {
+ } catch (final NullPointerException e) {
answer("No such module.");
- } catch (Exception e) {
+ } catch (final Exception e) {
answer("Error while loading module " + module + ": " + e);
}
}
@@ -758,22 +758,19 @@
* What's new.
*/
private void whatsNew() {
- BufferedReader in = null;
try {
- in = new BufferedReader(new InputStreamReader(new FileInputStream("news.txt")));
- final StringBuilder sb = new StringBuilder();
- for (String line; (line = in.readLine()) != null; sb.append(line).append('\n')) {
- ;
- }
- answer(sb.toString());
- } catch (IOException e) {
- answer("No news available.");
- } finally {
+ final BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream("news.txt")));
try {
+ final StringBuilder sb = new StringBuilder();
+ for (String line; (line = in.readLine()) != null; sb.append(line).append('\n')) {
+ ;
+ }
+ answer(sb.toString());
+ } finally {
in.close();
- } catch (Exception e) { /* ignore */ } finally {
- in = null;
}
+ } catch (final IOException e) {
+ answer("No news available.");
}
}
@@ -784,7 +781,7 @@
if (manager != InternalManager.this) {
try {
manager.save();
- } catch (Exception e) {
+ } catch (final Exception e) {
System.err.println("Error while saving data from module " + manager.getTopic() + ": " + e);
e.printStackTrace();
}
@@ -797,7 +794,7 @@
if (manager != InternalManager.this) {
try {
manager.load();
- } catch (Exception e) {
+ } catch (final Exception e) {
System.err.println("Error while loading data for module " + manager.getTopic() + ": " + e);
e.printStackTrace();
}
Modified: trunk/src/net/sf/cherbot/CherBotSecurityManager.java
===================================================================
--- trunk/src/net/sf/cherbot/CherBotSecurityManager.java 2006-10-29 13:49:33 UTC (rev 31)
+++ trunk/src/net/sf/cherbot/CherBotSecurityManager.java 2006-10-29 14:02:55 UTC (rev 32)
@@ -256,9 +256,9 @@
// for (String line; (line = in.readLine) != null;) {
// // TODO
// }
- //} catch (IOException e) {
+ //} catch (final IOException e) {
// System.err.println(e);
- //} finally { try { in.close(); } catch (Exception e) { /* ignore */ } finally { in = null; }
+ //} finally { try { in.close(); } catch (final Exception e) { /* ignore */ } finally { in = null; }
// Binary interface:
try {
@@ -294,9 +294,9 @@
// }
// out.println();
// }
- //} catch (IOException e) {
+ //} catch (final IOException e) {
// System.err.println(e);
- //} finally { try { out.close(); } catch (Exception e) { /* ignore */ } finally { in = null; }
+ //} finally { try { out.close(); } catch (final Exception e) { /* ignore */ } finally { in = null; }
// Binary interface:
final ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream("security.dat"));
Modified: trunk/src/net/sf/cherbot/EmotesManager.java
===================================================================
--- trunk/src/net/sf/cherbot/EmotesManager.java 2006-10-29 13:49:33 UTC (rev 31)
+++ trunk/src/net/sf/cherbot/EmotesManager.java 2006-10-29 14:02:55 UTC (rev 32)
@@ -563,7 +563,7 @@
int ranking;
try {
ranking = attitude.get(player)[0];
- } catch (Exception e) {
+ } catch (final Exception e) {
ranking = 0;
}
assert!(isLoved && isHated); // Not the best place, but if here it's only needed once.
Modified: trunk/src/net/sf/cherbot/ExampleTester.java
===================================================================
--- trunk/src/net/sf/cherbot/ExampleTester.java 2006-10-29 13:49:33 UTC (rev 31)
+++ trunk/src/net/sf/cherbot/ExampleTester.java 2006-10-29 14:02:55 UTC (rev 32)
@@ -70,7 +70,7 @@
} else {
System.err.println("No examples on " + method);
}
- } catch (NoSuchMethodException e) {
+ } catch (final NoSuchMethodException e) {
assert false;
}
return suite;
Modified: trunk/src/net/sf/cherbot/MailManager.java
===================================================================
--- trunk/src/net/sf/cherbot/MailManager.java 2006-10-29 13:49:33 UTC (rev 31)
+++ trunk/src/net/sf/cherbot/MailManager.java 2006-10-29 14:02:55 UTC (rev 32)
@@ -323,7 +323,7 @@
private Mail getMail(final int n) {
try {
return mails.get(getActor()).get(n - 1);
- } catch (Exception e) {
+ } catch (final Exception e) {
throw new CherBotException("No such mail: " + n);
}
}
Modified: trunk/src/net/sf/cherbot/Manager.java
===================================================================
--- trunk/src/net/sf/cherbot/Manager.java 2006-10-29 13:49:33 UTC (rev 31)
+++ trunk/src/net/sf/cherbot/Manager.java 2006-10-29 14:02:55 UTC (rev 32)
@@ -313,7 +313,7 @@
for (IOModule iomodule : iomodules) {
try {
iomodule.load();
- } catch (Exception e) {
+ } catch (final Exception e) {
if (ex == null) {
ex = e;
}
@@ -334,7 +334,7 @@
for (IOModule iomodule : iomodules) {
try {
iomodule.save();
- } catch (Exception e) {
+ } catch (final Exception e) {
if (ex == null) {
ex = e;
}
@@ -579,7 +579,7 @@
parent = clazz;
try {
return (String) clazz.getField("C_" + name).get(null);
- } catch (Exception e) {
+ } catch (final Exception e) {
ex = e;
}
clazz = clazz.getEnclosingClass();
@@ -754,7 +754,7 @@
} finally {
try {
reader.close();
- } catch (Exception e) { /* ignore */ } finally {
+ } catch (final Exception e) { /* ignore */ } finally {
reader = null;
}
}
@@ -770,7 +770,7 @@
} finally {
try {
writer.close();
- } catch (Exception e) { /* ignore */ } finally {
+ } catch (final Exception e) { /* ignore */ } finally {
writer = null;
}
}
@@ -856,7 +856,7 @@
ReadIterator() {
try {
line = readLine();
- } catch (IOException e) {
+ } catch (final IOException e) {
this.e = e;
}
}
@@ -883,7 +883,7 @@
} finally {
try {
line = readLine();
- } catch (IOException e) {
+ } catch (final IOException e) {
line = null;
this.e = e;
}
@@ -979,7 +979,7 @@
MatcherIterator() {
try {
line = reader().readLine();
- } catch (IOException e) {
+ } catch (final IOException e) {
this.e = e;
}
}
Modified: trunk/src/net/sf/cherbot/ManagerDocumenter.java
===================================================================
--- trunk/src/net/sf/cherbot/ManagerDocumenter.java 2006-10-29 13:49:33 UTC (rev 31)
+++ trunk/src/net/sf/cherbot/ManagerDocumenter.java 2006-10-29 14:02:55 UTC (rev 32)
@@ -99,7 +99,7 @@
} else {
System.err.println("No examples on " + method);
}
- } catch (NoSuchMethodException e) {
+ } catch (final NoSuchMethodException e) {
assert false;
}
return ret;
Modified: trunk/src/net/sf/cherbot/NoobManager.java
===================================================================
--- trunk/src/net/sf/cherbot/NoobManager.java 2006-10-29 13:49:33 UTC (rev 31)
+++ trunk/src/net/sf/cherbot/NoobManager.java 2006-10-29 14:02:55 UTC (rev 32)
@@ -227,7 +227,7 @@
} else {
answer("I don't know where players are. They usually don't tell me. And if they would, that information would be out of date too soon.");
}
- } catch (NoSuchPlayerException e) {
+ } catch (final NoSuchPlayerException e) {
answer("I don't know where " + topic + " is.");
}
}
@@ -256,7 +256,7 @@
try {
howtos.put(Pattern.compile(topic), text);
answer("Howto on " + topic + " successfully added.");
- } catch (PatternSyntaxException e) {
+ } catch (final PatternSyntaxException e) {
answer("I do not understand that regular expression: " + e.getMessage());
}
}
Modified: trunk/src/net/sf/cherbot/PlayerManager.java
===================================================================
--- trunk/src/net/sf/cherbot/PlayerManager.java 2006-10-29 13:49:33 UTC (rev 31)
+++ trunk/src/net/sf/cherbot/PlayerManager.java 2006-10-29 14:02:55 UTC (rev 32)
@@ -299,7 +299,7 @@
int end = 0;
try {
end = parseInt(gr(2));
- } catch (Exception e) { /* ignore */ }
+ } catch (final Exception e) { /* ignore */ }
if (end < start) {
end = start + 9;
}
@@ -456,7 +456,7 @@
@Override public int getLevel(final String player) {
try {
return levels.get(player);
- } catch (Exception e) {
+ } catch (final Exception e) {
return 0;
}
}
@@ -476,7 +476,7 @@
try {
final long ls = lastSeen.get(player);
answer("I've last seen " + player + " at: " + dateFormat.format(new Date(ls)) + "\nMy current time is: " + dateFormat.format(new Date()));
- } catch (NullPointerException e) {
+ } catch (final NullPointerException e) {
answer("I don't know when " + player + " was last online.");
}
}
@@ -523,7 +523,7 @@
sb.append(highestPlayers.size() > 1 ? " all have " : " has ");
sb.append("level ").append(Integer.toString(level)).append('.');
answer(sb.toString());
- } catch (NoSuchElementException e) {
+ } catch (final NoSuchElementException e) {
answer("I don't know any levels yet.");
}
}
@@ -630,7 +630,7 @@
try {
final int level = levels.get(player);
answer(player + " is level " + level + '.');
- } catch (Exception e) {
+ } catch (final Exception e) {
answer("I don't know the level of player " + player + '.');
}
}
Modified: trunk/src/net/sf/cherbot/PollManager.java
===================================================================
--- trunk/src/net/sf/cherbot/PollManager.java 2006-10-29 13:49:33 UTC (rev 31)
+++ trunk/src/net/sf/cherbot/PollManager.java 2006-10-29 14:02:55 UTC (rev 32)
@@ -246,7 +246,7 @@
Poll poll;
try {
poll = new Poll(polls.get(polls.size() - 1).getNumber() + 1);
- } catch (Exception e) { // first poll
+ } catch (final Exception e) { // first poll
poll = new Poll(1);
}
polls.add(poll);
@@ -508,7 +508,7 @@
try {
choices.remove(choice);
answer("Choice removed.");
- } catch (IndexOutOfBoundsException e) {
+ } catch (final IndexOutOfBoundsException e) {
throw new CherBotException("No such choice on poll #" + number + ": " + choice + '.');
}
}
@@ -634,7 +634,7 @@
choices.add(choice);
votes.put(choice, new int[] { parseInt(matcher.group(2)) });
}
- } catch (NullPointerException e) {
+ } catch (final NullPointerException e) {
throw new EOFException();
}
}
Modified: trunk/src/net/sf/cherbot/TimeManager.java
===================================================================
--- trunk/src/net/sf/cherbot/TimeManager.java 2006-10-29 13:49:33 UTC (rev 31)
+++ trunk/src/net/sf/cherbot/TimeManager.java 2006-10-29 14:02:55 UTC (rev 32)
@@ -330,7 +330,7 @@
try {
Time t = (Time) obj;
return compareTo(t) == 0;
- } catch (Exception e) {
+ } catch (final Exception e) {
return false;
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|