// Path: src/main/java/liquibase/ext/spatial/statement/DropSpatialIndexStatement.java
// public class DropSpatialIndexStatement extends AbstractSqlStatement {
//    /** The index name. */
//    private final String indexName;
// 
//    /** The table catalog name. */
//    private final String tableCatalogName;
// 
//    /** The table schema name. */
//    private final String tableSchemaName;
// 
//    /** The table name. */
//    private final String tableName;
// 
//    /**
//     * Creates a new instance with the given parameters.
//     * 
//     * @param indexName
//     *           the index name.
//     * @param tableCatalogName
//     *           the optional table's catalog name.
//     * @param tableSchemaName
//     *           the optional table's schema name.
//     * @param tableName
//     *           the table name.
//     */
//    public DropSpatialIndexStatement(final String indexName, final String tableCatalogName,
//          final String tableSchemaName, final String tableName) {
//       this.indexName = indexName;
//       this.tableCatalogName = tableCatalogName;
//       this.tableSchemaName = tableSchemaName;
//       this.tableName = tableName;
//    }
// 
//    /**
//     * Returns the index name.
//     * 
//     * @return the index name.
//     */
//    public String getIndexName() {
//       return this.indexName;
//    }
// 
//    /**
//     * Returns the table catalog name.
//     * 
//     * @return the table catalog name.
//     */
//    public String getTableCatalogName() {
//       return this.tableCatalogName;
//    }
// 
//    /**
//     * Returns the table schema name.
//     * 
//     * @return the table schema name.
//     */
//    public String getTableSchemaName() {
//       return this.tableSchemaName;
//    }
// 
//    /**
//     * Returns the table name.
//     * 
//     * @return the table name.
//     */
//    public String getTableName() {
//       return this.tableName;
//    }
// }
// 
// Path: src/main/java/liquibase/ext/spatial/xml/XmlConstants.java
// public interface XmlConstants {
//    /** The extension's XML namespace. */
//    static final String SPATIAL_CHANGELOG_NAMESPACE = "http://www.liquibase.org/xml/ns/dbchangelog-ext/liquibase-spatial";
// }


import java.util.ArrayList;
import java.util.Collection;
import liquibase.change.AbstractChange;
import liquibase.change.ChangeMetaData;
import liquibase.change.DatabaseChange;
import liquibase.change.DatabaseChangeProperty;
import liquibase.database.Database;
import liquibase.database.core.DerbyDatabase;
import liquibase.database.core.H2Database;
import liquibase.database.core.MySQLDatabase;
import liquibase.database.core.PostgresDatabase;
import liquibase.ext.spatial.statement.DropSpatialIndexStatement;
import liquibase.ext.spatial.xml.XmlConstants;
import liquibase.statement.SqlStatement;
import liquibase.statement.core.DropIndexStatement;
import liquibase.util.StringUtils;
package liquibase.ext.spatial.change;



/**
 * @author Lonny Jacobson
 */
@DatabaseChange(name = "dropSpatialIndex", description = "Drops the spatial index on an existing column or set of columns.", priority = ChangeMetaData.PRIORITY_DEFAULT, appliesTo = "index")
public class DropSpatialIndexChange extends AbstractChange {
   /** The name of the catalog. */
   private String catalogName;

   /** The name of the schema. */
   private String schemaName;

   /** The name of the indexed table. */
   private String tableName;

   /** The name of the index to drop. */
   private String indexName;

   @DatabaseChangeProperty(mustEqualExisting = "index.schema")
   public String getSchemaName() {
      return this.schemaName;
   }

   public void setSchemaName(final String schemaName) {
      this.schemaName = schemaName;
   }

   @DatabaseChangeProperty(mustEqualExisting = "index", description = "Name of the index to drop", requiredForDatabase = "mysql, oracle, postgresql")
   public String getIndexName() {
      return this.indexName;
   }

   public void setIndexName(final String indexName) {
      this.indexName = indexName;
   }

   @DatabaseChangeProperty(mustEqualExisting = "index.table", description = "Name fo the indexed table.", requiredForDatabase = "h2, derby")
   public String getTableName() {
      return this.tableName;
   }

   public void setTableName(final String tableName) {
      this.tableName = tableName;
   }

   @DatabaseChangeProperty(mustEqualExisting = "index.catalog")
   public String getCatalogName() {
      return this.catalogName;
   }

   public void setCatalogName(final String catalogName) {
      this.catalogName = catalogName;
   }

   @Override
   public String getSerializedObjectNamespace() {
      return XmlConstants.SPATIAL_CHANGELOG_NAMESPACE;
   }

   @Override
   public String getConfirmationMessage() {
      final StringBuilder message = new StringBuilder("Spatial index");
      if (StringUtils.trimToNull(getIndexName()) != null) {
         message.append(' ').append(getIndexName().trim());
      }
      message.append(" dropped");
      if (StringUtils.trimToNull(getTableName()) != null) {
         message.append(" from ").append(getTableName().trim());
      }
      return message.toString();
   }

