fix InfoLister: squared infos v_0
authorFrantišek Kučera <franta-hg@frantovo.cz>
Sun, 05 Jan 2014 00:49:01 +0100
branchv_0
changeset 139 5c0e344c3b60
parent 138 b765713c60e9
child 140 a4b4a96637a5
fix InfoLister: squared infos
java/sql-dk/src/info/globalcode/sql/dk/InfoLister.java
--- a/java/sql-dk/src/info/globalcode/sql/dk/InfoLister.java	Sun Jan 05 00:17:27 2014 +0100
+++ b/java/sql-dk/src/info/globalcode/sql/dk/InfoLister.java	Sun Jan 05 00:49:01 2014 +0100
@@ -59,27 +59,32 @@
 	public void showInfo() throws ConfigurationException, FormatterException {
 		EnumSet<InfoType> commands = options.getShowInfo();
 
+		boolean formattinNeeded = false;
+
 		for (InfoType infoType : commands) {
 			switch (infoType) {
-				// only these need formatted output
 				case CONNECTION:
 				case DATABASES:
 				case FORMATTERS:
 				case TYPES:
-					try (Formatter f = getFormatter()) {
-						formatter = f;
-						formatter.writeStartBatch();
-						formatter.writeStartDatabase(new DatabaseDefinition());
-						showInfos(commands);
-						formatter.writeEndDatabase();
-						formatter.writeEndBatch();
-						formatter.close();
-					}
+					formattinNeeded = true;
 					break;
-				default:
-					showInfos(commands);
 			}
 		}
+
+		if (formattinNeeded) {
+			try (Formatter f = getFormatter()) {
+				formatter = f;
+				formatter.writeStartBatch();
+				formatter.writeStartDatabase(new DatabaseDefinition());
+				showInfos(commands);
+				formatter.writeEndDatabase();
+				formatter.writeEndBatch();
+				formatter.close();
+			}
+		} else {
+			showInfos(commands);
+		}
 	}
 
 	private void showInfos(EnumSet<InfoType> commands) throws ConfigurationException, FormatterException {