// Path: src/main/java/com/btmatthews/maven/plugins/inmemdb/Database.java
// public interface Database {
// 
//     /**
//      * Find the loader that supports the source file and use it to load the data
//      * into or execute the script against the database.
//      *
//      * @param logger Used to report errors and raise exceptions.
//      * @param source The source file containing data or script.
//      */
//     void load(Logger logger, Source source);
// }
// 
// Path: src/main/java/com/btmatthews/maven/plugins/inmemdb/Loader.java
// public interface Loader {
// 
//     /**
//      * The message key for the error reported when a source file cannot be read.
//      */
//     String CANNOT_READ_SOURCE_FILE = "cannot_read_source_file";
// 
//     /**
//      * The message key for the error reported when a source file cannot be processed.
//      */
//     String ERROR_PROCESSING_SOURCE_FILE = "error_processing_source_file";
// 
//     /**
//      * Determine whether or not the data or script can be loaded or executed.
//      *
//      * @param logger Used to report errors and raise exceptions.
//      * @param source The source file containing the data or script.
//      * @return <ul>
//      *         <li><code>true</code> if the data or script can be loaded or executed.</li>
//      *         <li><code>false</code>if the data or script cannot be loaded or executed.</li>
//      *         </ul>
//      */
//     boolean isSupported(Logger logger, Source source);
// 
//     /**
//      * Load data into or execute a script against the in-memory database.
//      *
//      * @param logger   Used to report errors and raise exceptions.
//      * @param database The in-memory database.
//      * @param source   The source file containing the data or script.
//      */
//     void load(Logger logger, Database database, Source source);
// }
// 
// Path: src/main/java/com/btmatthews/maven/plugins/inmemdb/MessageUtil.java
// public final class MessageUtil {
// 
//     /**
//      * The base name of the message resource bundle.
//      */
//     private static final String BUNDLE_NAME = "com.btmatthews.maven.plugins.inmemdb.messages";
// 
//     /**
//      * The message resource bundle.
//      */
//     private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
// 
//     /**
//      * Make the constructor private because this class only offers static utility methods.
//      */
//     private MessageUtil() {
//     }
// 
//     /**
//      * Retrieve the message pattern for a given message key from the resource
//      * bundle and format the message replacing the place holders with the
//      * message arguments.
//      *
//      * @param messageKey The key of the message in the resource bundle.
//      * @param arguments  The message arguments.
//      * @return The expanded message string.
//      */
//     public static String getMessage(final String messageKey,
//                                     final Object... arguments) {
//         final String messagePattern = RESOURCE_BUNDLE.getString(messageKey);
//         return MessageFormat.format(messagePattern, arguments);
//     }
// }
// 
// Path: src/main/java/com/btmatthews/maven/plugins/inmemdb/Source.java
// public interface Source {
// 
//     /**
//      * Get the source file that contains the DDL/DML script or DBUnit data set.
//      *
//      * @return The source file.
//      */
//     String getSourceFile();
// 
//     /**
//      * Determine if the table names in the source file are fully qualified.
//      *
//      * @return <ul>
//      *         <li>{@link Boolean#TRUE} if the table names are fully qualified.</li>
//      *         <li>{@link Boolean#FALSE} if the table names are not fully qualified.</li>
//      *         </ul>
//      */
//     Boolean getQualifiedTableNames();
// }


import java.util.HashMap;
import java.util.Map;
import com.btmatthews.maven.plugins.inmemdb.Database;
import com.btmatthews.maven.plugins.inmemdb.Loader;
import com.btmatthews.maven.plugins.inmemdb.MessageUtil;
import com.btmatthews.maven.plugins.inmemdb.Source;
import com.btmatthews.utils.monitor.AbstractServer;
import com.btmatthews.utils.monitor.Logger;
/*
 * Copyright 2011-2012 Brian Matthews
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.btmatthews.maven.plugins.inmemdb.db;



/**
 * Abstract base classes for database objects providing an implementation of the
 * {@link Database#load(com.btmatthews.utils.monitor.Logger, com.btmatthews.maven.plugins.inmemdb.Source)}
 * operation that is used to load data into or execute scripts
 * against the database.
 *
 * @author <a href="mailto:brian@btmatthews.com">Brian Matthews</a>
 * @version 1.0.0
 */
public abstract class AbstractDatabase extends AbstractServer implements Database {

