Thread: [Japi-cvs] SF.net SVN: japi:[751]
Status: Beta
Brought to you by:
christianhujer
|
From: <chr...@us...> - 2008-12-28 20:05:34
|
Revision: 751
http://japi.svn.sourceforge.net/japi/?rev=751&view=rev
Author: christianhujer
Date: 2008-12-28 20:05:30 +0000 (Sun, 28 Dec 2008)
Log Message:
-----------
Made Comparator implementations Serializable.
Modified Paths:
--------------
historic/trunk/src/app/net/sf/japi/swing/LocaleComparator.java
libs/argparser/trunk/src/prj/net/sf/japi/io/args/CharsetDisplaynameComparator.java
libs/argparser/trunk/src/prj/net/sf/japi/io/args/MethodOptionComparator.java
libs/lang/trunk/src/prj/net/sf/japi/lang/PropertyComparator.java
libs/midi/trunk/src/prj/net/sf/japi/midi/DeviceComparator.java
libs/taglets/trunk/src/prj/net/sf/japi/taglets/TagByTextComparator.java
libs/util/trunk/src/prj/net/sf/japi/util/LocaleComparator.java
progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/util/StringToTextComparatorAdapter.java
Modified: historic/trunk/src/app/net/sf/japi/swing/LocaleComparator.java
===================================================================
--- historic/trunk/src/app/net/sf/japi/swing/LocaleComparator.java 2008-12-28 19:31:55 UTC (rev 750)
+++ historic/trunk/src/app/net/sf/japi/swing/LocaleComparator.java 2008-12-28 20:05:30 UTC (rev 751)
@@ -20,6 +20,7 @@
package net.sf.japi.swing;
+import java.io.Serializable;
import java.text.Collator;
import java.util.Comparator;
import java.util.Locale;
@@ -28,8 +29,11 @@
* The Locale for sorting the Locales is determined at creation time.
* @author <a href="mailto:ch...@ri...">Christian Hujer</a>
*/
-public final class LocaleComparator implements Comparator<Locale> {
+public final class LocaleComparator implements Comparator<Locale>, Serializable {
+ /** Serial version. */
+ private static final long serialVersionUID = 1L;
+
/** Collator for comparing the names. */
private final Collator collator = Collator.getInstance();
Modified: libs/argparser/trunk/src/prj/net/sf/japi/io/args/CharsetDisplaynameComparator.java
===================================================================
--- libs/argparser/trunk/src/prj/net/sf/japi/io/args/CharsetDisplaynameComparator.java 2008-12-28 19:31:55 UTC (rev 750)
+++ libs/argparser/trunk/src/prj/net/sf/japi/io/args/CharsetDisplaynameComparator.java 2008-12-28 20:05:30 UTC (rev 751)
@@ -4,14 +4,18 @@
import java.util.Comparator;
import java.util.Locale;
import java.text.Collator;
+import java.io.Serializable;
import org.jetbrains.annotations.NotNull;
/** Comparator that compares Charsets by their displayName.
* @author <a href="mailto:ch...@ri...">Christian Hujer</a>
* @todo move to a different library / package.
*/
-public class CharsetDisplaynameComparator implements Comparator<Charset> {
+public class CharsetDisplaynameComparator implements Comparator<Charset>, Serializable {
+ /** Serial version. */
+ private static final long serialVersionUID = 1L;
+
/** Locale to use for the Collator and the displayname.
* Must be set upon instanciation because the behaviour of a Comparator must stay constant over time.
* Otherwise this breaks collections using this Comparator.
Modified: libs/argparser/trunk/src/prj/net/sf/japi/io/args/MethodOptionComparator.java
===================================================================
--- libs/argparser/trunk/src/prj/net/sf/japi/io/args/MethodOptionComparator.java 2008-12-28 19:31:55 UTC (rev 750)
+++ libs/argparser/trunk/src/prj/net/sf/japi/io/args/MethodOptionComparator.java 2008-12-28 20:05:30 UTC (rev 751)
@@ -19,6 +19,7 @@
package net.sf.japi.io.args;
+import java.io.Serializable;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.Comparator;
@@ -27,8 +28,11 @@
/** Compares methods by their options.
* @author <a href="mailto:ch...@ri...">Christian Hujer</a>
*/
-public class MethodOptionComparator implements Comparator<Method> {
+public class MethodOptionComparator implements Comparator<Method>, Serializable {
+ /** Serial version. */
+ private static final long serialVersionUID = 1L;
+
/** Global instance. */
@NotNull public static final Comparator<Method> INSTANCE = new MethodOptionComparator();
Modified: libs/lang/trunk/src/prj/net/sf/japi/lang/PropertyComparator.java
===================================================================
--- libs/lang/trunk/src/prj/net/sf/japi/lang/PropertyComparator.java 2008-12-28 19:31:55 UTC (rev 750)
+++ libs/lang/trunk/src/prj/net/sf/japi/lang/PropertyComparator.java 2008-12-28 20:05:30 UTC (rev 751)
@@ -19,6 +19,7 @@
package net.sf.japi.lang;
+import java.io.Serializable;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Comparator;
@@ -33,8 +34,11 @@
* @author <a href="mailto:ch...@ri...">Christian Hujer</a>
* @todo think whether net.sf.japi.lang really is the correct package or this should rather go to something like net.sf.japi.beans or net.sf.japi.util.
*/
-public class PropertyComparator<T, C> implements Comparator<C> {
+public class PropertyComparator<T, C> implements Comparator<C>, Serializable {
+ /** Serial version. */
+ private static final long serialVersionUID = 1L;
+
/** The target class. */
@Nullable private final Class<C> targetClass;
Modified: libs/midi/trunk/src/prj/net/sf/japi/midi/DeviceComparator.java
===================================================================
--- libs/midi/trunk/src/prj/net/sf/japi/midi/DeviceComparator.java 2008-12-28 19:31:55 UTC (rev 750)
+++ libs/midi/trunk/src/prj/net/sf/japi/midi/DeviceComparator.java 2008-12-28 20:05:30 UTC (rev 751)
@@ -1,13 +1,17 @@
package net.sf.japi.midi;
+import java.io.Serializable;
import java.util.Comparator;
import javax.sound.midi.MidiDevice;
/** Comparator for MidiDevices which compares them by name.
* @author <a href="mailto:ch...@ri...">Christian Hujer</a>
*/
-public class DeviceComparator implements Comparator<MidiDevice> {
+public class DeviceComparator implements Comparator<MidiDevice>, Serializable {
+ /** Serial version. */
+ private static final long serialVersionUID = 1L;
+
/** The convenient default instance. */
private static Comparator<? super MidiDevice> instance = new DeviceComparator();
Modified: libs/taglets/trunk/src/prj/net/sf/japi/taglets/TagByTextComparator.java
===================================================================
--- libs/taglets/trunk/src/prj/net/sf/japi/taglets/TagByTextComparator.java 2008-12-28 19:31:55 UTC (rev 750)
+++ libs/taglets/trunk/src/prj/net/sf/japi/taglets/TagByTextComparator.java 2008-12-28 20:05:30 UTC (rev 751)
@@ -20,14 +20,18 @@
package net.sf.japi.taglets;
import com.sun.javadoc.Tag;
+import java.io.Serializable;
import java.util.Comparator;
/**
* Compares Javadoc Tags by their text.
* @author <a href="mailto:ch...@ri...">Christian Hujer</a>
*/
-public class TagByTextComparator implements Comparator<Tag> {
+public class TagByTextComparator implements Comparator<Tag>, Serializable {
+ /** Serial version. */
+ private static final long serialVersionUID = 1L;
+
/** Static instance. */
public static final Comparator<Tag> INSTANCE = new TagByTextComparator();
Modified: libs/util/trunk/src/prj/net/sf/japi/util/LocaleComparator.java
===================================================================
--- libs/util/trunk/src/prj/net/sf/japi/util/LocaleComparator.java 2008-12-28 19:31:55 UTC (rev 750)
+++ libs/util/trunk/src/prj/net/sf/japi/util/LocaleComparator.java 2008-12-28 20:05:30 UTC (rev 751)
@@ -19,6 +19,7 @@
package net.sf.japi.util;
+import java.io.Serializable;
import java.text.Collator;
import java.util.Comparator;
import java.util.Locale;
@@ -29,8 +30,11 @@
* The Locale for sorting the Locales is determined at creation time.
* @author <a href="mailto:ch...@ri...">Christian Hujer</a>
*/
-public final class LocaleComparator implements Comparator<Locale> {
+public final class LocaleComparator implements Comparator<Locale>, Serializable {
+ /** Serial version. */
+ private static final long serialVersionUID = 1L;
+
/** Collator for comparing the names. */
@NotNull private final Collator collator = Collator.getInstance();
Modified: progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/util/StringToTextComparatorAdapter.java
===================================================================
--- progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/util/StringToTextComparatorAdapter.java 2008-12-28 19:31:55 UTC (rev 750)
+++ progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/util/StringToTextComparatorAdapter.java 2008-12-28 20:05:30 UTC (rev 751)
@@ -20,6 +20,7 @@
package net.sf.japi.progs.jeduca.util;
+import java.io.Serializable;
import java.util.Comparator;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -27,8 +28,11 @@
/** An adapter to be able to use String comparators for Text objects.
* @author <a href="mailto:ch...@ri...">Christian Hujer</a>
*/
-public class StringToTextComparatorAdapter implements Comparator<Text> {
+public class StringToTextComparatorAdapter implements Comparator<Text>, Serializable {
+ /** Serial version. */
+ private static final long serialVersionUID = 1L;
+
/** Mime Comparator. */
@Nullable private final Comparator<String> mime;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <chr...@us...> - 2008-12-28 21:54:39
|
Revision: 752
http://japi.svn.sourceforge.net/japi/?rev=752&view=rev
Author: christianhujer
Date: 2008-12-28 21:50:19 +0000 (Sun, 28 Dec 2008)
Log Message:
-----------
Renamed ignored exceptions to "ignore" or "ignored".
Modified Paths:
--------------
historic/trunk/src/app/net/sf/japi/cpp/CPreProcessor.java
historic/trunk/src/app/net/sf/japi/io/ARGV.java
historic/trunk/src/app/net/sf/japi/io/ARGVEnumeration.java
historic/trunk/src/app/net/sf/japi/sql/CachedResultSetTableModel.java
historic/trunk/src/app/net/sf/japi/swing/JPropertyEditor.java
historic/trunk/src/app/net/sf/japi/util/Service.java
libs/argparser/trunk/src/prj/net/sf/japi/io/args/ArgParser.java
libs/argparser/trunk/src/prj/net/sf/japi/io/args/CommandWithHelp.java
libs/argparser/trunk/src/prj/net/sf/japi/io/args/LogCommand.java
libs/argparser/trunk/src/prj/net/sf/japi/io/args/OptionType.java
libs/argparser/trunk/src/prj/net/sf/japi/io/args/converter/ConverterRegistry.java
libs/argparser/trunk/src/prj/net/sf/japi/io/args/converter/InputStreamConverter.java
libs/io/trunk/src/prj/net/sf/japi/io/BRLineIterator.java
libs/logging/trunk/src/prj/net/sf/japi/log/LogEntry.java
libs/midi/trunk/src/prj/net/sf/japi/midi/MonitorReceiver.java
libs/net/trunk/src/prj/net/sf/japi/net/Forwarder.java
libs/swing-about/trunk/src/prj/net/sf/japi/swing/about/AboutDialog.java
libs/swing-action/trunk/src/prj/net/sf/japi/swing/DefaultActionBuilder.java
libs/swing-action/trunk/src/prj/net/sf/japi/swing/IconManager.java
libs/swing-action/trunk/src/tst/test/net/sf/japi/swing/DefaultActionBuilderTest.java
libs/swing-app/trunk/src/prj/net/sf/japi/swing/app/DocumentFrame.java
libs/swing-bookmarks/trunk/src/prj/net/sf/japi/swing/bookmarks/BookmarkDropTargetAdapter.java
libs/swing-keyprefs/trunk/src/prj/net/sf/japi/swing/prefs/keys/AbstractSimpleNode.java
libs/swing-misc/trunk/src/prj/net/sf/japi/swing/misc/ConsoleProgress.java
libs/swing-misc/trunk/src/prj/net/sf/japi/swing/misc/JFileChooserButton.java
libs/swing-tod/trunk/src/prj/net/sf/japi/swing/tod/TipOfTheDayManager.java
libs/taglets/trunk/src/prj/net/sf/japi/taglets/HistoryTaglet.java
libs/taglets/trunk/src/prj/net/sf/japi/taglets/TagByTextComparator.java
libs/util/trunk/src/prj/net/sf/japi/util/Collections2.java
libs/util/trunk/src/tst/test/net/sf/japi/util/EnumerationIteratorTest.java
libs/xml/trunk/src/prj/net/sf/japi/xml/FilteredNodeList.java
libs/xml/trunk/src/tst/test/net/sf/japi/xml/NodeListIterator2Test.java
progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/jtest/io/JTestSer.java
progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/jtest/io/JTestV1.java
progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/jtest/io/KEduca.java
progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/swing/io/IOUtilities.java
progs/jtype/trunk/src/prj/net/sf/japi/jtype/ReflectionField.java
progs/textedit/trunk/src/prj/net/sf/japi/progs/textedit/TextDocument.java
tools/midiMonitor/trunk/src/prj/net/sf/japi/tools/midiMonitor/MidiMonitor.java
Modified: historic/trunk/src/app/net/sf/japi/cpp/CPreProcessor.java
===================================================================
--- historic/trunk/src/app/net/sf/japi/cpp/CPreProcessor.java 2008-12-28 20:05:30 UTC (rev 751)
+++ historic/trunk/src/app/net/sf/japi/cpp/CPreProcessor.java 2008-12-28 21:50:19 UTC (rev 752)
@@ -108,7 +108,7 @@
chain.append(buffer, 0, bytesRead);
}
} finally {
- try { in.close(); } catch (final Exception e) { /* ignore */ }
+ in.close();
}
return chain.toString();
}
Modified: historic/trunk/src/app/net/sf/japi/io/ARGV.java
===================================================================
--- historic/trunk/src/app/net/sf/japi/io/ARGV.java 2008-12-28 20:05:30 UTC (rev 751)
+++ historic/trunk/src/app/net/sf/japi/io/ARGV.java 2008-12-28 21:50:19 UTC (rev 752)
@@ -45,7 +45,7 @@
argvReader = new ARGVReader(args);
try {
nextLine = argvReader.readLine();
- } catch (final IOException e) {
+ } catch (final IOException ignore) {
close();
}
}
@@ -56,7 +56,7 @@
try {
assert argvReader != null;
argvReader.close();
- } catch (final IOException e) {
+ } catch (final IOException ignore) {
// ignore
} finally {
argvReader = null;
@@ -84,7 +84,7 @@
try {
assert argvReader != null;
nextLine = argvReader.readLine();
- } catch (final IOException e) {
+ } catch (final IOException ignore) {
close();
}
}
Modified: historic/trunk/src/app/net/sf/japi/io/ARGVEnumeration.java
===================================================================
--- historic/trunk/src/app/net/sf/japi/io/ARGVEnumeration.java 2008-12-28 20:05:30 UTC (rev 751)
+++ historic/trunk/src/app/net/sf/japi/io/ARGVEnumeration.java 2008-12-28 21:50:19 UTC (rev 752)
@@ -79,7 +79,7 @@
if (currentStream != null) {
try {
currentStream.close();
- } catch (final IOException e) {
+ } catch (final IOException ignore) {
/* ignore. */
}
}
Modified: historic/trunk/src/app/net/sf/japi/sql/CachedResultSetTableModel.java
===================================================================
--- historic/trunk/src/app/net/sf/japi/sql/CachedResultSetTableModel.java 2008-12-28 20:05:30 UTC (rev 751)
+++ historic/trunk/src/app/net/sf/japi/sql/CachedResultSetTableModel.java 2008-12-28 21:50:19 UTC (rev 752)
@@ -148,9 +148,9 @@
@Nullable public Object getValueAt(final int rowIndex, final int columnIndex) {
try {
return data[rowIndex][columnIndex];
- } catch (final NullPointerException e) {
+ } catch (final NullPointerException ignore) {
return null;
- } catch (final ArrayIndexOutOfBoundsException e) {
+ } catch (final ArrayIndexOutOfBoundsException ignore) {
return null;
}
}
Modified: historic/trunk/src/app/net/sf/japi/swing/JPropertyEditor.java
===================================================================
--- historic/trunk/src/app/net/sf/japi/swing/JPropertyEditor.java 2008-12-28 20:05:30 UTC (rev 751)
+++ historic/trunk/src/app/net/sf/japi/swing/JPropertyEditor.java 2008-12-28 21:50:19 UTC (rev 752)
@@ -90,9 +90,9 @@
// TODO: Attach property editor
try {
return EDITORS.get(propertyType).newInstance();
- } catch (final InstantiationException e) {
+ } catch (final InstantiationException ignore) {
return null;
- } catch (IllegalAccessException e) {
+ } catch (IllegalAccessException ignore) {
return null;
}
}
Modified: historic/trunk/src/app/net/sf/japi/util/Service.java
===================================================================
--- historic/trunk/src/app/net/sf/japi/util/Service.java 2008-12-28 20:05:30 UTC (rev 751)
+++ historic/trunk/src/app/net/sf/japi/util/Service.java 2008-12-28 21:50:19 UTC (rev 752)
@@ -24,11 +24,11 @@
// return java.util.Service.lookup(service);
//} catch (final NoClassDefFoundError e) {
return (Iterable<T>) getMustangServiceClass().getMethod("load", Class.class).invoke(null, service);
- } catch (final ClassNotFoundException e) {
+ } catch (final ClassNotFoundException ignore) {
return new IteratorIterable<T>(providers(service));
- } catch (final NoSuchMethodException e) {
+ } catch (final NoSuchMethodException ignore) {
return new IteratorIterable<T>(providers(service));
- } catch (final IllegalAccessException e) {
+ } catch (final IllegalAccessException ignore) {
return new IteratorIterable<T>(providers(service));
} catch (final InvocationTargetException e) {
final Throwable t = e.getCause();
@@ -61,11 +61,11 @@
// return java.util.Service.lookup(service, loader);
//} catch (final NoClassDefFoundError e) {
return (Iterable<T>) getMustangServiceClass().getMethod("load", Class.class, ClassLoader.class).invoke(null, service, loader);
- } catch (final ClassNotFoundException e) {
+ } catch (final ClassNotFoundException ignore) {
return new IteratorIterable<T>(providers(service));
- } catch (final NoSuchMethodException e) {
+ } catch (final NoSuchMethodException ignore) {
return new IteratorIterable<T>(providers(service));
- } catch (final IllegalAccessException e) {
+ } catch (final IllegalAccessException ignore) {
return new IteratorIterable<T>(providers(service));
} catch (final InvocationTargetException e) {
final Throwable t = e.getCause();
@@ -94,13 +94,13 @@
@NotNull private static <T> Iterable<T> loadMustang(@NotNull final Class<T> service, @Nullable final ClassLoader loader) throws MustangUnavailableException {
try {
return (Iterable<T>) getMustangServiceClass().getMethod("load", Class.class, ClassLoader.class).invoke(null, service, loader);
- } catch (final IllegalAccessException e) {
+ } catch (final IllegalAccessException ignore) {
throw new MustangUnavailableException();
- } catch (final NoSuchMethodException e) {
+ } catch (final NoSuchMethodException ignore) {
throw new MustangUnavailableException();
- } catch (final ClassNotFoundException e) {
+ } catch (final ClassNotFoundException ignore) {
throw new MustangUnavailableException();
- } catch (final InvocationTargetException e) {
+ } catch (final InvocationTargetException ignore) {
throw new MustangUnavailableException();
}
}
Modified: libs/argparser/trunk/src/prj/net/sf/japi/io/args/ArgParser.java
===================================================================
--- libs/argparser/trunk/src/prj/net/sf/japi/io/args/ArgParser.java 2008-12-28 20:05:30 UTC (rev 751)
+++ libs/argparser/trunk/src/prj/net/sf/japi/io/args/ArgParser.java 2008-12-28 21:50:19 UTC (rev 752)
@@ -315,7 +315,7 @@
throw (TerminalException) cause;
}
System.err.println(e.getCause());
- } catch (final NoSuchElementException e) {
+ } catch (final NoSuchElementException ignore) {
throw new MissingArgumentException(currentOption);
} catch (final Exception e) {
e.printStackTrace();
@@ -333,7 +333,7 @@
public static void simpleParseAndRun(@NotNull final Command command, @NotNull final String... args) {
try {
parseAndRun(command, args);
- } catch (final TerminalException e) {
+ } catch (final TerminalException ignore) {
/* ignore, nothing serious has happend. */
} catch (final RequiredOptionsMissingException e) {
System.err.println(e);
Modified: libs/argparser/trunk/src/prj/net/sf/japi/io/args/CommandWithHelp.java
===================================================================
--- libs/argparser/trunk/src/prj/net/sf/japi/io/args/CommandWithHelp.java 2008-12-28 20:05:30 UTC (rev 751)
+++ libs/argparser/trunk/src/prj/net/sf/japi/io/args/CommandWithHelp.java 2008-12-28 21:50:19 UTC (rev 752)
@@ -148,7 +148,7 @@
}
try {
return ResourceBundle.getBundle(getClass().getName()).getString(key);
- } catch (final MissingResourceException e2) {
+ } catch (final MissingResourceException ignore) {
return ownBundle.getString(key);
}
}
Modified: libs/argparser/trunk/src/prj/net/sf/japi/io/args/LogCommand.java
===================================================================
--- libs/argparser/trunk/src/prj/net/sf/japi/io/args/LogCommand.java 2008-12-28 20:05:30 UTC (rev 751)
+++ libs/argparser/trunk/src/prj/net/sf/japi/io/args/LogCommand.java 2008-12-28 21:50:19 UTC (rev 752)
@@ -56,7 +56,7 @@
public void setLevel(@NotNull final Level level) {
try {
LogManager.getLogManager().readConfiguration(new ByteArrayInputStream((".level=" + level + "\nhandlers=java.util.logging.ConsoleHandler\njava.util.logging.ConsoleHandler.level=" + level).getBytes()));
- } catch (final IOException e) {
+ } catch (final IOException ignore) {
assert false : "This should never happen because we're reading from RAM.";
}
}
Modified: libs/argparser/trunk/src/prj/net/sf/japi/io/args/OptionType.java
===================================================================
--- libs/argparser/trunk/src/prj/net/sf/japi/io/args/OptionType.java 2008-12-28 20:05:30 UTC (rev 751)
+++ libs/argparser/trunk/src/prj/net/sf/japi/io/args/OptionType.java 2008-12-28 21:50:19 UTC (rev 752)
@@ -58,7 +58,7 @@
String name;
try {
name = ResourceBundle.getBundle("net.sf.japi.io.args.messages").getString(getClass().getName() + "." + name());
- } catch (final MissingResourceException e) {
+ } catch (final MissingResourceException ignore) {
name = name();
}
return name;
@@ -73,7 +73,7 @@
String name;
try {
name = ResourceBundle.getBundle("net.sf.japi.io.args.messages", locale).getString(getClass().getName() + "." + name());
- } catch (final MissingResourceException e) {
+ } catch (final MissingResourceException ignore) {
name = name();
}
return name;
@@ -95,7 +95,7 @@
String description;
try {
description = ResourceBundle.getBundle("net.sf.japi.io.args.messages").getString(getClass().getName() + "." + name() + ".description");
- } catch (final MissingResourceException e) {
+ } catch (final MissingResourceException ignore) {
description = name();
}
return description.length() == 0 ? description : " (" + description + ")";
@@ -110,7 +110,7 @@
String description;
try {
description = ResourceBundle.getBundle("net.sf.japi.io.args.messages", locale).getString(getClass().getName() + "." + name() + ".description");
- } catch (final MissingResourceException e) {
+ } catch (final MissingResourceException ignore) {
description = name();
}
return description.length() == 0 ? description : " (" + description + ")";
Modified: libs/argparser/trunk/src/prj/net/sf/japi/io/args/converter/ConverterRegistry.java
===================================================================
--- libs/argparser/trunk/src/prj/net/sf/japi/io/args/converter/ConverterRegistry.java 2008-12-28 20:05:30 UTC (rev 751)
+++ libs/argparser/trunk/src/prj/net/sf/japi/io/args/converter/ConverterRegistry.java 2008-12-28 21:50:19 UTC (rev 752)
@@ -145,7 +145,7 @@
@Nullable public static <T> ConstructorConverter<T> getConstructorConverter(@NotNull final Class<T> targetType) {
try {
return new ConstructorConverter<T>(targetType);
- } catch (final Exception e) {
+ } catch (final Exception ignore) {
return null;
}
}
Modified: libs/argparser/trunk/src/prj/net/sf/japi/io/args/converter/InputStreamConverter.java
===================================================================
--- libs/argparser/trunk/src/prj/net/sf/japi/io/args/converter/InputStreamConverter.java 2008-12-28 20:05:30 UTC (rev 751)
+++ libs/argparser/trunk/src/prj/net/sf/japi/io/args/converter/InputStreamConverter.java 2008-12-28 21:50:19 UTC (rev 752)
@@ -49,7 +49,7 @@
}
try {
return new URL(arg).openStream();
- } catch (final MalformedURLException e) {
+ } catch (final MalformedURLException ignore) {
return new FileInputStream(arg);
}
}
Modified: libs/io/trunk/src/prj/net/sf/japi/io/BRLineIterator.java
===================================================================
--- libs/io/trunk/src/prj/net/sf/japi/io/BRLineIterator.java 2008-12-28 20:05:30 UTC (rev 751)
+++ libs/io/trunk/src/prj/net/sf/japi/io/BRLineIterator.java 2008-12-28 21:50:19 UTC (rev 752)
@@ -52,7 +52,7 @@
private String readLine() {
try {
return in.readLine();
- } catch (final IOException e) {
+ } catch (final IOException ignore) {
return null;
}
}
Modified: libs/logging/trunk/src/prj/net/sf/japi/log/LogEntry.java
===================================================================
--- libs/logging/trunk/src/prj/net/sf/japi/log/LogEntry.java 2008-12-28 20:05:30 UTC (rev 751)
+++ libs/logging/trunk/src/prj/net/sf/japi/log/LogEntry.java 2008-12-28 21:50:19 UTC (rev 752)
@@ -88,7 +88,7 @@
i++;
}
return stackTrace[i];
- } catch (final ArrayIndexOutOfBoundsException e) {
+ } catch (final ArrayIndexOutOfBoundsException ignore) {
assert false;
throw new Error("Couldn'cause find StackTraceElement.");
}
Modified: libs/midi/trunk/src/prj/net/sf/japi/midi/MonitorReceiver.java
===================================================================
--- libs/midi/trunk/src/prj/net/sf/japi/midi/MonitorReceiver.java 2008-12-28 20:05:30 UTC (rev 751)
+++ libs/midi/trunk/src/prj/net/sf/japi/midi/MonitorReceiver.java 2008-12-28 21:50:19 UTC (rev 752)
@@ -67,7 +67,7 @@
if (out instanceof Closeable) {
try {
((Closeable) out).close();
- } catch (final IOException e) {
+ } catch (final IOException ignore) {
// ignore
}
}
Modified: libs/net/trunk/src/prj/net/sf/japi/net/Forwarder.java
===================================================================
--- libs/net/trunk/src/prj/net/sf/japi/net/Forwarder.java 2008-12-28 20:05:30 UTC (rev 751)
+++ libs/net/trunk/src/prj/net/sf/japi/net/Forwarder.java 2008-12-28 21:50:19 UTC (rev 752)
@@ -45,10 +45,10 @@
try {
final Socket client = new Socket(args[1], Integer.parseInt(args[2]));
new Forwarder(client, server).start();
- } catch (final IOException e) {
+ } catch (final IOException ignore) {
try {
server.close();
- } catch (final IOException ignore) {
+ } catch (final IOException ignored) {
/* ignore */
}
}
Modified: libs/swing-about/trunk/src/prj/net/sf/japi/swing/about/AboutDialog.java
===================================================================
--- libs/swing-about/trunk/src/prj/net/sf/japi/swing/about/AboutDialog.java 2008-12-28 20:05:30 UTC (rev 751)
+++ libs/swing-about/trunk/src/prj/net/sf/japi/swing/about/AboutDialog.java 2008-12-28 21:50:19 UTC (rev 752)
@@ -216,9 +216,9 @@
} finally {
in.close();
}
- } catch (final NullPointerException e) {
+ } catch (final NullPointerException ignore) {
licenseText = ACTION_BUILDER.getString("license.missing");
- } catch (final IOException e) {
+ } catch (final IOException ignore) {
licenseText = ACTION_BUILDER.getString("license.missing");
}
final JTextArea license = new JTextArea(licenseText, TEXT_ROWS, TEXT_COLUMNS);
@@ -240,9 +240,9 @@
@Nullable private String getStringFromBundle(@NotNull final ResourceBundle bundle, @NotNull final String key) {
try {
return bundle.getString(key);
- } catch (final MissingResourceException e) {
+ } catch (final MissingResourceException ignore) {
/* ignore */
- } catch (final ClassCastException e) {
+ } catch (final ClassCastException ignore) {
System.err.println("Internal error: value type for key " + key + " in " + bundle + " must be String.");
}
return null;
@@ -261,7 +261,7 @@
buildDeveloper = getStringFromBundle(bundle, "build.developer");
buildNumber = getStringFromBundle(bundle, "build.number");
buildTstamp = getStringFromBundle(bundle, "build.tstamp");
- } catch (final MissingResourceException e) {
+ } catch (final MissingResourceException ignore) {
/* ignore */
}
final Component aboutTab = new JLabel(actionBuilder.format("about", System.getProperty("java.version"), buildNumber, buildDeveloper, buildTstamp), SwingConstants.CENTER);
@@ -317,7 +317,7 @@
.append('=')
.append(bundle.getString(key))
.append('\n');
- } catch (final ClassCastException e) {
+ } catch (final ClassCastException ignore) {
System.err.println("Internal error: expecting build properties to be Strings, but property for key " + key + " was not a String.");
}
}
Modified: libs/swing-action/trunk/src/prj/net/sf/japi/swing/DefaultActionBuilder.java
===================================================================
--- libs/swing-action/trunk/src/prj/net/sf/japi/swing/DefaultActionBuilder.java 2008-12-28 20:05:30 UTC (rev 751)
+++ libs/swing-action/trunk/src/prj/net/sf/japi/swing/DefaultActionBuilder.java 2008-12-28 21:50:19 UTC (rev 752)
@@ -182,7 +182,7 @@
public DefaultActionBuilder(final String key) {
try {
addBundle(key + ".action");
- } catch (final MissingResourceException e) {
+ } catch (final MissingResourceException ignore) {
/* ignore */
}
}
@@ -352,8 +352,8 @@
try {
value = bundle.getString(key);
return value;
- } catch (final MissingResourceException e) { /* ignore */
- } catch (final ClassCastException e) { /* ignore */
+ } catch (final MissingResourceException ignore) { /* ignore */
+ } catch (final ClassCastException ignore) { /* ignore */
} // ignore exceptions because they don't mean errors just there's no resource, so parents are checked or null is returned.
}
for (final ActionBuilder parent : parents) {
@@ -401,8 +401,8 @@
try {
value = bundle.getString(key);
return value;
- } catch (final MissingResourceException e) { /* ignore */
- } catch (final ClassCastException e) { /* ignore */
+ } catch (final MissingResourceException ignore) { /* ignore */
+ } catch (final ClassCastException ignore) { /* ignore */
} // ignore exceptions because they don't mean errors just there's no resource, so parents are checked or null is returned.
}
for (final ActionBuilder parent : parents) {
Modified: libs/swing-action/trunk/src/prj/net/sf/japi/swing/IconManager.java
===================================================================
--- libs/swing-action/trunk/src/prj/net/sf/japi/swing/IconManager.java 2008-12-28 20:05:30 UTC (rev 751)
+++ libs/swing-action/trunk/src/prj/net/sf/japi/swing/IconManager.java 2008-12-28 21:50:19 UTC (rev 752)
@@ -93,7 +93,7 @@
public ClassLoader run() {
try {
return Thread.currentThread().getContextClassLoader();
- } catch (final SecurityException e) {
+ } catch (final SecurityException ignore) {
return getClass().getClassLoader();
}
}
Modified: libs/swing-action/trunk/src/tst/test/net/sf/japi/swing/DefaultActionBuilderTest.java
===================================================================
--- libs/swing-action/trunk/src/tst/test/net/sf/japi/swing/DefaultActionBuilderTest.java 2008-12-28 20:05:30 UTC (rev 751)
+++ libs/swing-action/trunk/src/tst/test/net/sf/japi/swing/DefaultActionBuilderTest.java 2008-12-28 21:50:19 UTC (rev 752)
@@ -46,9 +46,9 @@
//noinspection ConstantConditions
DefaultActionBuilder.find((JMenuBar) null, createSimple("item"));
Assert.fail("Expected NullPointerException or IllegalArgumentException.");
- } catch (final NullPointerException e) {
+ } catch (final NullPointerException ignore) {
// expected without @NotNull support
- } catch (final IllegalArgumentException e) {
+ } catch (final IllegalArgumentException ignore) {
// expected with @NotNull support
}
}
@@ -64,9 +64,9 @@
//noinspection ConstantConditions
DefaultActionBuilder.find(new JMenuBar(), (Action) null);
Assert.fail("Expected NullPointerException or IllegalArgumentException.");
- } catch (final NullPointerException e) {
+ } catch (final NullPointerException ignore) {
// expected without @NotNull support
- } catch (final IllegalArgumentException e) {
+ } catch (final IllegalArgumentException ignore) {
// expected with @NotNull support
}
}
@@ -82,9 +82,9 @@
//noinspection ConstantConditions
DefaultActionBuilder.find((JMenu) null, createSimple("item"));
Assert.fail("Expected NullPointerException or IllegalArgumentException.");
- } catch (final NullPointerException e) {
+ } catch (final NullPointerException ignore) {
// expected without @NotNull support
- } catch (final IllegalArgumentException e) {
+ } catch (final IllegalArgumentException ignore) {
// expected with @NotNull support
}
}
@@ -100,9 +100,9 @@
//noinspection ConstantConditions
DefaultActionBuilder.find(new JMenu(), null);
Assert.fail("Expected NullPointerException or IllegalArgumentException.");
- } catch (final NullPointerException e) {
+ } catch (final NullPointerException ignore) {
// expected without @NotNull support
- } catch (final IllegalArgumentException e) {
+ } catch (final IllegalArgumentException ignore) {
// expected with @NotNull support
}
}
Modified: libs/swing-app/trunk/src/prj/net/sf/japi/swing/app/DocumentFrame.java
===================================================================
--- libs/swing-app/trunk/src/prj/net/sf/japi/swing/app/DocumentFrame.java 2008-12-28 20:05:30 UTC (rev 751)
+++ libs/swing-app/trunk/src/prj/net/sf/japi/swing/app/DocumentFrame.java 2008-12-28 21:50:19 UTC (rev 752)
@@ -26,7 +26,7 @@
public void actionPerformed(final ActionEvent e) {
try {
setSelected(true);
- } catch (final PropertyVetoException e1) {
+ } catch (final PropertyVetoException ignore) {
/* simply ignore this. */
}
}
Modified: libs/swing-bookmarks/trunk/src/prj/net/sf/japi/swing/bookmarks/BookmarkDropTargetAdapter.java
===================================================================
--- libs/swing-bookmarks/trunk/src/prj/net/sf/japi/swing/bookmarks/BookmarkDropTargetAdapter.java 2008-12-28 20:05:30 UTC (rev 751)
+++ libs/swing-bookmarks/trunk/src/prj/net/sf/japi/swing/bookmarks/BookmarkDropTargetAdapter.java 2008-12-28 21:50:19 UTC (rev 752)
@@ -73,9 +73,9 @@
final Transferable source = dtde.getTransferable();
try {
return (BookmarkManager.Bookmark) source.getTransferData(getBookmarkDataFlavor());
- } catch (final UnsupportedFlavorException e) {
+ } catch (final UnsupportedFlavorException ignore) {
return null;
- } catch (final IOException e) {
+ } catch (final IOException ignore) {
return null;
}
}
Modified: libs/swing-keyprefs/trunk/src/prj/net/sf/japi/swing/prefs/keys/AbstractSimpleNode.java
===================================================================
--- libs/swing-keyprefs/trunk/src/prj/net/sf/japi/swing/prefs/keys/AbstractSimpleNode.java 2008-12-28 20:05:30 UTC (rev 751)
+++ libs/swing-keyprefs/trunk/src/prj/net/sf/japi/swing/prefs/keys/AbstractSimpleNode.java 2008-12-28 21:50:19 UTC (rev 752)
@@ -54,7 +54,7 @@
}
try {
return children[index];
- } catch (final ArrayIndexOutOfBoundsException e) {
+ } catch (final ArrayIndexOutOfBoundsException ignore) {
return null;
}
}
Modified: libs/swing-misc/trunk/src/prj/net/sf/japi/swing/misc/ConsoleProgress.java
===================================================================
--- libs/swing-misc/trunk/src/prj/net/sf/japi/swing/misc/ConsoleProgress.java 2008-12-28 20:05:30 UTC (rev 751)
+++ libs/swing-misc/trunk/src/prj/net/sf/japi/swing/misc/ConsoleProgress.java 2008-12-28 21:50:19 UTC (rev 752)
@@ -45,7 +45,7 @@
if (closeOut != null) {
try {
closeOut.close();
- } catch (final IOException e) {
+ } catch (final IOException ignore) {
// ignore
}
}
@@ -56,7 +56,7 @@
if (flushOut != null) {
try {
flushOut.flush();
- } catch (final IOException e) {
+ } catch (final IOException ignore) {
// ignore
}
}
@@ -66,7 +66,7 @@
public void finished() {
try {
out.append("100\n");
- } catch (final IOException e) {
+ } catch (final IOException ignore) {
// ignore
}
flush();
@@ -95,7 +95,7 @@
for (int i = 0; i < " 0%: ".length(); i++) {
out.append('\b');
}
- } catch (final IOException e) {
+ } catch (final IOException ignore) {
// ignore
}
}
@@ -111,7 +111,7 @@
out.append(String.format("%3d", prog));
flush();
out.append("\b\b\b");
- } c...
[truncated message content] |
|
From: <chr...@us...> - 2008-12-29 04:10:15
|
Revision: 757
http://japi.svn.sourceforge.net/japi/?rev=757&view=rev
Author: christianhujer
Date: 2008-12-29 04:10:11 +0000 (Mon, 29 Dec 2008)
Log Message:
-----------
Made all local variables final that can be final.
Modified Paths:
--------------
historic/trunk/src/app/net/sf/japi/finance/SimpleCapitalCalculator.java
historic/trunk/src/app/net/sf/japi/util/Table.java
historic/trunk/src/doc/guide/io/src/UniqPlain.java
progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/jtest/io/JTestV1.java
Modified: historic/trunk/src/app/net/sf/japi/finance/SimpleCapitalCalculator.java
===================================================================
--- historic/trunk/src/app/net/sf/japi/finance/SimpleCapitalCalculator.java 2008-12-29 04:02:35 UTC (rev 756)
+++ historic/trunk/src/app/net/sf/japi/finance/SimpleCapitalCalculator.java 2008-12-29 04:10:11 UTC (rev 757)
@@ -41,7 +41,7 @@
* @param numberOfPeriods
* @return the overall capital after numberOfPeriods periods
*/
- public double calculateCapital( int numberOfPeriods ) {
+ public double calculateCapital( final int numberOfPeriods ) {
if ( numberOfPeriods < 0 ) {
throw new IllegalArgumentException("Number of periods has to be at least 0!");
}
@@ -62,14 +62,14 @@
/** Sets new current capital.
* @param currentCapital
*/
- public void setCurrentCapital(double currentCapital) {
+ public void setCurrentCapital(final double currentCapital) {
this.currentCapital = currentCapital;
}
/** Sets new interest rate.
* @param interestRate
*/
- public void setInterestRate(double interestRate) {
+ public void setInterestRate(final double interestRate) {
this.interestRate = interestRate;
}
Modified: historic/trunk/src/app/net/sf/japi/util/Table.java
===================================================================
--- historic/trunk/src/app/net/sf/japi/util/Table.java 2008-12-29 04:02:35 UTC (rev 756)
+++ historic/trunk/src/app/net/sf/japi/util/Table.java 2008-12-29 04:10:11 UTC (rev 757)
@@ -67,7 +67,7 @@
*/
public Collection<Pair<T1,T2>> getPairsByFirst(final T1 first) {
final Set<Pair<T1,T2>> pairsByFirst = new HashSet<Pair<T1,T2>>();
- for (Pair<T1, T2> pair : pairs) {
+ for (final Pair<T1, T2> pair : pairs) {
final T1 pairFirst = pair.getFirst();
if (pairFirst.equals(first)) {
pairsByFirst.add(pair);
@@ -82,7 +82,7 @@
*/
public Collection<Pair<T1,T2>> getPairsBySecond(final T2 second) {
final Set<Pair<T1,T2>> pairsBySecond = new HashSet<Pair<T1,T2>>();
- for (Pair<T1, T2> pair : pairs) {
+ for (final Pair<T1, T2> pair : pairs) {
final T2 pairSecond = pair.getSecond();
if (pairSecond.equals(second)) {
pairsBySecond.add(pair);
Modified: historic/trunk/src/doc/guide/io/src/UniqPlain.java
===================================================================
--- historic/trunk/src/doc/guide/io/src/UniqPlain.java 2008-12-29 04:02:35 UTC (rev 756)
+++ historic/trunk/src/doc/guide/io/src/UniqPlain.java 2008-12-29 04:10:11 UTC (rev 757)
@@ -34,7 +34,7 @@
} else {
for (final String arg : args) {
try {
- BufferedReader in = new BufferedReader(new FileReader(arg));
+ final BufferedReader in = new BufferedReader(new FileReader(arg));
try {
for (String line; (line = in.readLine()) != null;) {
if (!line.equals(prevLine)) {
Modified: progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/jtest/io/JTestV1.java
===================================================================
--- progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/jtest/io/JTestV1.java 2008-12-29 04:02:35 UTC (rev 756)
+++ progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/jtest/io/JTestV1.java 2008-12-29 04:10:11 UTC (rev 757)
@@ -133,21 +133,21 @@
* @throws SAXException in case of XML parsing errors
*/
public QuestionCollection load(final Document doc) throws IOException, SAXException {
- List<QuestionText> questions = new ArrayList<QuestionText>();
- NodeList questionEls = doc.getElementsByTagName("QuestionText");
- int questionElsSize = questionEls.getLength();
+ final List<QuestionText> questions = new ArrayList<QuestionText>();
+ final NodeList questionEls = doc.getElementsByTagName("QuestionText");
+ final int questionElsSize = questionEls.getLength();
for (int i = 0; i < questionElsSize; i++) {
- Element questionEl = (Element) questionEls.item(i);
- String qtype = questionEl.getAttribute("qtype");
+ final Element questionEl = (Element) questionEls.item(i);
+ final String qtype = questionEl.getAttribute("qtype");
if ("regex".equals(qtype)) {
- List<String> expressions = new ArrayList<String>();
- NodeList textEls = questionEl.getChildNodes();
- int textElsSize = textEls.getLength();
+ final List<String> expressions = new ArrayList<String>();
+ final NodeList textEls = questionEl.getChildNodes();
+ final int textElsSize = textEls.getLength();
String questionText = null;
for (int j = 0; j < textElsSize; j++) {
- Node n = textEls.item(j);
+ final Node n = textEls.item(j);
if (n.getNodeType() == ELEMENT_NODE) {
- String tagName = n.getNodeName();
+ final String tagName = n.getNodeName();
if ("text".equals(tagName)) {
questionText = n.getFirstChild().getNodeValue();
} else if ("regex".equals(tagName)) {
@@ -155,19 +155,19 @@
}
}
}
- OpenQuestionText question = new OpenQuestionText(questionText, expressions);
+ final OpenQuestionText question = new OpenQuestionText(questionText, expressions);
question.setType(questionEl.getAttribute("type"));
question.setHTML(true);
questions.add(question);
} else {
- List<MCAnswerText> answers = new ArrayList<MCAnswerText>();
- NodeList textEls = questionEl.getChildNodes();
- int textElsSize = textEls.getLength();
+ final List<MCAnswerText> answers = new ArrayList<MCAnswerText>();
+ final NodeList textEls = questionEl.getChildNodes();
+ final int textElsSize = textEls.getLength();
String questionText = null;
for (int j = 0; j < textElsSize; j++) {
- Node n = textEls.item(j);
+ final Node n = textEls.item(j);
if (n.getNodeType() == ELEMENT_NODE) {
- String tagName = n.getNodeName();
+ final String tagName = n.getNodeName();
if ("text".equals(tagName)) {
questionText = n.getFirstChild().getNodeValue();
} else if ("true".equals(tagName)) {
@@ -177,13 +177,13 @@
}
}
}
- QuestionText question = new MCQuestionText(questionText, answers);
+ final QuestionText question = new MCQuestionText(questionText, answers);
question.setType(questionEl.getAttribute("type"));
question.setHTML(true);
questions.add(question);
}
}
- QuestionCollection col = new QuestionCollection(questions);
+ final QuestionCollection col = new QuestionCollection(questions);
setInfo(col, doc);
return col;
}
@@ -216,7 +216,7 @@
if (!(domImpl instanceof DOMImplementationLS)) {
throw new IOException("DOM Implementation with LS-Feature required, upgrade your Java XML Library");
}
- DOMImplementationLS ls = (DOMImplementationLS) domImpl;
+ final DOMImplementationLS ls = (DOMImplementationLS) domImpl;
ls.createLSSerializer().writeToURI(export(col), f.toURI().toString());
}
@@ -225,12 +225,12 @@
* @return XML Document (KEduca) for <var>col</var>
*/
public Document export(final QuestionCollection col) {
- DocumentType keduca = domImpl.createDocumentType("educa", null, null);
- Document doc = domImpl.createDocument(null, "Document", keduca);
+ final DocumentType keduca = domImpl.createDocumentType("educa", null, null);
+ final Document doc = domImpl.createDocument(null, "Document", keduca);
//System.err.println("<!DOCTYPE " + doc.getDoctype().getName() + ">");
- Element docEl = doc.getDocumentElement();
+ final Element docEl = doc.getDocumentElement();
{
- Element infoEl = doc.createElement("info");
+ final Element infoEl = doc.createElement("info");
docEl.appendChild(infoEl);
infoEl.appendChild(create(doc, "title", col.getTitle()));
infoEl.appendChild(create(doc, "category", col.getCategory()));
@@ -238,7 +238,7 @@
infoEl.appendChild(create(doc, "level", col.getLevel()));
infoEl.appendChild(create(doc, "language", col.getLanguage()));
{
- Element authorEl = doc.createElement("author");
+ final Element authorEl = doc.createElement("author");
infoEl.appendChild(authorEl);
infoEl.appendChild(create(doc, "name", col.getAuthorName()));
infoEl.appendChild(create(doc, "email", col.getAuthorEMail()));
@@ -246,10 +246,10 @@
}
}
{
- Element dataEl = doc.createElement("data");
+ final Element dataEl = doc.createElement("data");
docEl.appendChild(dataEl);
for (int i = 0; i < col.getSize(); i++) {
- QuestionText qt = col.getQuestion(i);
+ final QuestionText qt = col.getQuestion(i);
if (qt instanceof MCQuestionText) { // skip answers other than Multiple Choice
dataEl.appendChild(createQuestionEl(doc, (MCQuestionText) qt));
}
@@ -264,13 +264,13 @@
* @return element for question
*/
private Element createQuestionEl(final Document doc, final MCQuestionText question) {
- Element questionEl = doc.createElement("question");
+ final Element questionEl = doc.createElement("question");
if (question.getType() != null) {
questionEl.setAttribute("type", question.getType());
}
questionEl.appendChild(create(doc, "text", question.getText()));
for (int i = 0; i < question.getSize(); i++) {
- MCAnswerText answer = question.getAnswer(i);
+ final MCAnswerText answer = question.getAnswer(i);
questionEl.appendChild(create(doc, answer.isCorrect() ? "true" : "false", answer.getText()));
}
return questionEl;
@@ -283,7 +283,7 @@
* @return element with name <var>name</var> containing <var>text</var>
*/
private Element create(final Document doc, final String name, final String text) {
- Element el = doc.createElement(name);
+ final Element el = doc.createElement(name);
el.appendChild(doc.createTextNode(text));
return el;
}
@@ -301,7 +301,7 @@
/** {@inheritDoc} */
protected boolean canLoadImpl(final String uri) {
try {
- ErrorCapture capture = new ErrorCapture();
+ final ErrorCapture capture = new ErrorCapture();
db.setErrorHandler(capture);
db.parse(uri);
return capture.hadErrors();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <chr...@us...> - 2009-02-21 16:21:23
|
Revision: 1002
http://japi.svn.sourceforge.net/japi/?rev=1002&view=rev
Author: christianhujer
Date: 2009-02-21 16:21:18 +0000 (Sat, 21 Feb 2009)
Log Message:
-----------
Moved learning classes from midi library to midilearn program.
Added Paths:
-----------
progs/midilearn/trunk/src/prj/net/sf/japi/midilearn/Interval.java
progs/midilearn/trunk/src/prj/net/sf/japi/midilearn/IntervalTrainer.java
Removed Paths:
-------------
libs/midi/trunk/src/prj/net/sf/japi/midi/Interval.java
libs/midi/trunk/src/prj/net/sf/japi/midi/IntervalTrainer.java
Deleted: libs/midi/trunk/src/prj/net/sf/japi/midi/Interval.java
===================================================================
--- libs/midi/trunk/src/prj/net/sf/japi/midi/Interval.java 2009-02-20 21:22:29 UTC (rev 1001)
+++ libs/midi/trunk/src/prj/net/sf/japi/midi/Interval.java 2009-02-21 16:21:18 UTC (rev 1002)
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2009 Christian Hujer.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package net.sf.japi.midi;
-
-import java.util.Locale;
-import java.util.ResourceBundle;
-import org.jetbrains.annotations.NotNull;
-
-/** An Interval, used for the {@link IntervalTrainer}.
- * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
- */
-public class Interval {
-
- /** The distance of this interval, e.g. 0 for prime, 12 for octave. */
- private int distance;
-
- /** Returns the names of this interval in the current locale.
- * @return The names of this interval in the current locale.
- */
- public String[] getNames() {
- return ResourceBundle.getBundle("Interval").getString("I_" + distance + ".names").split(",");
- }
-
- /** Returns the names of this interval in the specified locale.
- * @param locale Locale in which to return the names.
- * @return The names of this interval in the specified locale.
- */
- public String[] getNames(@NotNull final Locale locale) {
- return ResourceBundle.getBundle("Interval", locale).getString("I_" + distance + ".names").split(",");
- }
-}
Deleted: libs/midi/trunk/src/prj/net/sf/japi/midi/IntervalTrainer.java
===================================================================
--- libs/midi/trunk/src/prj/net/sf/japi/midi/IntervalTrainer.java 2009-02-20 21:22:29 UTC (rev 1001)
+++ libs/midi/trunk/src/prj/net/sf/japi/midi/IntervalTrainer.java 2009-02-21 16:21:18 UTC (rev 1002)
@@ -1,28 +0,0 @@
-/*
- * Copyright (C) 2009 Christian Hujer.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package net.sf.japi.midi;
-
-/** Training program for intervals.
- * Plays intervals and asks the user to tell the correct kind of interval.
- * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
- */
-public class IntervalTrainer {
-
-}
-
Copied: progs/midilearn/trunk/src/prj/net/sf/japi/midilearn/Interval.java (from rev 999, libs/midi/trunk/src/prj/net/sf/japi/midi/Interval.java)
===================================================================
--- progs/midilearn/trunk/src/prj/net/sf/japi/midilearn/Interval.java (rev 0)
+++ progs/midilearn/trunk/src/prj/net/sf/japi/midilearn/Interval.java 2009-02-21 16:21:18 UTC (rev 1002)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2009 Christian Hujer
+ *
+ * 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 3 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, see <http://www.gnu.org/licenses/>.
+ */
+
+package net.sf.japi.midilearn;
+
+import java.util.Locale;
+import java.util.ResourceBundle;
+import org.jetbrains.annotations.NotNull;
+
+/** An Interval, used for the {@link IntervalTrainer}.
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
+ */
+public class Interval {
+
+ /** The distance of this interval, e.g. 0 for prime, 12 for octave. */
+ private int distance;
+
+ /** Returns the names of this interval in the current locale.
+ * @return The names of this interval in the current locale.
+ */
+ public String[] getNames() {
+ return ResourceBundle.getBundle("Interval").getString("I_" + distance + ".names").split(",");
+ }
+
+ /** Returns the names of this interval in the specified locale.
+ * @param locale Locale in which to return the names.
+ * @return The names of this interval in the specified locale.
+ */
+ public String[] getNames(@NotNull final Locale locale) {
+ return ResourceBundle.getBundle("Interval", locale).getString("I_" + distance + ".names").split(",");
+ }
+}
Property changes on: progs/midilearn/trunk/src/prj/net/sf/japi/midilearn/Interval.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:eol-style
+ LF
Copied: progs/midilearn/trunk/src/prj/net/sf/japi/midilearn/IntervalTrainer.java (from rev 999, libs/midi/trunk/src/prj/net/sf/japi/midi/IntervalTrainer.java)
===================================================================
--- progs/midilearn/trunk/src/prj/net/sf/japi/midilearn/IntervalTrainer.java (rev 0)
+++ progs/midilearn/trunk/src/prj/net/sf/japi/midilearn/IntervalTrainer.java 2009-02-21 16:21:18 UTC (rev 1002)
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2009 Christian Hujer
+ *
+ * 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 3 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, see <http://www.gnu.org/licenses/>.
+ */
+
+package net.sf.japi.midilearn;
+
+/** Training program for intervals.
+ * Plays intervals and asks the user to tell the correct kind of interval.
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
+ */
+public class IntervalTrainer {
+
+}
+
Property changes on: progs/midilearn/trunk/src/prj/net/sf/japi/midilearn/IntervalTrainer.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:eol-style
+ LF
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <chr...@us...> - 2009-05-12 23:25:30
|
Revision: 1293
http://japi.svn.sourceforge.net/japi/?rev=1293&view=rev
Author: christianhujer
Date: 2009-05-12 23:25:17 +0000 (Tue, 12 May 2009)
Log Message:
-----------
Move sql classes to a module of their own.
Added Paths:
-----------
libs/sql/trunk/src/prj/net/sf/japi/sql/CachedResultSetTableModel.java
libs/sql/trunk/src/prj/net/sf/japi/sql/DatabaseTreeModel.java
libs/sql/trunk/src/prj/net/sf/japi/sql/ResultSetTableModel.java
libs/sql/trunk/src/prj/net/sf/japi/sql/SQLHelper.java
libs/sql/trunk/src/prj/net/sf/japi/sql/ScrollResultSetTableModel.java
libs/sql/trunk/src/prj/net/sf/japi/sql/package.html
Removed Paths:
-------------
historic/trunk/src/app/net/sf/japi/sql/CachedResultSetTableModel.java
historic/trunk/src/app/net/sf/japi/sql/DatabaseTreeModel.java
historic/trunk/src/app/net/sf/japi/sql/ResultSetTableModel.java
historic/trunk/src/app/net/sf/japi/sql/SQLHelper.java
historic/trunk/src/app/net/sf/japi/sql/ScrollResultSetTableModel.java
historic/trunk/src/app/net/sf/japi/sql/package.html
Deleted: historic/trunk/src/app/net/sf/japi/sql/CachedResultSetTableModel.java
===================================================================
--- historic/trunk/src/app/net/sf/japi/sql/CachedResultSetTableModel.java 2009-05-12 23:24:22 UTC (rev 1292)
+++ historic/trunk/src/app/net/sf/japi/sql/CachedResultSetTableModel.java 2009-05-12 23:25:17 UTC (rev 1293)
@@ -1,170 +0,0 @@
-/* JAPI - (Yet another (hopefully) useful) Java API
- *
- * Copyright (C) 2004-2006 Christian Hujer
- *
- * 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.
- */
-
-package net.sf.japi.sql;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import javax.swing.table.AbstractTableModel;
-import javax.swing.table.TableModel;
-import net.sf.japi.util.ThrowableHandler;
-import org.jetbrains.annotations.Nullable;
-
-/** An implementation of <code>javax.swing.TableModel</code> for an SQL ResultSet.
- * In contrast to @see ResultSetTableModel this implementation reads all data upon setting the ResultSet.
- * The advantage is that reading the ResultSet does not require the database connection anymore.
- * The disadvantage is that this class requires much memory on large results and may fail for OutOfMemory on huge results.
- * This class is fully serializable, at least in the way Swing classes are at all serializable.
- * <p/>
- * Serialized instances will also serialize the cached data.
- * The data source information is not serialized.
- * @see ResultSet
- * @see TableModel
- * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
- * @todo maybe setResultSet should throw SQLException?
- */
-public class CachedResultSetTableModel extends AbstractTableModel implements ResultSetTableModel {
-
- /** Serial Version. */
- private static final long serialVersionUID = 1L;
-
- /** The number of rows.
- * @serial include
- */
- private int rowCount;
-
- /** The number of columns.
- * @serial include
- */
- private int columnCount;
-
- /** The column titles.
- * @serial include
- */
- @Nullable private String[] columnTitles;
-
- /** The Data.
- * @serial include
- */
- @Nullable private Object[][] data;
-
- /** The ResultSet. */
- @Nullable private ResultSet resultSet;
-
- /** Create a CachedResultSetTableModel. */
- public CachedResultSetTableModel() {
- }
-
- /** Create a CachedResultSetTableModel.
- * @param rs Initial ResultSet
- */
- public CachedResultSetTableModel(@Nullable final ResultSet rs) {
- setResultSet(rs);
- }
-
- /** Report an exception to all registered ThrowableHandlers.
- * @param exception Exception to report
- */
- private void handleException(final SQLException exception) {
- final Object[] listeners = listenerList.getListenerList();
- for (int i = listeners.length - 2; i >= 0; i -= 2) {
- //noinspection ObjectEquality
- if (listeners[i] == ThrowableHandler.class) {
- ((ThrowableHandler<? super SQLException>) listeners[i + 1]).handleThrowable(exception);
- }
- }
- }
-
- /** {@inheritDoc} */
- public void setResultSet(@Nullable final ResultSet resultSet) {
- if (resultSet == null) {
- this.resultSet = resultSet;
- rowCount = 0;
- columnCount = 0;
- columnTitles = null;
- data = null;
- } else {
- try {
- columnTitles = SQLHelper.getColumnLabels(resultSet);
- columnCount = columnTitles != null ? columnTitles.length : 0;
- rowCount = SQLHelper.getRowCount(resultSet);
- data = SQLHelper.getData(resultSet);
- this.resultSet = resultSet;
- } catch (final SQLException e) {
- handleException(e);
- rowCount = 0;
- columnCount = 0;
- columnTitles = null;
- data = null;
- return; // don't invoke fireTableStructureChanged() twice then.
- }
- }
- fireTableStructureChanged();
- }
-
- /** {@inheritDoc} */
- @Nullable public ResultSet getResultSet() {
- return resultSet;
- }
-
- /** {@inheritDoc} */
- public void addThrowableHandler(final ThrowableHandler<? super SQLException> throwableHandler) {
- listenerList.add(ThrowableHandler.class, throwableHandler);
- }
-
- /** {@inheritDoc} */
- public void removeThrowableHandler(final ThrowableHandler<? super SQLException> throwableHandler) {
- listenerList.remove(ThrowableHandler.class, throwableHandler);
- }
-
- /** @see TableModel */
- public int getColumnCount() {
- return columnCount;
- }
-
- /** @see TableModel */
- public int getRowCount() {
- return rowCount;
- }
-
- /** @see TableModel */
- @Nullable public Object getValueAt(final int rowIndex, final int columnIndex) {
- try {
- return data[rowIndex][columnIndex];
- } catch (final NullPointerException ignore) {
- return null;
- } catch (final ArrayIndexOutOfBoundsException ignore) {
- return null;
- }
- }
-
- /** {@inheritDoc}
- * Always returns <code>String.class</code>.
- */
- @Override public Class<?> getColumnClass(final int columnIndex) {
- return String.class;
- }
-
- /** {@inheritDoc} */
- @Override @Nullable public String getColumnName(final int column) {
- return columnTitles != null ? columnTitles[column] : null;
- }
-
-} // class CachedResultSetTableModel
Deleted: historic/trunk/src/app/net/sf/japi/sql/DatabaseTreeModel.java
===================================================================
--- historic/trunk/src/app/net/sf/japi/sql/DatabaseTreeModel.java 2009-05-12 23:24:22 UTC (rev 1292)
+++ historic/trunk/src/app/net/sf/japi/sql/DatabaseTreeModel.java 2009-05-12 23:25:17 UTC (rev 1293)
@@ -1,250 +0,0 @@
-/* JAPI - (Yet another (hopefully) useful) Java API
- *
- * Copyright (C) 2004-2006 Christian Hujer
- *
- * 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.
- */
-
-package net.sf.japi.sql;
-
-import java.sql.DatabaseMetaData;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.List;
-import javax.swing.event.EventListenerList;
-import javax.swing.event.TreeModelEvent;
-import javax.swing.event.TreeModelListener;
-import javax.swing.tree.TreeModel;
-import javax.swing.tree.TreePath;
-
-/** A TreeModel displaying the catalogs of a database (usually tables and views) as tree.
- * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
- */
-@SuppressWarnings({"ObjectEquality"})
-public class DatabaseTreeModel implements TreeModel {
-
- /** The event listeners. */
- private final EventListenerList listenerList = new EventListenerList();
-
- /** The Database nodes in the tree. */
- private final List<CatalogTreeNode> catalogs = new ArrayList<CatalogTreeNode>();
-
- /** The Database Metadata of the database this treemodel reflects. */
- private DatabaseMetaData databaseMetaData;
-
- /** Create a DatabaseTreeModel.
- * Thw tree model is not yet connected to databaseMetaData.
- */
- public DatabaseTreeModel() {
- }
-
- /** Create a DatabaseTreeModel for a Database.
- * @param databaseMetaData Database Metadata for this tree model
- * @throws SQLException in case of database problems
- */
- public DatabaseTreeModel(final DatabaseMetaData databaseMetaData) throws SQLException {
- this.databaseMetaData = databaseMetaData;
- refresh();
- }
-
- /** Refresh the data of this model from the database.
- * @throws SQLException in case of database problems
- */
- public void refresh() throws SQLException {
- catalogs.clear();
- if (databaseMetaData != null) {
- final ResultSet rs = databaseMetaData.getCatalogs();
- try {
- while (rs.next()) {
- try {
- catalogs.add(new CatalogTreeNode(rs.getString(1)));
- } catch (final SQLException e) {
- System.err.println(e);
- // TODO
- }
- }
- } finally {
- rs.close();
- }
- }
- fireTreeStructureChanged();
- }
-
- /** Set the databaseMetaData for this model.
- * @param databaseMetaData database meta data for this model
- * @throws SQLException in case of database problems
- */
- public void setDatabaseMetaData(final DatabaseMetaData databaseMetaData) throws SQLException {
- this.databaseMetaData = databaseMetaData;
- refresh();
- }
-
- /** Get the databaseMetaData of this model.
- * @return databaseMetaData of this model
- */
- public DatabaseMetaData getDatabaseMetaData() {
- return databaseMetaData;
- }
-
- /** {@inheritDoc} */
- public void addTreeModelListener(final TreeModelListener l) {
- listenerList.add(TreeModelListener.class, l);
- }
-
- /** {@inheritDoc} */
- public Object getChild(final Object parent, final int index) {
- if (parent == this) {
- return catalogs.get(index);
- } else {
- assert parent instanceof CatalogTreeNode;
- return ((CatalogTreeNode) parent).getTable(index);
- }
- }
-
- /** {@inheritDoc} */
- public int getChildCount(final Object parent) {
- return parent == this ? catalogs.size() : ((CatalogTreeNode) parent).getTableCount();
- }
-
- /** {@inheritDoc} */
- public int getIndexOfChild(final Object parent, final Object child) {
- return parent == this ? catalogs.indexOf(child) : ((CatalogTreeNode) parent).getTableIndex((CatalogTreeNode.TableTreeNode) child);
- }
-
- /** {@inheritDoc} */
- public Object getRoot() {
- return this;
- }
-
- /** {@inheritDoc} */
- public boolean isLeaf(final Object node) {
- return node instanceof CatalogTreeNode.TableTreeNode;
- }
-
- /** {@inheritDoc} */
- public void removeTreeModelListener(final TreeModelListener l) {
- listenerList.remove(TreeModelListener.class, l);
- }
-
- /** {@inheritDoc} */
- public void valueForPathChanged(final TreePath path, final Object newValue) {
- }
-
- /** Event fire if the tree has changed. */
- private void fireTreeStructureChanged() {
- TreeModelEvent e = null;
- final Object[] listeners = listenerList.getListenerList();
- for (int i = listeners.length - 2; i >= 0; i -= 2) {
- if (listeners[i] == TreeModelListener.class) {
- if (e == null) {
- e = new TreeModelEvent(this, new Object[] { this });
- }
- ((TreeModelListener) listeners[i + 1]).treeStructureChanged(e);
- }
- }
- }
-
- /** A TreeNode reflecting a Database. */
- public class CatalogTreeNode {
-
- /** The name of this catalog. */
- private String catalog;
-
- /** The tables of this catalog. */
- private final List<TableTreeNode> tables = new ArrayList<TableTreeNode>();
-
- /** Create a CatalogTreeNode.
- * @param catalog Catalog for which to create a CatalogTreeNode.
- * @throws SQLException in case of database problems
- */
- CatalogTreeNode(final String catalog) throws SQLException {
- this.catalog = catalog;
- final ResultSet rs = databaseMetaData.getTables(catalog, null, null, null);
- try {
- while (rs.next()) {
- tables.add(new TableTreeNode(rs.getString("TABLE_NAME")));
- }
- } finally {
- rs.close();
- }
- }
-
- /** Get a table with a certain index.
- * @param index index of table to get
- * @return table for <var>index</var>
- */
- TableTreeNode getTable(final int index) {
- return tables.get(index);
- }
-
- /** Get the number of tables.
- * @return number of tables
- */
- public int getTableCount() {
- return tables.size();
- }
-
- /** Get the index of a table.
- * @param table Table to get index of
- * @return index of <var>table</var>
- */
- public int getTableIndex(final TableTreeNode table) {
- return tables.indexOf(table);
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return catalog;
- }
-
- /** A TreeNode reflecting a Table. */
- public class TableTreeNode {
-
- /** The name of this table. */
- private String table;
-
- /** Create a TableTreeNode.
- * @param table Table name for which to create a TableTreeNode.
- */
- TableTreeNode(final String table) {
- this.table = table;
- }
-
- /** Get the name of the table this TableTreeNode represents.
- * @return table name
- */
- public String getTableName() {
- return catalog + '.' + table;
- }
-
- /** Get the name of the catalog this TableTreeNode is in.
- * @return catalog name
- */
- public String getCatalogName() {
- return catalog;
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return table;
- }
-
- } // class TableTreeNode
-
- } // class CatalogTreeNode
-
-} // class DatabaseTreeModel
Deleted: historic/trunk/src/app/net/sf/japi/sql/ResultSetTableModel.java
===================================================================
--- historic/trunk/src/app/net/sf/japi/sql/ResultSetTableModel.java 2009-05-12 23:24:22 UTC (rev 1292)
+++ historic/trunk/src/app/net/sf/japi/sql/ResultSetTableModel.java 2009-05-12 23:25:17 UTC (rev 1293)
@@ -1,53 +0,0 @@
-/* JAPI - (Yet another (hopefully) useful) Java API
- *
- * Copyright (C) 2004-2006 Christian Hujer
- *
- * 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.
- */
-
-package net.sf.japi.sql;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import javax.swing.table.TableModel;
-import net.sf.japi.util.ThrowableHandler;import org.jetbrains.annotations.Nullable;
-
-/** Interface for TableModels which handle information from ResultSets.
- * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
- */
-public interface ResultSetTableModel extends TableModel {
-
- /** Set the ResultSet.
- * @param resultSet ResultSet, maybe <code>null</code>
- */
- void setResultSet(ResultSet resultSet);
-
- /** Get the ResultSet.
- * @return ResultSet or <code>null</code> if there is no current result set
- */
- @Nullable ResultSet getResultSet();
-
- /** Adds a ThrowableHandler to this model.
- * @param throwableHandler ThrowableHandler to add
- */
- void addThrowableHandler(ThrowableHandler<? super SQLException> throwableHandler);
-
- /** Removes a ThrowableHandler from this model.
- * @param throwableHandler ThrowableHandler to add
- */
- void removeThrowableHandler(ThrowableHandler<? super SQLException> throwableHandler);
-
-} // interface ResultSetTableModel
Deleted: historic/trunk/src/app/net/sf/japi/sql/SQLHelper.java
===================================================================
--- historic/trunk/src/app/net/sf/japi/sql/SQLHelper.java 2009-05-12 23:24:22 UTC (rev 1292)
+++ historic/trunk/src/app/net/sf/japi/sql/SQLHelper.java 2009-05-12 23:25:17 UTC (rev 1293)
@@ -1,100 +0,0 @@
-/* JAPI - (Yet another (hopefully) useful) Java API
- *
- * Copyright (C) 2004-2006 Christian Hujer
- *
- * 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.
- */
-
-package net.sf.japi.sql;
-
-import java.sql.ResultSet;
-import java.sql.ResultSetMetaData;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.List;
-
-/** A Helper Class to make work with JDBC less painful in some situations.
- * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
- */
-public class SQLHelper {
-
- /** The Type information for a two-dimensional Object Array. */
- private static final Object[][] OBJECT_ARRAY_ARRAY_INSTANCE = new Object[0][0];
-
- /** Get a ResultSet's Column Names.
- * The names are physical.
- * For names for display @see #getColumnLabels(ResultSet).
- * @param rs ResultSet
- * @return column names
- * @throws SQLException on SQL problems
- */
- public static String[] getColumnNames(final ResultSet rs) throws SQLException {
- final ResultSetMetaData md = rs.getMetaData();
- final int columnCount = md.getColumnCount();
- final String[] columnNames = new String[columnCount];
- for (int i = 0; i < columnCount; i++) {
- columnNames[i] = md.getColumnName(i + 1);
- }
- return columnNames;
- }
-
- /** Get a ResultSet's Column Labels.
- * The names are for display.
- * For physical names @see #getColumnNames(ResultSet).
- * @param rs ResultSet
- * @return column labels
- * @throws SQLException on SQL problems
- */
- public static String[] getColumnLabels(final ResultSet rs) throws SQLException {
- final ResultSetMetaData md = rs.getMetaData();
- final int columnCount = md.getColumnCount();
- final String[] columnNames = new String[columnCount];
- for (int i = 0; i < columnCount; i++) {
- columnNames[i] = md.getColumnLabel(i + 1);
- }
- return columnNames;
- }
-
- /** Get a ResultSet's result.
- * @param rs ResultSet
- * @return two-dimensional Array containing the results
- * @throws SQLException on SQL problems
- */
- public static Object[][] getData(final ResultSet rs) throws SQLException {
- final List<Object[]> resultList = new ArrayList<Object[]>();
- final ResultSetMetaData md = rs.getMetaData();
- final int columnCount = md.getColumnCount();
- while (rs.next()) {
- final Object[] row = new Object[columnCount];
- for (int i = 0; i < columnCount; i++) {
- row[i] = rs.getObject(i + 1);
- }
- resultList.add(row);
- }
- return resultList.toArray(OBJECT_ARRAY_ARRAY_INSTANCE);
- }
-
- /** Get a ResultSet's size.
- * Warning: The ResultSet's Cursor is moved by invoking this method!
- * @param rs ResultSet
- * @return the number of rows in this ResultSet
- * @throws SQLException on SQL problems
- */
- public static int getRowCount(final ResultSet rs) throws SQLException {
- return rs.last() ? rs.getRow() : 0;
- }
-
-} // class SQLHelper
Deleted: historic/trunk/src/app/net/sf/japi/sql/ScrollResultSetTableModel.java
===================================================================
--- historic/trunk/src/app/net/sf/japi/sql/ScrollResultSetTableModel.java 2009-05-12 23:24:22 UTC (rev 1292)
+++ historic/trunk/src/app/net/sf/japi/sql/ScrollResultSetTableModel.java 2009-05-12 23:25:17 UTC (rev 1293)
@@ -1,365 +0,0 @@
-/* JAPI - (Yet another (hopefully) useful) Java API
- *
- * Copyright (C) 2004-2006 Christian Hujer
- *
- * 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.
- */
-
-package net.sf.japi.sql;
-
-import java.math.BigDecimal;
-import java.sql.Blob;
-import java.sql.Clob;
-import java.sql.Date;
-import java.sql.Ref;
-import java.sql.ResultSet;
-import static java.sql.ResultSet.CONCUR_UPDATABLE;
-import java.sql.ResultSetMetaData;
-import java.sql.SQLException;
-import java.sql.Struct;
-import java.sql.Time;
-import java.sql.Timestamp;
-import java.sql.Types;
-import javax.sql.RowSet;
-import javax.sql.RowSetEvent;
-import javax.sql.RowSetListener;
-import javax.swing.JTable;
-import javax.swing.table.AbstractTableModel;
-import javax.swing.table.TableModel;
-import net.sf.japi.util.ThrowableHandler;
-import org.jetbrains.annotations.Nullable;
-
-/** An implementation of <code>javax.swing.TableModel</code> for an SQL ResultSet.
- * It is required that the ResultSet is absolutely navigatable.
- * That feature heavily depends on the JDBC Driver implementation.
- * Please note that though this class does NOT store the ResultSet data except some meta data, the {@link JTable} probably will in its own private shadow copy table model.
- * @see ResultSet
- * @see TableModel
- * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
- */
-public class ScrollResultSetTableModel extends AbstractTableModel implements ResultSetTableModel, RowSetListener {
-
- /** Serial Version. */
- private static final long serialVersionUID = 1L;
-
- /** The ResultSet. */
- @Nullable private transient ResultSet resultSet;
-
- /** The ResultSetMetaData. */
- @Nullable private transient ResultSetMetaData metaData;
-
- /** The number of rows.
- * @serial include
- */
- private int rowCount;
-
- /** The number of columns.
- * @serial include
- */
- private int columnCount;
-
- /** The column titles.
- * @serial include
- */
- @Nullable private String[] columnTitles;
-
- /** Create a ResultSetTableModel. */
- public ScrollResultSetTableModel() {
- }
-
- /** Create a ResultSetTableModel.
- * @param rs Initial ResultSet
- */
- public ScrollResultSetTableModel(final ResultSet rs) {
- setResultSet(rs);
- }
-
- /** {@inheritDoc} */
- public void setResultSet(@Nullable final ResultSet resultSet) {
- this.resultSet = resultSet;
- updateResultSetData();
- }
-
- /** Report an exception to all registered ThrowableHandlers.
- * @param exception Exception to report
- */
- private void handleException(final SQLException exception) {
- final Object[] listeners = listenerList.getListenerList();
- for (int i = listeners.length - 2; i >= 0; i -= 2) {
- //noinspection ObjectEquality
- if (listeners[i] == ThrowableHandler.class) {
- ((ThrowableHandler<? super SQLException>)listeners[i+1]).handleThrowable(exception);
- }
- }
- }
-
- /** {@inheritDoc} */
- @Nullable public ResultSet getResultSet() {
- return resultSet;
- }
-
- /** {@inheritDoc} */
- public void addThrowableHandler(final ThrowableHandler<? super SQLException> throwableHandler) {
- listenerList.add(ThrowableHandler.class, throwableHandler);
- }
-
- /** {@inheritDoc} */
- public void removeThrowableHandler(final ThrowableHandler<? super SQLException> throwableHandler) {
- listenerList.remove(ThrowableHandler.class, throwableHandler);
- }
-
- /** {@inheritDoc} */
- public void rowSetChanged(final RowSetEvent event) {
- System.err.println(event);
- updateResultSetData();
- }
-
- /** {@inheritDoc} */
- // Remove ConstantConditions once IntelliJ IDEA is smarter about null
- @SuppressWarnings({"ConstantConditions"})
- public void rowChanged(final RowSetEvent event) {
- System.err.println(event);
- if (resultSet == null) {
- return;
- }
- try {
- final int row = resultSet.getRow();
- if (resultSet.rowDeleted()) {
- fireTableRowsDeleted(row, row);
- } else if (resultSet.rowInserted()) {
- fireTableRowsInserted(row, row);
- } else if (resultSet.rowUpdated()) {
- fireTableRowsUpdated(row, row);
- }
- } catch (final SQLException e) {
- handleException(e);
- }
- }
-
- /** {@inheritDoc} */
- public void cursorMoved(final RowSetEvent event) {
- System.err.println(event);
- // ignore
- }
-
- /** {@inheritDoc} */
- public int getRowCount() {
- final ResultSet resultSet = this.resultSet;
- if (resultSet == null) {
- return 0;
- }
- try {
- return resultSet.last() ? resultSet.getRow() : 0;
- } catch (final SQLException e) {
- handleException(e);
- return 0;
- }
- //return rowCount;
- }
-
- /** {@inheritDoc} */
- public int getColumnCount() {
- if (metaData == null) {
- return 0;
- }
- try {
- return metaData.getColumnCount();
- } catch (final SQLException e) {
- handleException(e);
- return 0;
- }
- //return columnCount;
- }
-
- /** {@inheritDoc} */
- // Remove ConstantConditions once IntelliJ IDEA is smarter about null
- @SuppressWarnings({"ConstantConditions"})
- @Nullable public Object getValueAt(final int rowIndex, final int columnIndex) {
- if (resultSet == null) {
- return null;
- }
- try {
- resultSet.absolute(rowIndex + 1);
- return resultSet.getString(columnIndex + 1);
- } catch (final SQLException e) {
- handleException(e);
- setResultSet(null);
- return null;
- }
- }
-
- /** {@inheritDoc} */
- @SuppressWarnings({"OverlyComplexMethod", "OverlyLongMethod", "SwitchStatementWithTooManyBranches"})
- @Override public Class<?> getColumnClass(final int columnIndex) {
- final int type;
- try {
- if (metaData == null) {
- // TODO: Display error to usage, reset state
- return super.getColumnClass(columnIndex);
- }
- type = metaData.getColumnType(columnIndex + 1);
- } catch (final SQLException e) {
- handleException(...
[truncated message content] |