   /**
    * Generates a {@link DropSpatialIndexStatement} followed by a {@link DropIndexStatement}, if
    * applicable. The first statement allows extra clean-up when dropping an index. The second
    * statement leverages the normal <code>DROP INDEX</code> logic.
    */
   @Override
   public SqlStatement[] generateStatements(final Database database) {
      final Collection<SqlStatement> statements = new ArrayList<SqlStatement>();
      // MySQL and PostgreSQL only need the normal DROP INDEX statement.
      if (!(database instanceof MySQLDatabase) && !(database instanceof PostgresDatabase)) {
// Path: src/main/java/liquibase/ext/spatial/statement/DropSpatialIndexStatement.java
// public class DropSpatialIndexStatement extends AbstractSqlStatement {
//    /** The index name. */
//    private final String indexName;
// 
//    /** The table catalog name. */
//    private final String tableCatalogName;
// 
//    /** The table schema name. */
//    private final String tableSchemaName;
// 
//    /** The table name. */
//    private final String tableName;
// 
//    /**
//     * Creates a new instance with the given parameters.
//     * 
//     * @param indexName
//     *           the index name.
//     * @param tableCatalogName
//     *           the optional table's catalog name.
//     * @param tableSchemaName
//     *           the optional table's schema name.
//     * @param tableName
//     *           the table name.
//     */
//    public DropSpatialIndexStatement(final String indexName, final String tableCatalogName,
//          final String tableSchemaName, final String tableName) {
//       this.indexName = indexName;
//       this.tableCatalogName = tableCatalogName;
//       this.tableSchemaName = tableSchemaName;
//       this.tableName = tableName;
//    }
// 
//    /**
//     * Returns the index name.
//     * 
//     * @return the index name.
//     */
//    public String getIndexName() {
//       return this.indexName;
//    }
// 
//    /**
//     * Returns the table catalog name.
//     * 
//     * @return the table catalog name.
//     */
//    public String getTableCatalogName() {
//       return this.tableCatalogName;
//    }
// 
//    /**
//     * Returns the table schema name.
//     * 
//     * @return the table schema name.
//     */
//    public String getTableSchemaName() {
//       return this.tableSchemaName;
//    }
// 
//    /**
//     * Returns the table name.
//     * 
//     * @return the table name.
//     */
//    public String getTableName() {
//       return this.tableName;
//    }
// }
// 
// Path: src/main/java/liquibase/ext/spatial/xml/XmlConstants.java
// public interface XmlConstants {
//    /** The extension's XML namespace. */
//    static final String SPATIAL_CHANGELOG_NAMESPACE = "http://www.liquibase.org/xml/ns/dbchangelog-ext/liquibase-spatial";
// }


// Path: src/main/java/liquibase/ext/spatial/change/DropSpatialIndexChange.java
import java.util.ArrayList;
import java.util.Collection;
import liquibase.change.AbstractChange;
import liquibase.change.ChangeMetaData;
import liquibase.change.DatabaseChange;
import liquibase.change.DatabaseChangeProperty;
import liquibase.database.Database;
import liquibase.database.core.DerbyDatabase;
import liquibase.database.core.H2Database;
import liquibase.database.core.MySQLDatabase;
import liquibase.database.core.PostgresDatabase;
import liquibase.ext.spatial.statement.DropSpatialIndexStatement;
import liquibase.ext.spatial.xml.XmlConstants;
import liquibase.statement.SqlStatement;
import liquibase.statement.core.DropIndexStatement;
import liquibase.util.StringUtils;

package liquibase.ext.spatial.change;



/**
 * @author Lonny Jacobson
 */
@DatabaseChange(name = "dropSpatialIndex", description = "Drops the spatial index on an existing column or set of columns.", priority = ChangeMetaData.PRIORITY_DEFAULT, appliesTo = "index")
public class DropSpatialIndexChange extends AbstractChange {
   /** The name of the catalog. */
   private String catalogName;

   /** The name of the schema. */
   private String schemaName;

   /** The name of the indexed table. */
   private String tableName;

   /** The name of the index to drop. */
   private String indexName;

   @DatabaseChangeProperty(mustEqualExisting = "index.schema")
   public String getSchemaName() {
      return this.schemaName;
   }

   public void setSchemaName(final String schemaName) {
      this.schemaName = schemaName;
   }

   @DatabaseChangeProperty(mustEqualExisting = "index", description = "Name of the index to drop", requiredForDatabase = "mysql, oracle, postgresql")
   public String getIndexName() {
      return this.indexName;
   }

   public void setIndexName(final String indexName) {
      this.indexName = indexName;
   }

   @DatabaseChangeProperty(mustEqualExisting = "index.table", description = "Name fo the indexed table.", requiredForDatabase = "h2, derby")
   public String getTableName() {
      return this.tableName;
   }

   public void setTableName(final String tableName) {
      this.tableName = tableName;
   }

   @DatabaseChangeProperty(mustEqualExisting = "index.catalog")
   public String getCatalogName() {
      return this.catalogName;
   }

   public void setCatalogName(final String catalogName) {
      this.catalogName = catalogName;
   }

   @Override
   public String getSerializedObjectNamespace() {
      return XmlConstants.SPATIAL_CHANGELOG_NAMESPACE;
   }

   @Override
   public String getConfirmationMessage() {
      final StringBuilder message = new StringBuilder("Spatial index");
      if (StringUtils.trimToNull(getIndexName()) != null) {
         message.append(' ').append(getIndexName().trim());
      }
      message.append(" dropped");
      if (StringUtils.trimToNull(getTableName()) != null) {
         message.append(" from ").append(getTableName().trim());
      }
      return message.toString();
   }

   /**
    * Generates a {@link DropSpatialIndexStatement} followed by a {@link DropIndexStatement}, if
    * applicable. The first statement allows extra clean-up when dropping an index. The second
    * statement leverages the normal <code>DROP INDEX</code> logic.
    */
   @Override
   public SqlStatement[] generateStatements(final Database database) {
      final Collection<SqlStatement> statements = new ArrayList<SqlStatement>();
      // MySQL and PostgreSQL only need the normal DROP INDEX statement.
      if (!(database instanceof MySQLDatabase) && !(database instanceof PostgresDatabase)) {
         final DropSpatialIndexStatement dropSpatialIndex = new DropSpatialIndexStatement(