/** The collection of products */
 public static List products() {
   List result = CollectionsPack.newList();
   for (int i = 0; i < products.length; i++) {
     if (products[i] != null) result.add(products[i]);
   }
   return result;
 }
/** DatabaseProductPack */
public class DatabaseProductPack {

  /**
   * This returns a Product identifier from the product description return from a JDBC
   * getDatabaseProductName()
   */
  public static DatabaseProduct productFromProductDescription(String productDescription) {
    int size = DatabaseProductConstants.DB_SIZE;
    for (int i = 0; i < size; i++) {
      DatabaseProduct product = products[i];
      if (product != null) {
        if (product.matchesDescription(productDescription)) {
          return product;
        }
      }
    }
    ;
    return null;
  }

  /**
   * This returns a Product identifier from the product description return from a JDBC
   * getDatabaseProductName()
   */
  public static int productCodeFromProductDescription(String productDescription) {
    DatabaseProduct product = productFromProductDescription(productDescription);
    if (product == null) return -1;
    return product.code();
  }

  // ** REQUIRE: productCode >= 0 && < DB.SIZE
  public static DatabaseProduct productFromCode(int productCode) {
    if (!(productCode >= 0)) {
      return null;
    }
    ;
    if (!(productCode < DatabaseProductConstants.DB_SIZE)) {
      return null;
    }
    ;

    return products[productCode];
  }

  public static DatabaseProduct productFromKey(String productKey) {
    return (DatabaseProduct) keyToProduct.atKey(productKey);
  }

  /** The collection of products */
  public static List products() {
    List result = CollectionsPack.newList();
    for (int i = 0; i < products.length; i++) {
      if (products[i] != null) result.add(products[i]);
    }
    return result;
  }

  // **************************************
  // **************************************
  // **************************************

  public static void main(String[] args) {
    System.out.println(products());
  }

  // **************************************
  // **************************************
  // **************************************

  protected static DatabaseProduct[] products = null;
  protected static Map keyToProduct = CollectionsPack.newMap();

  static {
    products = new DatabaseProduct[DatabaseProductConstants.DB_SIZE];

    registerProduct(new com.chimu.form.database.product.access.DatabaseProductC());
    registerProduct(new com.chimu.form.database.product.mssql.DatabaseProductC());
    registerProduct(new com.chimu.form.database.product.informix.DatabaseProductC());
    registerProduct(new com.chimu.form.database.product.sqla.DatabaseProductC());
    registerProduct(new com.chimu.form.database.product.oracle.DatabaseProductC());
    registerProduct(new com.chimu.form.database.product.harmonia.DatabaseProductC());
    registerProduct(new com.chimu.form.database.product.db2.DatabaseProductC());

    registerProduct(new com.chimu.form.database.product.sql92.DatabaseProductC());
  }

  static void registerProduct(DatabaseProduct product) {
    products[product.code()] = product;
    keyToProduct.atKey_put(product.key(), product);
  }

  private DatabaseProductPack() {};
};