    /**
     * The message key for the error reported when a server cannot be started.
     */
    protected static final String ERROR_STARTING_SERVER = "error_starting_server";
    /**
     * The message key for the error reported when a server cannot be stopped.
     */
    protected static final String ERROR_STOPPING_SERVER = "error_stopping_server";
    /**
     * The message key for the error reported when a file type is not supported.
     */
    private static final String UNSUPPORTED_FILE_TYPE = "unsupported_file_type";
    /**
     * The database name.
     */
// Path: src/main/java/com/btmatthews/maven/plugins/inmemdb/Database.java
// public interface Database {
// 
//     /**
//      * Find the loader that supports the source file and use it to load the data
//      * into or execute the script against the database.
//      *
//      * @param logger Used to report errors and raise exceptions.
//      * @param source The source file containing data or script.
//      */
//     void load(Logger logger, Source source);
// }
// 
// Path: src/main/java/com/btmatthews/maven/plugins/inmemdb/Loader.java
// public interface Loader {
// 
//     /**
//      * The message key for the error reported when a source file cannot be read.
//      */
//     String CANNOT_READ_SOURCE_FILE = "cannot_read_source_file";
// 
//     /**
//      * The message key for the error reported when a source file cannot be processed.
//      */
//     String ERROR_PROCESSING_SOURCE_FILE = "error_processing_source_file";
// 
//     /**
//      * Determine whether or not the data or script can be loaded or executed.
//      *
//      * @param logger Used to report errors and raise exceptions.
//      * @param source The source file containing the data or script.
//      * @return <ul>
//      *         <li><code>true</code> if the data or script can be loaded or executed.</li>
//      *         <li><code>false</code>if the data or script cannot be loaded or executed.</li>
//      *         </ul>
//      */
//     boolean isSupported(Logger logger, Source source);
// 
//     /**
//      * Load data into or execute a script against the in-memory database.
//      *
//      * @param logger   Used to report errors and raise exceptions.
//      * @param database The in-memory database.
//      * @param source   The source file containing the data or script.
//      */
//     void load(Logger logger, Database database, Source source);
// }
// 
// Path: src/main/java/com/btmatthews/maven/plugins/inmemdb/MessageUtil.java
// public final class MessageUtil {
// 
//     /**
//      * The base name of the message resource bundle.
//      */
//     private static final String BUNDLE_NAME = "com.btmatthews.maven.plugins.inmemdb.messages";
// 
//     /**
//      * The message resource bundle.
//      */
//     private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
// 
//     /**
//      * Make the constructor private because this class only offers static utility methods.
//      */
//     private MessageUtil() {
//     }
// 
//     /**
//      * Retrieve the message pattern for a given message key from the resource
//      * bundle and format the message replacing the place holders with the
//      * message arguments.
//      *
//      * @param messageKey The key of the message in the resource bundle.
//      * @param arguments  The message arguments.
//      * @return The expanded message string.
//      */
//     public static String getMessage(final String messageKey,
//                                     final Object... arguments) {
//         final String messagePattern = RESOURCE_BUNDLE.getString(messageKey);
//         return MessageFormat.format(messagePattern, arguments);
//     }
// }
// 
// Path: src/main/java/com/btmatthews/maven/plugins/inmemdb/Source.java
// public interface Source {
// 
//     /**
//      * Get the source file that contains the DDL/DML script or DBUnit data set.
//      *
//      * @return The source file.
//      */
//     String getSourceFile();
// 
//     /**
//      * Determine if the table names in the source file are fully qualified.
//      *
//      * @return <ul>
//      *         <li>{@link Boolean#TRUE} if the table names are fully qualified.</li>
//      *         <li>{@link Boolean#FALSE} if the table names are not fully qualified.</li>
//      *         </ul>
//      */
//     Boolean getQualifiedTableNames();
// }


// Path: src/main/java/com/btmatthews/maven/plugins/inmemdb/db/AbstractDatabase.java
import java.util.HashMap;
import java.util.Map;
import com.btmatthews.maven.plugins.inmemdb.Database;
import com.btmatthews.maven.plugins.inmemdb.Loader;
import com.btmatthews.maven.plugins.inmemdb.MessageUtil;
import com.btmatthews.maven.plugins.inmemdb.Source;
import com.btmatthews.utils.monitor.AbstractServer;
import com.btmatthews.utils.monitor.Logger;

/*
 * Copyright 2011-2012 Brian Matthews
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.btmatthews.maven.plugins.inmemdb.db;



/**
 * Abstract base classes for database objects providing an implementation of the
 * {@link Database#load(com.btmatthews.utils.monitor.Logger, com.btmatthews.maven.plugins.inmemdb.Source)}
 * operation that is used to load data into or execute scripts
 * against the database.
 *
 * @author <a href="mailto:brian@btmatthews.com">Brian Matthews</a>
 * @version 1.0.0
 */
public abstract class AbstractDatabase extends AbstractServer implements Database {

    /**
     * The message key for the error reported when a server cannot be started.
     */
    protected static final String ERROR_STARTING_SERVER = "error_starting_server";
    /**
     * The message key for the error reported when a server cannot be stopped.
     */
    protected static final String ERROR_STOPPING_SERVER = "error_stopping_server";
    /**
     * The message key for the error reported when a file type is not supported.
     */
    private static final String UNSUPPORTED_FILE_TYPE = "unsupported_file_type";
    /**
     * The database name.
     */
    private String databaseName;