more configuration, more JAXB, more formatters v_0
authorFrantišek Kučera <franta-hg@frantovo.cz>
Sun, 22 Dec 2013 18:19:38 +0100
branchv_0
changeset 29d66858b4b563
parent 28 57c44a6baedb
child 30 b7ea47b2d4ca
more configuration, more JAXB, more formatters
java/sql-dk/src/info/globalcode/sql/dk/CLIOptions.java
java/sql-dk/src/info/globalcode/sql/dk/CLIParser.java
java/sql-dk/src/info/globalcode/sql/dk/Constants.java
java/sql-dk/src/info/globalcode/sql/dk/DatabaseConnection.java
java/sql-dk/src/info/globalcode/sql/dk/Functions.java
java/sql-dk/src/info/globalcode/sql/dk/SQLCommand.java
java/sql-dk/src/info/globalcode/sql/dk/batch/Batch.java
java/sql-dk/src/info/globalcode/sql/dk/configuration/Configuration.java
java/sql-dk/src/info/globalcode/sql/dk/configuration/DatabaseDefinition.java
java/sql-dk/src/info/globalcode/sql/dk/configuration/FormatterDefinition.java
java/sql-dk/src/info/globalcode/sql/dk/formatting/AbstractFormatter.java
java/sql-dk/src/info/globalcode/sql/dk/formatting/Formatter.java
java/sql-dk/src/info/globalcode/sql/dk/formatting/SilentFormatter.java
java/sql-dk/src/info/globalcode/sql/dk/formatting/XmlFormatter.java
     1.1 --- a/java/sql-dk/src/info/globalcode/sql/dk/CLIOptions.java	Sat Dec 21 22:22:30 2013 +0100
     1.2 +++ b/java/sql-dk/src/info/globalcode/sql/dk/CLIOptions.java	Sun Dec 22 18:19:38 2013 +0100
     1.3 @@ -20,6 +20,7 @@
     1.4  import static info.globalcode.sql.dk.Functions.isNotEmpty;
     1.5  import static info.globalcode.sql.dk.Functions.isEmpty;
     1.6  import static info.globalcode.sql.dk.Functions.equalz;
     1.7 +import info.globalcode.sql.dk.SQLCommand.COMMAND_TYPE;
     1.8  import java.util.ArrayList;
     1.9  import java.util.Collection;
    1.10  import java.util.EnumSet;
    1.11 @@ -57,14 +58,6 @@
    1.12  		DATABASES,
    1.13  		CONNECTION
    1.14  	}
    1.15 -
    1.16 -	public enum COMMAND_TYPE {
    1.17 -
    1.18 -		/** SELECT */
    1.19 -		QUERY,
    1.20 -		/** INSERT, UPDATE, DELETE */
    1.21 -		UPDATE
    1.22 -	};
    1.23  	private COMMAND_TYPE commandType;
    1.24  	private final Collection<NamedParameter> namedParameters = new ArrayList<>();
    1.25  	private final List<Parameter> numberedParameters = new ArrayList<>();
     2.1 --- a/java/sql-dk/src/info/globalcode/sql/dk/CLIParser.java	Sat Dec 21 22:22:30 2013 +0100
     2.2 +++ b/java/sql-dk/src/info/globalcode/sql/dk/CLIParser.java	Sun Dec 22 18:19:38 2013 +0100
     2.3 @@ -17,6 +17,7 @@
     2.4   */
     2.5  package info.globalcode.sql.dk;
     2.6  
     2.7 +import info.globalcode.sql.dk.SQLCommand.COMMAND_TYPE;
     2.8  import java.sql.Types;
     2.9  import java.util.ArrayList;
    2.10  import java.util.Collections;
    2.11 @@ -75,12 +76,12 @@
    2.12  					break;
    2.13  				case Tokens.SQL:
    2.14  					options.setSql(fetchNext(args, ++i));
    2.15 -					options.setCommandType(CLIOptions.COMMAND_TYPE.QUERY);
    2.16 +					options.setCommandType(COMMAND_TYPE.QUERY);
    2.17  					break;
    2.18  				case Tokens.SQL_UPDATE:
    2.19  				case Tokens.SQL_INSERT:
    2.20  					options.setSql(fetchNext(args, ++i));
    2.21 -					options.setCommandType(CLIOptions.COMMAND_TYPE.UPDATE);
    2.22 +					options.setCommandType(COMMAND_TYPE.UPDATE);
    2.23  					break;
    2.24  				case Tokens.BATCH:
    2.25  					options.setBatch(true);
     3.1 --- a/java/sql-dk/src/info/globalcode/sql/dk/Constants.java	Sat Dec 21 22:22:30 2013 +0100
     3.2 +++ b/java/sql-dk/src/info/globalcode/sql/dk/Constants.java	Sun Dec 22 18:19:38 2013 +0100
     3.3 @@ -27,6 +27,7 @@
     3.4  	public static final String LICENSE_FILE = "info/globalcode/sql/dk/license.txt";
     3.5  	public static final String VERSION_FILE = "info/globalcode/sql/dk/version.txt";
     3.6  	public static final String HELP_FILE = "info/globalcode/sql/dk/help.txt";
     3.7 +	public static final String XMLNS_CONFIGURATION = "https://sql-dk.globalcode.info/xmlns/configuration";
     3.8  
     3.9  	private Constants() {
    3.10  	}
     4.1 --- a/java/sql-dk/src/info/globalcode/sql/dk/DatabaseConnection.java	Sat Dec 21 22:22:30 2013 +0100
     4.2 +++ b/java/sql-dk/src/info/globalcode/sql/dk/DatabaseConnection.java	Sun Dec 22 18:19:38 2013 +0100
     4.3 @@ -17,9 +17,13 @@
     4.4   */
     4.5  package info.globalcode.sql.dk;
     4.6  
     4.7 +import info.globalcode.sql.dk.batch.Batch;
     4.8  import info.globalcode.sql.dk.configuration.DatabaseDefinition;
     4.9 +import info.globalcode.sql.dk.formatting.Formatter;
    4.10  import java.sql.Connection;
    4.11  import java.sql.DriverManager;
    4.12 +import java.sql.PreparedStatement;
    4.13 +import java.sql.ResultSet;
    4.14  import java.sql.SQLException;
    4.15  
    4.16  /**
    4.17 @@ -36,4 +40,76 @@
    4.18  
    4.19  		connection = DriverManager.getConnection(databaseDefinition.getUrl(), databaseDefinition.getName(), databaseDefinition.getPassword());
    4.20  	}
    4.21 +
    4.22 +	public void executeQuery(SQLCommand sqlCommand, Formatter formatter) throws SQLException {
    4.23 +		formatter.writeStartDatabase(databaseDefinition);
    4.24 +		processCommand(sqlCommand, formatter);
    4.25 +		formatter.writeEndDatabase();
    4.26 +	}
    4.27 +
    4.28 +	public void executeBatch(Batch batch, Formatter formatter) throws SQLException {
    4.29 +		formatter.writeStartDatabase(databaseDefinition);
    4.30 +		while (batch.hasNext()) {
    4.31 +			processCommand(batch.next(), formatter);
    4.32 +		}
    4.33 +		formatter.writeEndDatabase();
    4.34 +	}
    4.35 +
    4.36 +	private void processCommand(SQLCommand sqlCommand, Formatter formatter) throws SQLException {
    4.37 +		SQLCommand.COMMAND_TYPE commandType = sqlCommand.getCommandType();
    4.38 +		switch (commandType) {
    4.39 +			case QUERY:
    4.40 +				processQueryCommand(sqlCommand, formatter);
    4.41 +				break;
    4.42 +			case UPDATE:
    4.43 +				processUpdateCommand(sqlCommand, formatter);
    4.44 +				break;
    4.45 +			default:
    4.46 +				throw new IllegalArgumentException("Unexpected command type: " + commandType);
    4.47 +		}
    4.48 +	}
    4.49 +
    4.50 +	private void processQueryCommand(SQLCommand sqlCommand, Formatter formatter) throws SQLException {
    4.51 +		formatter.writeStartResultSet();
    4.52 +		formatter.writeQuery(sqlCommand.getQuery());
    4.53 +		/** TODO: formatter.writeParameters(null); */
    4.54 +		try (PreparedStatement ps = sqlCommand.prepareStatement(connection)) {
    4.55 +			sqlCommand.parametrize(ps);
    4.56 +			try (ResultSet rs = ps.executeQuery()) {
    4.57 +				processResultSet(rs, formatter);
    4.58 +			}
    4.59 +		}
    4.60 +
    4.61 +		formatter.writeEndResultSet();
    4.62 +	}
    4.63 +
    4.64 +	private void processUpdateCommand(SQLCommand sqlCommand, Formatter formatter) throws SQLException {
    4.65 +		formatter.writeStartUpdatesResult();
    4.66 +		formatter.writeQuery(sqlCommand.getQuery());
    4.67 +		/** TODO: formatter.writeParameters(null); */
    4.68 +		try (PreparedStatement ps = sqlCommand.prepareStatement(connection)) {
    4.69 +			sqlCommand.parametrize(ps);
    4.70 +			int updatedRowsCount = ps.executeUpdate();
    4.71 +			formatter.writeUpdatedRowsCount(updatedRowsCount);
    4.72 +
    4.73 +			formatter.writeStartGeneratedKeys();
    4.74 +			try (ResultSet rs = ps.getGeneratedKeys()) {
    4.75 +				processResultSet(rs, formatter);
    4.76 +			}
    4.77 +			formatter.writeEndGeneratedKeys();
    4.78 +
    4.79 +		}
    4.80 +
    4.81 +		formatter.writeEndUpdatesResult();
    4.82 +	}
    4.83 +
    4.84 +	private void processResultSet(ResultSet rs, Formatter formatter) throws SQLException {
    4.85 +		/** TODO: formatter.writeColumnsHeader(null); */
    4.86 +		while (rs.next()) {
    4.87 +			formatter.writeStartRow();
    4.88 +
    4.89 +			/** TODO: formatter.writeColumnValue(rs.get); */
    4.90 +			formatter.writeEndRow();
    4.91 +		}
    4.92 +	}
    4.93  }
     5.1 --- a/java/sql-dk/src/info/globalcode/sql/dk/Functions.java	Sat Dec 21 22:22:30 2013 +0100
     5.2 +++ b/java/sql-dk/src/info/globalcode/sql/dk/Functions.java	Sun Dec 22 18:19:38 2013 +0100
     5.3 @@ -17,6 +17,7 @@
     5.4   */
     5.5  package info.globalcode.sql.dk;
     5.6  
     5.7 +import info.globalcode.sql.dk.configuration.NameIdentified;
     5.8  import java.util.ArrayList;
     5.9  import java.util.Collection;
    5.10  import java.util.Map;
    5.11 @@ -84,4 +85,14 @@
    5.12  			return c;
    5.13  		}
    5.14  	}
    5.15 +
    5.16 +	public static <T extends NameIdentified> T findByName(Collection<T> collection, String name) {
    5.17 +		for (T element : collection) {
    5.18 +			if (equalz(element.getName(), name)) {
    5.19 +				return element;
    5.20 +			}
    5.21 +		}
    5.22 +
    5.23 +		return null;
    5.24 +	}
    5.25  }
     6.1 --- a/java/sql-dk/src/info/globalcode/sql/dk/SQLCommand.java	Sat Dec 21 22:22:30 2013 +0100
     6.2 +++ b/java/sql-dk/src/info/globalcode/sql/dk/SQLCommand.java	Sun Dec 22 18:19:38 2013 +0100
     6.3 @@ -26,9 +26,30 @@
     6.4   */
     6.5  public abstract class SQLCommand {
     6.6  
     6.7 +	private COMMAND_TYPE commandType;
     6.8  	private String query;
     6.9  
    6.10  	public abstract PreparedStatement prepareStatement(Connection c);
    6.11  
    6.12  	public abstract void parametrize(PreparedStatement ps);
    6.13 +
    6.14 +	public COMMAND_TYPE getCommandType() {
    6.15 +		return commandType;
    6.16 +	}
    6.17 +
    6.18 +	public void setCommandType(COMMAND_TYPE commandType) {
    6.19 +		this.commandType = commandType;
    6.20 +	}
    6.21 +
    6.22 +	public String getQuery() {
    6.23 +		return query;
    6.24 +	}
    6.25 +
    6.26 +	public enum COMMAND_TYPE {
    6.27 +
    6.28 +		/** SELECT */
    6.29 +		QUERY,
    6.30 +		/** INSERT, UPDATE, DELETE */
    6.31 +		UPDATE
    6.32 +	};
    6.33  }
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/java/sql-dk/src/info/globalcode/sql/dk/batch/Batch.java	Sun Dec 22 18:19:38 2013 +0100
     7.3 @@ -0,0 +1,46 @@
     7.4 +/**
     7.5 + * SQL-DK
     7.6 + * Copyright © 2013 František Kučera (frantovo.cz)
     7.7 + *
     7.8 + * This program is free software: you can redistribute it and/or modify
     7.9 + * it under the terms of the GNU General Public License as published by
    7.10 + * the Free Software Foundation, either version 3 of the License, or
    7.11 + * (at your option) any later version.
    7.12 + *
    7.13 + * This program is distributed in the hope that it will be useful,
    7.14 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    7.15 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    7.16 + * GNU General Public License for more details.
    7.17 + *
    7.18 + * You should have received a copy of the GNU General Public License
    7.19 + * along with this program. If not, see <http://www.gnu.org/licenses/>.
    7.20 + */
    7.21 +package info.globalcode.sql.dk.batch;
    7.22 +
    7.23 +import info.globalcode.sql.dk.SQLCommand;
    7.24 +import java.util.Iterator;
    7.25 +
    7.26 +/**
    7.27 + *
    7.28 + * @author Ing. František Kučera (frantovo.cz)
    7.29 + */
    7.30 +public class Batch implements Iterator<SQLCommand> {
    7.31 +
    7.32 +	@Override
    7.33 +	public boolean hasNext() {
    7.34 +		/** TODO: implement iterator */
    7.35 +		throw new UnsupportedOperationException("Not supported yet.");
    7.36 +	}
    7.37 +
    7.38 +	@Override
    7.39 +	public SQLCommand next() {
    7.40 +		/** TODO: implement iterator */
    7.41 +		throw new UnsupportedOperationException("Not supported yet.");
    7.42 +	}
    7.43 +
    7.44 +	@Override
    7.45 +	public void remove() {
    7.46 +		/** TODO: implement iterator */
    7.47 +		throw new UnsupportedOperationException("Not supported yet.");
    7.48 +	}
    7.49 +}
     8.1 --- a/java/sql-dk/src/info/globalcode/sql/dk/configuration/Configuration.java	Sat Dec 21 22:22:30 2013 +0100
     8.2 +++ b/java/sql-dk/src/info/globalcode/sql/dk/configuration/Configuration.java	Sun Dec 22 18:19:38 2013 +0100
     8.3 @@ -17,20 +17,40 @@
     8.4   */
     8.5  package info.globalcode.sql.dk.configuration;
     8.6  
     8.7 +import static info.globalcode.sql.dk.Constants.XMLNS_CONFIGURATION;
     8.8 +import static info.globalcode.sql.dk.Functions.findByName;
     8.9 +import info.globalcode.sql.dk.formatting.SilentFormatter;
    8.10 +import info.globalcode.sql.dk.formatting.XmlFormatter;
    8.11  import java.util.ArrayList;
    8.12 +import java.util.Collection;
    8.13 +import java.util.Collections;
    8.14  import java.util.List;
    8.15 +import javax.xml.bind.annotation.XmlElement;
    8.16  import javax.xml.bind.annotation.XmlRootElement;
    8.17  
    8.18  /**
    8.19   *
    8.20   * @author Ing. František Kučera (frantovo.cz)
    8.21   */
    8.22 -@XmlRootElement
    8.23 +@XmlRootElement(name = "configuration", namespace = XMLNS_CONFIGURATION)
    8.24  public class Configuration {
    8.25  
    8.26  	private List<DatabaseDefinition> databases = new ArrayList<>();
    8.27  	private List<FormatterDefinition> formatters = new ArrayList<>();
    8.28 +	private String defaultFormatter;
    8.29 +	/**
    8.30 +	 * Default list of formatters. Is used if particular name is not found in user configuration.
    8.31 +	 */
    8.32 +	private static final Collection<FormatterDefinition> buildInFormatters;
    8.33  
    8.34 +	static {
    8.35 +		Collection<FormatterDefinition> l = new ArrayList<>();
    8.36 +		l.add(new FormatterDefinition(SilentFormatter.NAME, SilentFormatter.class.getName()));
    8.37 +		l.add(new FormatterDefinition(XmlFormatter.NAME, XmlFormatter.class.getName()));
    8.38 +		buildInFormatters = Collections.unmodifiableCollection(l);
    8.39 +	}
    8.40 +
    8.41 +	@XmlElement(name = "database", namespace = XMLNS_CONFIGURATION)
    8.42  	public List<DatabaseDefinition> getDatabases() {
    8.43  		return databases;
    8.44  	}
    8.45 @@ -39,6 +59,11 @@
    8.46  		this.databases = databases;
    8.47  	}
    8.48  
    8.49 +	public DatabaseDefinition getDatabase(String name) {
    8.50 +		return findByName(databases, name);
    8.51 +	}
    8.52 +
    8.53 +	@XmlElement(name = "formatter", namespace = XMLNS_CONFIGURATION)
    8.54  	public List<FormatterDefinition> getFormatters() {
    8.55  		return formatters;
    8.56  	}
    8.57 @@ -46,4 +71,21 @@
    8.58  	public void setFormatters(List<FormatterDefinition> formatters) {
    8.59  		this.formatters = formatters;
    8.60  	}
    8.61 +
    8.62 +	public FormatterDefinition getFormatter(String name) {
    8.63 +		FormatterDefinition fd = findByName(formatters, name);
    8.64 +		return fd == null ? findByName(buildInFormatters, name) : fd;
    8.65 +	}
    8.66 +
    8.67 +	/**
    8.68 +	 * @return name of default formatter, is used if name is not specified on CLI
    8.69 +	 */
    8.70 +	@XmlElement(name = "defaultFormatter", namespace = XMLNS_CONFIGURATION)
    8.71 +	public String getDefaultFormatter() {
    8.72 +		return defaultFormatter;
    8.73 +	}
    8.74 +
    8.75 +	public void setDefaultFormatter(String defaultFormatter) {
    8.76 +		this.defaultFormatter = defaultFormatter;
    8.77 +	}
    8.78  }
     9.1 --- a/java/sql-dk/src/info/globalcode/sql/dk/configuration/DatabaseDefinition.java	Sat Dec 21 22:22:30 2013 +0100
     9.2 +++ b/java/sql-dk/src/info/globalcode/sql/dk/configuration/DatabaseDefinition.java	Sun Dec 22 18:19:38 2013 +0100
     9.3 @@ -17,9 +17,10 @@
     9.4   */
     9.5  package info.globalcode.sql.dk.configuration;
     9.6  
     9.7 +import static info.globalcode.sql.dk.Constants.XMLNS_CONFIGURATION;
     9.8  import info.globalcode.sql.dk.DatabaseConnection;
     9.9 +import java.sql.SQLException;
    9.10  import javax.xml.bind.annotation.XmlElement;
    9.11 -import javax.xml.bind.annotation.XmlTransient;
    9.12  
    9.13  /**
    9.14   *
    9.15 @@ -32,7 +33,7 @@
    9.16  	private String userName;
    9.17  	private String password;
    9.18  
    9.19 -	@XmlElement(name = "name")
    9.20 +	@XmlElement(name = "name", namespace = XMLNS_CONFIGURATION)
    9.21  	@Override
    9.22  	public String getName() {
    9.23  		return name;
    9.24 @@ -42,7 +43,7 @@
    9.25  		this.name = name;
    9.26  	}
    9.27  
    9.28 -	@XmlElement(name = "url")
    9.29 +	@XmlElement(name = "url", namespace = XMLNS_CONFIGURATION)
    9.30  	public String getUrl() {
    9.31  		return url;
    9.32  	}
    9.33 @@ -51,7 +52,7 @@
    9.34  		this.url = url;
    9.35  	}
    9.36  
    9.37 -	@XmlElement(name = "userName")
    9.38 +	@XmlElement(name = "userName", namespace = XMLNS_CONFIGURATION)
    9.39  	public String getUserName() {
    9.40  		return userName;
    9.41  	}
    9.42 @@ -60,7 +61,7 @@
    9.43  		this.userName = userName;
    9.44  	}
    9.45  
    9.46 -	@XmlElement(name = "password")
    9.47 +	@XmlElement(name = "password", namespace = XMLNS_CONFIGURATION)
    9.48  	public String getPassword() {
    9.49  		return password;
    9.50  	}
    9.51 @@ -69,8 +70,7 @@
    9.52  		this.password = password;
    9.53  	}
    9.54  
    9.55 -	@XmlTransient
    9.56 -	public DatabaseConnection connect() {
    9.57 +	public DatabaseConnection connect() throws SQLException {
    9.58  		return new DatabaseConnection(this);
    9.59  	}
    9.60  }
    10.1 --- a/java/sql-dk/src/info/globalcode/sql/dk/configuration/FormatterDefinition.java	Sat Dec 21 22:22:30 2013 +0100
    10.2 +++ b/java/sql-dk/src/info/globalcode/sql/dk/configuration/FormatterDefinition.java	Sun Dec 22 18:19:38 2013 +0100
    10.3 @@ -17,13 +17,13 @@
    10.4   */
    10.5  package info.globalcode.sql.dk.configuration;
    10.6  
    10.7 +import static info.globalcode.sql.dk.Constants.XMLNS_CONFIGURATION;
    10.8  import info.globalcode.sql.dk.DKException;
    10.9  import info.globalcode.sql.dk.formatting.Formatter;
   10.10  import info.globalcode.sql.dk.formatting.FormatterContext;
   10.11  import java.lang.reflect.Constructor;
   10.12  import java.lang.reflect.InvocationTargetException;
   10.13  import javax.xml.bind.annotation.XmlElement;
   10.14 -import javax.xml.bind.annotation.XmlTransient;
   10.15  
   10.16  /**
   10.17   *
   10.18 @@ -34,7 +34,15 @@
   10.19  	private String name;
   10.20  	private String className;
   10.21  
   10.22 -	@XmlElement(name = "name")
   10.23 +	public FormatterDefinition() {
   10.24 +	}
   10.25 +
   10.26 +	public FormatterDefinition(String name, String className) {
   10.27 +		this.name = name;
   10.28 +		this.className = className;
   10.29 +	}
   10.30 +
   10.31 +	@XmlElement(name = "name", namespace = XMLNS_CONFIGURATION)
   10.32  	@Override
   10.33  	public String getName() {
   10.34  		return name;
   10.35 @@ -54,7 +62,7 @@
   10.36  	 *
   10.37  	 * @return fully qualified class name
   10.38  	 */
   10.39 -	@XmlElement(name = "class")
   10.40 +	@XmlElement(name = "class", namespace = XMLNS_CONFIGURATION)
   10.41  	public String getClassName() {
   10.42  		return className;
   10.43  	}
   10.44 @@ -68,7 +76,6 @@
   10.45  	 * @return
   10.46  	 * @throws DKException
   10.47  	 */
   10.48 -	@XmlTransient
   10.49  	public Formatter getInstance(FormatterContext context) throws DKException {
   10.50  		try {
   10.51  			Constructor constructor = Class.forName(className).getConstructor(context.getClass());
    11.1 --- a/java/sql-dk/src/info/globalcode/sql/dk/formatting/AbstractFormatter.java	Sat Dec 21 22:22:30 2013 +0100
    11.2 +++ b/java/sql-dk/src/info/globalcode/sql/dk/formatting/AbstractFormatter.java	Sun Dec 22 18:19:38 2013 +0100
    11.3 @@ -18,6 +18,7 @@
    11.4  package info.globalcode.sql.dk.formatting;
    11.5  
    11.6  import info.globalcode.sql.dk.Parameter;
    11.7 +import info.globalcode.sql.dk.configuration.DatabaseDefinition;
    11.8  import java.util.EmptyStackException;
    11.9  import java.util.EnumSet;
   11.10  import java.util.List;
   11.11 @@ -121,7 +122,7 @@
   11.12  	}
   11.13  
   11.14  	@Override
   11.15 -	public void writeStartDatabase() {
   11.16 +	public void writeStartDatabase(DatabaseDefinition databaseDefinition) {
   11.17  		pushState(State.DATABASE, EnumSet.of(State.ROOT));
   11.18  	}
   11.19  
    12.1 --- a/java/sql-dk/src/info/globalcode/sql/dk/formatting/Formatter.java	Sat Dec 21 22:22:30 2013 +0100
    12.2 +++ b/java/sql-dk/src/info/globalcode/sql/dk/formatting/Formatter.java	Sun Dec 22 18:19:38 2013 +0100
    12.3 @@ -18,6 +18,7 @@
    12.4  package info.globalcode.sql.dk.formatting;
    12.5  
    12.6  import info.globalcode.sql.dk.Parameter;
    12.7 +import info.globalcode.sql.dk.configuration.DatabaseDefinition;
    12.8  import java.util.List;
    12.9  
   12.10  /**
   12.11 @@ -26,7 +27,7 @@
   12.12   */
   12.13  public interface Formatter {
   12.14  
   12.15 -	void writeStartDatabase();
   12.16 +	void writeStartDatabase(DatabaseDefinition databaseDefinition);
   12.17  
   12.18  	void writeEndDatabase();
   12.19  
    13.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.2 +++ b/java/sql-dk/src/info/globalcode/sql/dk/formatting/SilentFormatter.java	Sun Dec 22 18:19:38 2013 +0100
    13.3 @@ -0,0 +1,33 @@
    13.4 +/**
    13.5 + * SQL-DK
    13.6 + * Copyright © 2013 František Kučera (frantovo.cz)
    13.7 + *
    13.8 + * This program is free software: you can redistribute it and/or modify
    13.9 + * it under the terms of the GNU General Public License as published by
   13.10 + * the Free Software Foundation, either version 3 of the License, or
   13.11 + * (at your option) any later version.
   13.12 + *
   13.13 + * This program is distributed in the hope that it will be useful,
   13.14 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   13.15 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   13.16 + * GNU General Public License for more details.
   13.17 + *
   13.18 + * You should have received a copy of the GNU General Public License
   13.19 + * along with this program. If not, see <http://www.gnu.org/licenses/>.
   13.20 + */
   13.21 +package info.globalcode.sql.dk.formatting;
   13.22 +
   13.23 +/**
   13.24 + * Does not output anything, can be used instead of
   13.25 + * <code>/dev/null</code>.
   13.26 + *
   13.27 + * @author Ing. František Kučera (frantovo.cz)
   13.28 + */
   13.29 +public class SilentFormatter extends AbstractFormatter {
   13.30 +	
   13.31 +	public static final String NAME = "silent";
   13.32 +
   13.33 +	public SilentFormatter(FormatterContext formatterContext) {
   13.34 +		super(formatterContext);
   13.35 +	}
   13.36 +}
    14.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.2 +++ b/java/sql-dk/src/info/globalcode/sql/dk/formatting/XmlFormatter.java	Sun Dec 22 18:19:38 2013 +0100
    14.3 @@ -0,0 +1,31 @@
    14.4 +/**
    14.5 + * SQL-DK
    14.6 + * Copyright © 2013 František Kučera (frantovo.cz)
    14.7 + *
    14.8 + * This program is free software: you can redistribute it and/or modify
    14.9 + * it under the terms of the GNU General Public License as published by
   14.10 + * the Free Software Foundation, either version 3 of the License, or
   14.11 + * (at your option) any later version.
   14.12 + *
   14.13 + * This program is distributed in the hope that it will be useful,
   14.14 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   14.15 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   14.16 + * GNU General Public License for more details.
   14.17 + *
   14.18 + * You should have received a copy of the GNU General Public License
   14.19 + * along with this program. If not, see <http://www.gnu.org/licenses/>.
   14.20 + */
   14.21 +package info.globalcode.sql.dk.formatting;
   14.22 +
   14.23 +/**
   14.24 + *
   14.25 + * @author Ing. František Kučera (frantovo.cz)
   14.26 + */
   14.27 +public class XmlFormatter extends AbstractFormatter {
   14.28 +
   14.29 +	public static final String NAME = "xml";
   14.30 +
   14.31 +	public XmlFormatter(FormatterContext formatterContext) {
   14.32 +		super(formatterContext);
   14.33 +	}
   14.34 +}