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 1395c0e344c3b60
parent 138 b765713c60e9
child 140 a4b4a96637a5
fix InfoLister: squared infos
java/sql-dk/src/info/globalcode/sql/dk/InfoLister.java
     1.1 --- a/java/sql-dk/src/info/globalcode/sql/dk/InfoLister.java	Sun Jan 05 00:17:27 2014 +0100
     1.2 +++ b/java/sql-dk/src/info/globalcode/sql/dk/InfoLister.java	Sun Jan 05 00:49:01 2014 +0100
     1.3 @@ -59,27 +59,32 @@
     1.4  	public void showInfo() throws ConfigurationException, FormatterException {
     1.5  		EnumSet<InfoType> commands = options.getShowInfo();
     1.6  
     1.7 +		boolean formattinNeeded = false;
     1.8 +
     1.9  		for (InfoType infoType : commands) {
    1.10  			switch (infoType) {
    1.11 -				// only these need formatted output
    1.12  				case CONNECTION:
    1.13  				case DATABASES:
    1.14  				case FORMATTERS:
    1.15  				case TYPES:
    1.16 -					try (Formatter f = getFormatter()) {
    1.17 -						formatter = f;
    1.18 -						formatter.writeStartBatch();
    1.19 -						formatter.writeStartDatabase(new DatabaseDefinition());
    1.20 -						showInfos(commands);
    1.21 -						formatter.writeEndDatabase();
    1.22 -						formatter.writeEndBatch();
    1.23 -						formatter.close();
    1.24 -					}
    1.25 +					formattinNeeded = true;
    1.26  					break;
    1.27 -				default:
    1.28 -					showInfos(commands);
    1.29  			}
    1.30  		}
    1.31 +
    1.32 +		if (formattinNeeded) {
    1.33 +			try (Formatter f = getFormatter()) {
    1.34 +				formatter = f;
    1.35 +				formatter.writeStartBatch();
    1.36 +				formatter.writeStartDatabase(new DatabaseDefinition());
    1.37 +				showInfos(commands);
    1.38 +				formatter.writeEndDatabase();
    1.39 +				formatter.writeEndBatch();
    1.40 +				formatter.close();
    1.41 +			}
    1.42 +		} else {
    1.43 +			showInfos(commands);
    1.44 +		}
    1.45  	}
    1.46  
    1.47  	private void showInfos(EnumSet<InfoType> commands) throws ConfigurationException, FormatterException {