--- a/java/sql-dk/src/info/globalcode/sql/dk/InfoLister.java Sun Dec 29 18:26:43 2013 +0100
+++ b/java/sql-dk/src/info/globalcode/sql/dk/InfoLister.java Mon Dec 30 00:01:39 2013 +0100
@@ -66,20 +66,26 @@
case DATABASES:
case FORMATTERS:
case TYPES:
- formatter = getFormatter();
- formatter.writeStartBatch();
- formatter.writeStartDatabase(new DatabaseDefinition());
+ try (Formatter f = getFormatter()) {
+ formatter = f;
+ formatter.writeStartBatch();
+ formatter.writeStartDatabase(new DatabaseDefinition());
+ showInfos(commands);
+ formatter.writeEndDatabase();
+ formatter.writeEndBatch();
+ formatter.close();
+ }
+ break;
+ default:
+ showInfos(commands);
}
}
+ }
+ private void showInfos(EnumSet<InfoType> commands) throws ConfigurationException, FormatterException {
for (InfoType infoType : commands) {
infoType.showInfo(this);
}
-
- if (formatter != null) {
- formatter.writeEndDatabase();
- formatter.writeEndBatch();
- }
}
private void listFormatters() throws ConfigurationException, FormatterException {