option --list-formatters – list configured and built-in formatters v_0
authorFrantišek Kučera <franta-hg@frantovo.cz>
Thu, 26 Dec 2013 01:53:15 +0100
branchv_0
changeset 6710c9b9e54622
parent 66 6e28893eaada
child 68 574cd7fbb5b2
option --list-formatters – list configured and built-in formatters
java/sql-dk/src/info/globalcode/sql/dk/InfoLister.java
java/sql-dk/src/info/globalcode/sql/dk/configuration/Configuration.java
     1.1 --- a/java/sql-dk/src/info/globalcode/sql/dk/InfoLister.java	Thu Dec 26 01:29:29 2013 +0100
     1.2 +++ b/java/sql-dk/src/info/globalcode/sql/dk/InfoLister.java	Thu Dec 26 01:53:15 2013 +0100
     1.3 @@ -17,9 +17,12 @@
     1.4   */
     1.5  package info.globalcode.sql.dk;
     1.6  
     1.7 +import info.globalcode.sql.dk.configuration.Configuration;
     1.8  import info.globalcode.sql.dk.configuration.ConfigurationException;
     1.9  import info.globalcode.sql.dk.configuration.ConfigurationProvider;
    1.10  import info.globalcode.sql.dk.configuration.DatabaseDefinition;
    1.11 +import info.globalcode.sql.dk.configuration.FormatterDefinition;
    1.12 +import static info.globalcode.sql.dk.Functions.rpad;
    1.13  import java.io.BufferedReader;
    1.14  import java.io.InputStreamReader;
    1.15  import java.io.PrintStream;
    1.16 @@ -53,7 +56,24 @@
    1.17  				 * TODO: implement show info
    1.18  				 */
    1.19  				case FORMATTERS:
    1.20 -					println("TODO: list available formatters");
    1.21 +					for (FormatterDefinition fd : configurationProvider.getConfiguration().getBuildInFormatters()) {
    1.22 +						log.log(Level.INFO, "Built-in formatter:   {0} implemented by class: {1}", new Object[]{rpad(fd.getName(), 16), fd.getClassName()});
    1.23 +					}
    1.24 +
    1.25 +					List<FormatterDefinition> configuredFormatters = configurationProvider.getConfiguration().getFormatters();
    1.26 +					for (FormatterDefinition fd : configuredFormatters) {
    1.27 +						log.log(Level.INFO, "Configured formatter: {0} implemented by class: {1}", new Object[]{rpad(fd.getName(), 16), fd.getClassName()});
    1.28 +					}
    1.29 +					if (configuredFormatters.isEmpty()) {
    1.30 +						log.log(Level.INFO, "No other formatters are configured");
    1.31 +					}
    1.32 +
    1.33 +					String configuredDefaultFormatter = configurationProvider.getConfiguration().getDefaultFormatter();
    1.34 +					if (configuredDefaultFormatter == null) {
    1.35 +						log.log(Level.INFO, "Built-in default formatter: {0}", Configuration.DEFAULT_FORMATTER);
    1.36 +					} else {
    1.37 +						log.log(Level.INFO, "Configured default formatter: {0}", configuredDefaultFormatter);
    1.38 +					}
    1.39  					break;
    1.40  				case HELP:
    1.41  					printResource(Constants.HELP_FILE);
     2.1 --- a/java/sql-dk/src/info/globalcode/sql/dk/configuration/Configuration.java	Thu Dec 26 01:29:29 2013 +0100
     2.2 +++ b/java/sql-dk/src/info/globalcode/sql/dk/configuration/Configuration.java	Thu Dec 26 01:53:15 2013 +0100
     2.3 @@ -29,6 +29,7 @@
     2.4  import java.util.List;
     2.5  import javax.xml.bind.annotation.XmlElement;
     2.6  import javax.xml.bind.annotation.XmlRootElement;
     2.7 +import javax.xml.bind.annotation.XmlTransient;
     2.8  
     2.9  /**
    2.10   *
    2.11 @@ -99,6 +100,11 @@
    2.12  		}
    2.13  	}
    2.14  
    2.15 +	@XmlTransient
    2.16 +	public Collection<FormatterDefinition> getBuildInFormatters() {
    2.17 +		return buildInFormatters;
    2.18 +	}
    2.19 +
    2.20  	/**
    2.21  	 * @return name of default formatter, is used if name is not specified on CLI
    2.22  	 */