Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

Commit [r2094] Maximize Restore History

sfatehi 2011-04-20

1 2 3 > >> (Page 1 of 3)
changed /builder.1/schemacrawler-api/src/main/java/schemacrawler/schema/ColumnMap.java
changed /builder.1/schemacrawler-api/src/main/java/schemacrawler/crawl/AbstractRetriever.java
copied /builder.1/schemacrawler-api/src/main/java/schemacrawler/crawl/MutableIndex.java -> /builder.1/schemacrawler-api/src/main/java/schemacrawler/build/MutableResultsColumns.java
copied /builder.1/schemacrawler-api/src/main/java/schemacrawler/crawl/MutableForeignKeyColumnMap.java -> /builder.1/schemacrawler-api/src/main/java/schemacrawler/build/ForeignKeyColumnMapMetadata.java
copied /builder.1/schemacrawler-api/src/main/java/schemacrawler/crawl/MutableDatabaseInfo.java -> /builder.1/schemacrawler-api/src/main/java/schemacrawler/build/BaseDependantNamedObjectMetadata.java
copied /builder.1/schemacrawler-api/src/main/java/schemacrawler/crawl/MutableJdbcDriverProperty.java -> /builder.1/schemacrawler-api/src/main/java/schemacrawler/build/DatabaseInfoMetadata.java
copied /builder.1/schemacrawler-api/src/main/java/schemacrawler/crawl/MutablePrivilege.java -> /builder.1/schemacrawler-api/src/main/java/schemacrawler/build/MutablePrivilege.java
copied /builder.1/schemacrawler-api/src/main/java/schemacrawler/crawl/MutableForeignKey.java -> /builder.1/schemacrawler-api/src/main/java/schemacrawler/build/NamedObjectList.java
copied /builder.1/schemacrawler-api/src/main/java/schemacrawler/crawl/MutableDatabaseProperty.java -> /builder.1/schemacrawler-api/src/main/java/schemacrawler/build/MutableTrigger.java
copied /builder.1/schemacrawler-api/src/main/java/schemacrawler/crawl/MutableView.java -> /builder.1/schemacrawler-api/src/main/java/schemacrawler/build/NamedObjectSort.java
copied /builder.1/schemacrawler-api/src/main/java/schemacrawler/crawl/MutableCheckConstraint.java -> /builder.1/schemacrawler-api/src/main/java/schemacrawler/build/ColumnMetadata.java
copied /builder.1/schemacrawler-api/src/main/java/schemacrawler/crawl/MutableIndexColumn.java -> /builder.1/schemacrawler-api/src/main/java/schemacrawler/build/BaseColumnMetadata.java
copied /builder.1/schemacrawler-api/src/main/java/schemacrawler/crawl/MutableColumn.java -> /builder.1/schemacrawler-api/src/main/java/schemacrawler/build/JavaSqlTypesUtility.java
/builder.1/schemacrawler-api/src/main/java/schemacrawler/schema/ColumnMap.java Diff Switch to side-by-side view
Loading...
/builder.1/schemacrawler-api/src/main/java/schemacrawler/crawl/AbstractRetriever.java Diff Switch to side-by-side view
Loading...
/builder.1/schemacrawler-api/src/main/java/schemacrawler/crawl/MutableIndex.java to /builder.1/schemacrawler-api/src/main/java/schemacrawler/build/MutableResultsColumns.java
--- a/builder.1/schemacrawler-api/src/main/java/schemacrawler/crawl/MutableIndex.java
+++ b/builder.1/schemacrawler-api/src/main/java/schemacrawler/build/MutableResultsColumns.java
@@ -2,7 +2,7 @@
  *
  * SchemaCrawler
  * http://sourceforge.net/projects/schemacrawler
- * Copyright (c) 2000-2011, Sualeh Fatehi.
+ * Copyright (c) 2000-2010, Sualeh Fatehi.
  *
  * This library is free software; you can redistribute it and/or modify it under the terms
  * of the GNU Lesser General Public License as published by the Free Software Foundation;
@@ -18,163 +18,142 @@
  *
  */
 
-package schemacrawler.crawl;
+package schemacrawler.build;
 
 
-import schemacrawler.schema.Column;
-import schemacrawler.schema.Index;
-import schemacrawler.schema.IndexColumn;
-import schemacrawler.schema.IndexType;
-import schemacrawler.schema.NamedObject;
-import schemacrawler.schema.Table;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import schemacrawler.schema.ResultsColumn;
+import schemacrawler.schema.ResultsColumns;
 
 /**
- * Represents an index on a database table.
+ * Represents a result set, a result of a query.
  * 
  * @author Sualeh Fatehi
  */
-class MutableIndex
-  extends AbstractDependantObject
-  implements Index
+class MutableResultsColumns
+  extends BaseNamedObjectMetadata
+  implements ResultsColumns
 {
 
-  private static final long serialVersionUID = 4051326747138079028L;
+  private static final long serialVersionUID = 5204766782914559188L;
 
-  private final NamedObjectList<MutableIndexColumn> columns = new NamedObjectList<MutableIndexColumn>();
-  private boolean isUnique;
-  private IndexType type;
-  private int cardinality;
-  private int pages;
+  private final ResultsColumn[] columns;
 
-  MutableIndex(final Table parent, final String name)
+  private MutableResultsColumns(final ResultsColumnsBuilder builder)
   {
-    super(parent, name);
-    // Default values
-    type = IndexType.unknown;
-  }
-
-  /**
-   * {@inheritDoc}
-   * <p>
-   * Note: Since indexes are not always explicitly named in databases,
-   * the sorting routine orders the indexes by the names of the columns
-   * in the index.
-   * </p>
-   */
-  @Override
-  public int compareTo(final NamedObject obj)
-  {
-    if (obj == null)
-    {
-      return -1;
-    }
-
-    final Index other = (Index) obj;
-    int comparison = 0;
-    final Column[] thisColumns = getColumns();
-    final Column[] otherColumns = other.getColumns();
-
-    if (comparison == 0)
-    {
-      comparison = thisColumns.length - otherColumns.length;
-    }
-    if (comparison == 0)
-    {
-      for (int i = 0; i < thisColumns.length; i++)
-      {
-        final Column thisColumn = thisColumns[i];
-        final Column otherColumn = otherColumns[i];
-        if (comparison == 0)
-        {
-          comparison = thisColumn.compareTo(otherColumn);
-        }
-        else
-        {
-          break;
-        }
-      }
-    }
-    if (comparison == 0)
-    {
-      comparison = super.compareTo(other);
-    }
-
-    return comparison;
+    super(builder);
+    columns = builder.getColumns();
   }
 
   /**
    * {@inheritDoc}
    * 
-   * @see Index#getCardinality()
+   * @see schemacrawler.schema.ResultsColumns#getColumn(java.lang.String)
    */
-  public final int getCardinality()
+  public ResultsColumn getColumn(final String name)
   {
-    return cardinality;
+    return columns.lookup(name);
   }
 
   /**
    * {@inheritDoc}
    * 
-   * @see Index#getColumns()
+   * @see schemacrawler.schema.ResultsColumns#getColumns()
    */
-  public IndexColumn[] getColumns()
+  public ResultsColumn[] getColumns()
   {
-    return columns.values().toArray(new IndexColumn[columns.size()]);
+    return columns;
   }
 
   /**
    * {@inheritDoc}
    * 
-   * @see Index#getPages()
+   * @see schemacrawler.schema.ResultsColumns#getColumnsListAsString()
    */
-  public final int getPages()
+  public String getColumnsListAsString()
   {
-    return pages;
+    String columnsList = "";
+    final ResultsColumn[] columnsArray = getColumns();
+    if (columnsArray != null && columnsArray.length > 0)
+    {
+      final StringBuilder buffer = new StringBuilder();
+      for (int i = 0; i < columnsArray.length; i++)
+      {
+        if (i > 0)
+        {
+          buffer.append(", ");
+        }
+        final ResultsColumn column = columnsArray[i];
+        buffer.append(column.getFullName());
+      }
+      columnsList = buffer.toString();
+    }
+    return columnsList;
   }
 
-  /**
-   * {@inheritDoc}
-   * 
-   * @see Index#getType()
-   */
-  public final IndexType getType()
+  public Iterator<ResultsColumn> iterator()
   {
-    return type;
+    return Arrays.asList(getColumns()).iterator();
   }
 
-  /**
-   * {@inheritDoc}
-   * 
-   * @see Index#isUnique()
-   */
-  public boolean isUnique()
+  public final class ResultsColumnsBuilder
+    extends BaseNamedObjectBuilder
   {
-    return isUnique;
-  }
 
-  void addColumn(final MutableIndexColumn column)
-  {
-    columns.add(column);
-  }
+    private static final long serialVersionUID = 5204766782914559188L;
 
-  final void setCardinality(final int cardinality)
-  {
-    this.cardinality = cardinality;
-  }
+    private final Set<MutableResultsColumn> columns = new HashSet<MutableResultsColumn>();
 
-  final void setPages(final int pages)
-  {
-    this.pages = pages;
-  }
+    ResultsColumnsBuilder(final String name)
+    {
+      super(name);
+    }
 
-  final void setType(final IndexType type)
-  {
-    this.type = type;
-  }
+    /**
+     * {@inheritDoc}
+     * 
+     * @see schemacrawler.schema.ResultsColumns#getColumns()
+     */
+    public ResultsColumn[] getColumns()
+    {
+      return columns.toArray(new ResultsColumn[columns.size()]);
+    }
 
-  final void setUnique(final boolean unique)
-  {
-    isUnique = unique;
+    /**
+     * {@inheritDoc}
+     * 
+     * @see schemacrawler.schema.ResultsColumns#getColumnsListAsString()
+     */
+    public String getColumnsListAsString()
+    {
+      String columnsList = "";
+      final ResultsColumn[] columnsArray = getColumns();
+      if (columnsArray != null && columnsArray.length > 0)
+      {
+        final StringBuilder buffer = new StringBuilder();
+        for (int i = 0; i < columnsArray.length; i++)
+        {
+          if (i > 0)
+          {
+            buffer.append(", ");
+          }
+          final ResultsColumn column = columnsArray[i];
+          buffer.append(column.getFullName());
+        }
+        columnsList = buffer.toString();
+      }
+      return columnsList;
+    }
+
+    void addColumn(final MutableResultsColumn column)
+    {
+      columns.add(column);
+    }
+
   }
 
 }
/builder.1/schemacrawler-api/src/main/java/schemacrawler/crawl/MutableForeignKeyColumnMap.java to /builder.1/schemacrawler-api/src/main/java/schemacrawler/build/ForeignKeyColumnMapMetadata.java
--- a/builder.1/schemacrawler-api/src/main/java/schemacrawler/crawl/MutableForeignKeyColumnMap.java
+++ b/builder.1/schemacrawler-api/src/main/java/schemacrawler/build/ForeignKeyColumnMapMetadata.java
@@ -2,7 +2,7 @@
  *
  * SchemaCrawler
  * http://sourceforge.net/projects/schemacrawler
- * Copyright (c) 2000-2011, Sualeh Fatehi.
+ * Copyright (c) 2000-2010, Sualeh Fatehi.
  *
  * This library is free software; you can redistribute it and/or modify it under the terms
  * of the GNU Lesser General Public License as published by the Free Software Foundation;
@@ -18,12 +18,12 @@
  *
  */
 
-package schemacrawler.crawl;
+package schemacrawler.build;
 
 
 import schemacrawler.schema.Column;
+import schemacrawler.schema.ColumnMap;
 import schemacrawler.schema.ForeignKeyColumnMap;
-import schemacrawler.schema.NamedObject;
 
 /**
  * Represents a single column mapping from a primary key column to a
@@ -31,27 +31,53 @@
  * 
  * @author Sualeh Fatehi
  */
-final class MutableForeignKeyColumnMap
-  extends AbstractDependantNamedObject
+final class ForeignKeyColumnMapMetadata
+  extends BaseColumnMap
   implements ForeignKeyColumnMap
 {
 
+  public final static class ForeignKeyColumnMapBuilder
+    extends BaseColumnMapBuilder
+  {
+
+    private int keySequence;
+
+    ForeignKeyColumnMap build()
+    {
+      return new ForeignKeyColumnMapMetadata(this);
+    }
+
+    public int getKeySequence()
+    {
+      return keySequence;
+    }
+
+    public void setKeySequence(final int keySequence)
+    {
+      this.keySequence = keySequence;
+    }
+
+  }
+
   private static final long serialVersionUID = 3689073962672273464L;
+  private final Column foreignKeyColumn;
+  private final Column primaryKeyColumn;
 
-  private Column foreignKeyColumn;
-  private Column primaryKeyColumn;
-  private int keySequence;
+  private final int keySequence;
 
-  MutableForeignKeyColumnMap(final NamedObject parent, final String name)
+  private ForeignKeyColumnMapMetadata(final ForeignKeyColumnMapBuilder builder)
   {
-    super(parent, name);
+    super(builder);
+    primaryKeyColumn = builder.getPrimaryKeyColumn();
+    foreignKeyColumn = builder.getForeignKeyColumn();
+    keySequence = builder.keySequence;
   }
 
   /**
    * {@inheritDoc}
    */
   @Override
-  public int compareTo(final NamedObject obj)
+  public int compareTo(final ColumnMap obj)
   {
     if (obj == null)
     {
@@ -111,19 +137,4 @@
     return primaryKeyColumn;
   }
 
-  void setForeignKeyColumn(final Column foreignKeyColumn)
-  {
-    this.foreignKeyColumn = foreignKeyColumn;
-  }
-
-  void setKeySequence(final int keySequence)
-  {
-    this.keySequence = keySequence;
-  }
-
-  void setPrimaryKeyColumn(final Column primaryKeyColumn)
-  {
-    this.primaryKeyColumn = primaryKeyColumn;
-  }
-
 }
/builder.1/schemacrawler-api/src/main/java/schemacrawler/crawl/MutableDatabaseInfo.java to /builder.1/schemacrawler-api/src/main/java/schemacrawler/build/BaseDependantNamedObjectMetadata.java
--- a/builder.1/schemacrawler-api/src/main/java/schemacrawler/crawl/MutableDatabaseInfo.java
+++ b/builder.1/schemacrawler-api/src/main/java/schemacrawler/build/BaseDependantNamedObjectMetadata.java
@@ -2,7 +2,7 @@
  *
  * SchemaCrawler
  * http://sourceforge.net/projects/schemacrawler
- * Copyright (c) 2000-2011, Sualeh Fatehi.
+ * Copyright (c) 2000-2010, Sualeh Fatehi.
  *
  * This library is free software; you can redistribute it and/or modify it under the terms
  * of the GNU Lesser General Public License as published by the Free Software Foundation;
@@ -18,106 +18,115 @@
  *
  */
 
-package schemacrawler.crawl;
+package schemacrawler.build;
 
 
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Set;
-
-import schemacrawler.schema.DatabaseInfo;
-import schemacrawler.schema.DatabaseProperty;
+import schemacrawler.schema.DependantNamedObject;
+import schemacrawler.schema.NamedObject;
 
 /**
- * Database and connection information. Created from metadata returned
- * by a JDBC call, and other sources of information.
+ * Represents the dependent of a named object.
  * 
- * @author Sualeh Fatehi sualeh@hotmail.com
+ * @author Sualeh Fatehi
  */
-final class MutableDatabaseInfo
-  implements DatabaseInfo
+abstract class BaseDependantNamedObjectMetadata
+  extends BaseNamedObjectMetadata
+  implements DependantNamedObject
 {
 
-  private static final long serialVersionUID = 4051323422934251828L;
+  static abstract class BaseDependantNamedObjectBuilder
+    extends BaseNamedObjectBuilder
+  {
 
-  private static final String NEWLINE = System.getProperty("line.separator");
+    private final NamedObject parent;
 
-  private String userName;
-  private String productName;
-  private String productVersion;
-  private final Set<DatabaseProperty> databaseProperties = new HashSet<DatabaseProperty>();
+    BaseDependantNamedObjectBuilder(final NamedObject parent, final String name)
+    {
+      super(name);
+      this.parent = parent;
+    }
 
-  /**
-   * {@inheritDoc}
-   */
-  public String getProductName()
-  {
-    return productName;
   }
 
-  /**
-   * {@inheritDoc}
-   */
-  public String getProductVersion()
+  private static final long serialVersionUID = -4327208866052082457L;
+
+  private final NamedObject parent;
+
+  private transient int hashCode;
+
+  protected BaseDependantNamedObjectMetadata(final BaseDependantNamedObjectBuilder builder)
   {
-    return productVersion;
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public DatabaseProperty[] getProperties()
-  {
-    final DatabaseProperty[] properties = databaseProperties
-      .toArray(new DatabaseProperty[databaseProperties.size()]);
-    Arrays.sort(properties);
-    return properties;
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public String getUserName()
-  {
-    return userName;
+    super(builder);
+    parent = builder.parent;
   }
 
   /**
    * {@inheritDoc}
    * 
-   * @see Object#toString()
+   * @see java.lang.Object#equals(java.lang.Object)
    */
   @Override
-  public String toString()
+  public boolean equals(final Object obj)
   {
-    final StringBuilder info = new StringBuilder();
-    info.append("-- database: ").append(getProductName()).append(' ')
-      .append(getProductVersion()).append(NEWLINE);
-    return info.toString();
+    if (!super.equals(obj))
+    {
+      return false;
+    }
+    if (this == obj)
+    {
+      return true;
+    }
+    if (obj == null)
+    {
+      return false;
+    }
+    final BaseDependantNamedObjectMetadata other = (BaseDependantNamedObjectMetadata) obj;
+    if (parent == null)
+    {
+      if (other.parent != null)
+      {
+        return false;
+      }
+    }
+    else if (!parent.equals(other.parent))
+    {
+      return false;
+    }
+    return true;
   }
 
-  void addAll(final Collection<MutableDatabaseProperty> dbProperties)
+  /**
+   * {@inheritDoc}
+   * 
+   * @see schemacrawler.schema.DependantNamedObject#getParent()
+   */
+  public final NamedObject getParent()
   {
-    if (dbProperties != null)
+    return parent;
+  }
+
+  /**
+   * {@inheritDoc}
+   * 
+   * @see java.lang.Object#hashCode()
+   */
+  @Override
+  public int hashCode()
+  {
+    buildHashCode();
+    return hashCode;
+  }
+
+  private void buildHashCode()
+  {
+    if (hashCode == 0)
     {
-      databaseProperties.addAll(dbProperties);
+      final int prime = 31;
+      int result = super.hashCode();
+      result = prime * result + (parent == null? 0: parent.hashCode());
+      result = prime * result + super.hashCode();
+      hashCode = result;
     }
   }
 
-  void setProductName(final String productName)
-  {
-    this.productName = productName;
-  }
-
-  void setProductVersion(final String productVersion)
-  {
-    this.productVersion = productVersion;
-  }
-
-  void setUserName(final String userName)
-  {
-    this.userName = userName;
-  }
-
 }
/builder.1/schemacrawler-api/src/main/java/schemacrawler/crawl/MutableJdbcDriverProperty.java to /builder.1/schemacrawler-api/src/main/java/schemacrawler/build/DatabaseInfoMetadata.java
--- a/builder.1/schemacrawler-api/src/main/java/schemacrawler/crawl/MutableJdbcDriverProperty.java
+++ b/builder.1/schemacrawler-api/src/main/java/schemacrawler/build/DatabaseInfoMetadata.java
@@ -2,7 +2,7 @@
  *
  * SchemaCrawler
  * http://sourceforge.net/projects/schemacrawler
- * Copyright (c) 2000-2011, Sualeh Fatehi.
+ * Copyright (c) 2000-2010, Sualeh Fatehi.
  *
  * This library is free software; you can redistribute it and/or modify it under the terms
  * of the GNU Lesser General Public License as published by the Free Software Foundation;
@@ -18,102 +18,140 @@
  *
  */
 
-package schemacrawler.crawl;
+package schemacrawler.build;
 
 
-import java.sql.DriverPropertyInfo;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
 
-import schemacrawler.schema.JdbcDriverProperty;
+import schemacrawler.schema.DatabaseInfo;
+import schemacrawler.schema.DatabaseProperty;
 
 /**
- * Represents a JDBC driver property, and it's value. Created from
- * metadata returned by a JDBC call, and other sources of information.
+ * Database and connection information. Created from metadata returned
+ * by a JDBC call, and other sources of information.
  * 
  * @author Sualeh Fatehi sualeh@hotmail.com
  */
-final class MutableJdbcDriverProperty
-  extends MutableProperty
-  implements JdbcDriverProperty
+final class DatabaseInfoMetadata
+  implements DatabaseInfo
 {
 
-  private static final long serialVersionUID = 8030156654422512161L;
+  public static final class DatabaseInfoBuilder
+  {
 
-  private final String description;
-  private final boolean required;
-  private final String[] choices;
+    private String userName;
+    private String productName;
+    private String productVersion;
+    private final Set<DatabaseProperty> databaseProperties = new HashSet<DatabaseProperty>();
 
-  MutableJdbcDriverProperty(final DriverPropertyInfo driverPropertyInfo)
-  {
-    super(driverPropertyInfo.name, driverPropertyInfo.value);
-    description = driverPropertyInfo.description;
-    required = driverPropertyInfo.required;
-    choices = driverPropertyInfo.choices;
+    public void addDatabaseProperty(final DatabaseProperty dbProperty)
+    {
+      databaseProperties.add(dbProperty);
+    }
+
+    public String getProductName()
+    {
+      return productName;
+    }
+
+    public String getProductVersion()
+    {
+      return productVersion;
+    }
+
+    public DatabaseProperty[] getProperties()
+    {
+      final DatabaseProperty[] properties = databaseProperties
+        .toArray(new DatabaseProperty[databaseProperties.size()]);
+      Arrays.sort(properties);
+      return properties;
+    }
+
+    public String getUserName()
+    {
+      return userName;
+    }
+
+    public void setProductName(final String productName)
+    {
+      this.productName = productName;
+    }
+
+    public void setProductVersion(final String productVersion)
+    {
+      this.productVersion = productVersion;
+    }
+
+    public void setUserName(final String userName)
+    {
+      this.userName = userName;
+    }
+
   }
 
-  public int compareTo(final JdbcDriverProperty otherProperty)
+  private static final long serialVersionUID = 4051323422934251828L;
+
+  private static final String NEWLINE = System.getProperty("line.separator");
+
+  private final String userName;
+  private final String productName;
+  private final String productVersion;
+  private final DatabaseProperty[] databaseProperties;
+
+  private DatabaseInfoMetadata(final DatabaseInfoBuilder builder)
   {
-    if (otherProperty == null)
-    {
-      return -1;
-    }
-    else
-    {
-      return getName().toLowerCase().compareTo(otherProperty.getName()
-        .toLowerCase());
-    }
+    userName = builder.userName;
+    productName = builder.productName;
+    productVersion = builder.productVersion;
+    databaseProperties = builder.getProperties();
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  public String getProductName()
+  {
+    return productName;
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  public String getProductVersion()
+  {
+    return productVersion;
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  public DatabaseProperty[] getProperties()
+  {
+    return databaseProperties;
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  public String getUserName()
+  {
+    return userName;
   }
 
   /**
    * {@inheritDoc}
    * 
-   * @see schemacrawler.schema.JdbcDriverProperty#getChoices()
-   */
-  public String[] getChoices()
-  {
-    if (choices != null)
-    {
-      return choices;
-    }
-    else
-    {
-      return new String[0];
-    }
-  }
-
-  /**
-   * {@inheritDoc}
-   * 
-   * @see schemacrawler.schema.JdbcDriverProperty#getDescription()
-   */
-  public String getDescription()
-  {
-    if (description != null)
-    {
-      return description;
-    }
-    else
-    {
-      return "";
-    }
-  }
-
-  /**
-   * {@inheritDoc}
+   * @see Object#toString()
    */
   @Override
-  public String getValue()
+  public String toString()
   {
-    return (String) super.getValue();
-  }
-
-  /**
-   * {@inheritDoc}
-   * 
-   * @see schemacrawler.schema.JdbcDriverProperty#isRequired()
-   */
-  public boolean isRequired()
-  {
-    return required;
+    final StringBuilder info = new StringBuilder();
+    info.append("-- database: ").append(getProductName()).append(' ')
+      .append(getProductVersion()).append(NEWLINE);
+    return info.toString();
   }
 
 }
/builder.1/schemacrawler-api/src/main/java/schemacrawler/crawl/MutablePrivilege.java to /builder.1/schemacrawler-api/src/main/java/schemacrawler/build/MutablePrivilege.java
--- a/builder.1/schemacrawler-api/src/main/java/schemacrawler/crawl/MutablePrivilege.java
+++ b/builder.1/schemacrawler-api/src/main/java/schemacrawler/build/MutablePrivilege.java
@@ -2,7 +2,7 @@
  *
  * SchemaCrawler
  * http://sourceforge.net/projects/schemacrawler
- * Copyright (c) 2000-2011, Sualeh Fatehi.
+ * Copyright (c) 2000-2010, Sualeh Fatehi.
  *
  * This library is free software; you can redistribute it and/or modify it under the terms
  * of the GNU Lesser General Public License as published by the Free Software Foundation;
@@ -18,7 +18,7 @@
  *
  */
 
-package schemacrawler.crawl;
+package schemacrawler.build;
 
 
 import java.util.Arrays;
@@ -35,9 +35,39 @@
  * @author Sualeh Fatehi
  */
 final class MutablePrivilege
-  extends AbstractDependantObject
+  extends BaseDependantObjectMetadata
   implements Privilege
 {
+
+  public final class PrivilegeBuilder
+    extends BaseDependantObjectBuilder
+  {
+
+    private final Set<Grant> grants = new HashSet<Grant>();
+
+    PrivilegeBuilder(final DatabaseObject parent, final String name)
+    {
+      super(parent, name);
+    }
+
+    public void addGrant(final String grantor,
+                         final String grantee,
+                         final boolean isGrantable)
+    {
+      if (!Utility.isBlank(grantor) && !Utility.isBlank(grantee))
+      {
+        grants.add(new PrivilegeGrant(grantor, grantee, isGrantable));
+      }
+    }
+
+    public Grant[] getGrants()
+    {
+      final Grant[] grantsArray = grants.toArray(new Grant[grants.size()]);
+      Arrays.sort(grantsArray);
+      return grantsArray;
+    }
+
+  }
 
   private final class PrivilegeGrant
     implements Grant, Comparable<Grant>
@@ -164,30 +194,19 @@
 
   }
 
-  private final Set<Grant> grants = new HashSet<Grant>();
+  private final Grant[] grants;
 
   private static final long serialVersionUID = -1117664231494271886L;
 
-  MutablePrivilege(final DatabaseObject parent, final String name)
-  {
-    super(parent, name);
+  private MutablePrivilege(final PrivilegeBuilder builder)
+  {
+    super(builder);
+    grants = builder.getGrants();
   }
 
   public Grant[] getGrants()
   {
-    final Grant[] grantsArray = grants.toArray(new Grant[grants.size()]);
-    Arrays.sort(grantsArray);
-    return grantsArray;
-  }
-
-  void addGrant(final String grantor,
-                final String grantee,
-                final boolean isGrantable)
-  {
-    if (!Utility.isBlank(grantor) && !Utility.isBlank(grantee))
-    {
-      grants.add(new PrivilegeGrant(grantor, grantee, isGrantable));
-    }
+    return grants;
   }
 
 }
/builder.1/schemacrawler-api/src/main/java/schemacrawler/crawl/MutableForeignKey.java to /builder.1/schemacrawler-api/src/main/java/schemacrawler/build/NamedObjectList.java
--- a/builder.1/schemacrawler-api/src/main/java/schemacrawler/crawl/MutableForeignKey.java
+++ b/builder.1/schemacrawler-api/src/main/java/schemacrawler/build/NamedObjectList.java
@@ -2,7 +2,7 @@
  *
  * SchemaCrawler
  * http://sourceforge.net/projects/schemacrawler
- * Copyright (c) 2000-2011, Sualeh Fatehi.
+ * Copyright (c) 2000-2010, Sualeh Fatehi.
  *
  * This library is free software; you can redistribute it and/or modify it under the terms
  * of the GNU Lesser General Public License as published by the Free Software Foundation;
@@ -18,156 +18,178 @@
  *
  */
 
-package schemacrawler.crawl;
+package schemacrawler.build;
 
 
-import schemacrawler.schema.Column;
-import schemacrawler.schema.ForeignKey;
-import schemacrawler.schema.ForeignKeyColumnMap;
-import schemacrawler.schema.ForeignKeyDeferrability;
-import schemacrawler.schema.ForeignKeyUpdateRule;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
 import schemacrawler.schema.NamedObject;
+import sf.util.Utility;
 
 /**
- * Represents a foreign-key mapping to a primary key in another table.
+ * Ordered list of named objects, that can be searched associatively.
  * 
  * @author Sualeh Fatehi
  */
-class MutableForeignKey
-  extends AbstractNamedObject
-  implements ForeignKey
+class NamedObjectList<N extends NamedObject>
+  implements Serializable, Iterable<N>
 {
 
-  private static final long serialVersionUID = 4121411795974895671L;
+  private static final long serialVersionUID = 3257847666804142128L;
 
-  private final NamedObjectList<MutableForeignKeyColumnMap> columnPairs = new NamedObjectList<MutableForeignKeyColumnMap>();
-  private ForeignKeyUpdateRule updateRule;
-  private ForeignKeyUpdateRule deleteRule;
-  private ForeignKeyDeferrability deferrability;
+  private static String makeLookupKey(final NamedObject namedObject)
+  {
+    final String key;
+    if (namedObject == null)
+    {
+      key = null;
+    }
+    else
+    {
+      key = namedObject.getFullName();
+    }
+    return key;
+  }
 
-  MutableForeignKey(final String name)
+  private static String makeLookupKey(final NamedObject namedObject,
+                                      final String name)
   {
-    super(name);
+    final StringBuilder buffer = new StringBuilder(256);
 
-    // Default values
-    updateRule = ForeignKeyUpdateRule.unknown;
-    deleteRule = ForeignKeyUpdateRule.unknown;
-    deferrability = ForeignKeyDeferrability.unknown;
+    final String key;
+    final String namedObjectLookupKey = makeLookupKey(namedObject);
+
+    if (namedObjectLookupKey != null)
+    {
+      buffer.append(namedObjectLookupKey);
+    }
+    if (buffer.length() > 0)
+    {
+      buffer.append('.');
+    }
+    buffer.append(name);
+
+    key = buffer.toString();
+    return key;
   }
+
+  private static String makeLookupKey(final String fullName)
+  {
+    final String key;
+    if (Utility.isBlank(fullName))
+    {
+      key = null;
+    }
+    else
+    {
+      key = fullName;
+    }
+    return key;
+  }
+
+  private NamedObjectSort sort = NamedObjectSort.natural;
+  private final Map<String, N> objects = new HashMap<String, N>();
 
   /**
    * {@inheritDoc}
-   * <p>
-   * Note: Since foreign keys are not always explicitly named in
-   * databases, the sorting routine orders the foreign keys by the names
-   * of the columns in the foreign keys.
-   * </p>
+   * 
+   * @see java.lang.Iterable#iterator()
    */
-  @Override
-  public int compareTo(final NamedObject obj)
+  public Iterator<N> iterator()
   {
-    if (obj == null)
-    {
-      return -1;
-    }
-
-    final ForeignKey other = (ForeignKey) obj;
-    int comparison = 0;
-    final ForeignKeyColumnMap[] thisColumnPairs = getColumnPairs();
-    final ForeignKeyColumnMap[] otherColumnPairs = other.getColumnPairs();
-
-    if (comparison == 0)
-    {
-      comparison = thisColumnPairs.length - otherColumnPairs.length;
-    }
-
-    if (comparison == 0)
-    {
-      for (int i = 0; i < thisColumnPairs.length; i++)
-      {
-        final ForeignKeyColumnMap thisColumnPair = thisColumnPairs[i];
-        final ForeignKeyColumnMap otherColumnPair = otherColumnPairs[i];
-        if (comparison == 0)
-        {
-          comparison = thisColumnPair.compareTo(otherColumnPair);
-        }
-        else
-        {
-          break;
-        }
-      }
-    }
-
-    return comparison;
+    return values().iterator();
   }
 
   /**
    * {@inheritDoc}
    * 
-   * @see ForeignKey#getColumnPairs()
+   * @see java.lang.Object#toString()
    */
-  public ForeignKeyColumnMap[] getColumnPairs()
+  @Override
+  public String toString()
   {
-    return columnPairs.values()
-      .toArray(new ForeignKeyColumnMap[columnPairs.size()]);
+    return values().toString();
   }
 
   /**
-   * {@inheritDoc}
+   * Add a named object to the list.
    * 
-   * @see ForeignKey#getDeferrability()
+   * @param namedObject
+   *        Named object
    */
-  public final ForeignKeyDeferrability getDeferrability()
+  void add(final N namedObject)
   {
-    return deferrability;
+    if (namedObject == null)
+    {
+      throw new IllegalArgumentException("Cannot add a null object to the list");
+    }
+    final String key = makeLookupKey(namedObject);
+    objects.put(key, namedObject);
+  }
+
+  boolean isEmpty()
+  {
+    return objects.isEmpty();
+  }
+
+  N lookup(final NamedObject namedObject, final String name)
+  {
+    final String key = makeLookupKey(namedObject, name);
+    return objects.get(key);
   }
 
   /**
-   * {@inheritDoc}
+   * Looks up a named object by name.
    * 
-   * @see ForeignKey#getDeleteRule()
+   * @param fullName
+   *        Fully qualified name
+   * @return Named object
    */
-  public final ForeignKeyUpdateRule getDeleteRule()
+  N lookup(final String fullName)
   {
-    return deleteRule;
+    final String key = makeLookupKey(fullName);
+    return objects.get(key);
+  }
+
+  void remove(final NamedObject namedObject)
+  {
+    if (namedObject != null)
+    {
+      objects.remove(makeLookupKey(namedObject));
+    }
+  }
+
+  void setSortOrder(final NamedObjectSort sort)
+  {
+    this.sort = sort;
   }
 
   /**
-   * {@inheritDoc}
+   * Returns the number of elements in this list.
    * 
-   * @see ForeignKey#getUpdateRule()
+   * @return Number of elements in this list.
    */
-  public final ForeignKeyUpdateRule getUpdateRule()
+  int size()
   {
-    return updateRule;
+    return objects.size();
   }
 
-  void addColumnPair(final int keySequence,
-                     final Column pkColumn,
-                     final Column fkColumn)
+  /**
+   * Gets all named objects in the list, in sorted order.
+   * 
+   * @return All named objects
+   */
+  List<N> values()
   {
-    final String fkColumnMapName = getName() + "." + keySequence;
-    final MutableForeignKeyColumnMap fkColumnPair = new MutableForeignKeyColumnMap(this,
-                                                                                   fkColumnMapName);
-    fkColumnPair.setKeySequence(keySequence);
-    fkColumnPair.setPrimaryKeyColumn(pkColumn);
-    fkColumnPair.setForeignKeyColumn(fkColumn);
-    columnPairs.add(fkColumnPair);
-  }
-
-  final void setDeferrability(final ForeignKeyDeferrability deferrability)
-  {
-    this.deferrability = deferrability;
-  }
-
-  final void setDeleteRule(final ForeignKeyUpdateRule deleteRule)
-  {
-    this.deleteRule = deleteRule;
-  }
-
-  final void setUpdateRule(final ForeignKeyUpdateRule updateRule)
-  {
-    this.updateRule = updateRule;
+    final List<N> all = new ArrayList<N>(objects.values());
+    Collections.sort(all, sort);
+    return all;
   }
 
 }
/builder.1/schemacrawler-api/src/main/java/schemacrawler/crawl/MutableDatabaseProperty.java to /builder.1/schemacrawler-api/src/main/java/schemacrawler/build/MutableTrigger.java
--- a/builder.1/schemacrawler-api/src/main/java/schemacrawler/crawl/MutableDatabaseProperty.java
+++ b/builder.1/schemacrawler-api/src/main/java/schemacrawler/build/MutableTrigger.java
@@ -2,7 +2,7 @@
  *
  * SchemaCrawler
  * http://sourceforge.net/projects/schemacrawler
- * Copyright (c) 2000-2011, Sualeh Fatehi.
+ * Copyright (c) 2000-2010, Sualeh Fatehi.
  *
  * This library is free software; you can redistribute it and/or modify it under the terms
  * of the GNU Lesser General Public License as published by the Free Software Foundation;
@@ -17,119 +17,189 @@
  * Boston, MA 02111-1307, USA.
  *
  */
-package schemacrawler.crawl;
-
-
-import java.io.Serializable;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-
-import schemacrawler.schema.DatabaseProperty;
-
-class MutableDatabaseProperty
-  extends MutableProperty
-  implements DatabaseProperty
+
+package schemacrawler.build;
+
+
+import schemacrawler.schema.ActionOrientationType;
+import schemacrawler.schema.ConditionTimingType;
+import schemacrawler.schema.EventManipulationType;
+import schemacrawler.schema.Table;
+import schemacrawler.schema.Trigger;
+
+/**
+ * Represents a trigger.
+ * 
+ * @author Sualeh Fatehi
+ */
+class MutableTrigger
+  extends BaseDependantObjectMetadata
+  implements Trigger
 {
 
-  private static final long serialVersionUID = -7150431683440256142L;
-
-  private static final Set<Entry<String, String>> acronyms;
-
-  static
-  {
-    final Map<String, String> acronymsMap = new HashMap<String, String>();
-    acronymsMap.put("JDBC", "Jdbc");
-    acronymsMap.put("ANSI", "Ansi");
-    acronymsMap.put("SQL", "Sql");
-    acronymsMap.put("URL", "Url");
-    acronymsMap.put("TYPE_FORWARD_ONLY", "Type_forward_only");
-    acronymsMap.put("TYPE_SCROLL_INSENSITIVE", "Type_scroll_insensitive");
-    acronymsMap.put("TYPE_SCROLL_SENSITIVE", "Type_scroll_sensitive");
-    acronyms = Collections.unmodifiableSet(acronymsMap.entrySet());
-  }
-
-  private transient String description;
-
-  MutableDatabaseProperty(final String name, final Object value)
-  {
-    super(name, (Serializable) value);
-    buildDescription();
-  }
-
-  public int compareTo(final DatabaseProperty otherDbProperty)
-  {
-    if (otherDbProperty == null)
-    {
-      return -1;
-    }
-    else
-    {
-      return getDescription().toLowerCase().compareTo(otherDbProperty
-        .getDescription().toLowerCase());
-    }
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public String getDescription()
-  {
-    buildDescription();
-    return description;
-  }
-
-  @Override
-  public String toString()
-  {
-    return getDescription() + " = " + getValue();
-  }
-
-  private void buildDescription()
-  {
-    if (description == null)
-    {
-      final String get = "get";
-      description = getName();
-      if (description.startsWith(get))
+  public final class TriggerBuilder
+    extends BaseDependantObjectBuilder
+  {
+    private static final long serialVersionUID = -1619291073229701764L;
+
+    private EventManipulationType eventManipulationType;
+
+    private int actionOrder;
+    private final StringBuilder actionCondition;
+    private final StringBuilder actionStatement;
+    private ActionOrientationType actionOrientation;
+    private ConditionTimingType conditionTiming;
+
+    public TriggerBuilder(final Table parent, final String name)
+    {
+      super(parent, name);
+      // Default values
+      eventManipulationType = EventManipulationType.unknown;
+      actionOrientation = ActionOrientationType.unknown;
+      conditionTiming = ConditionTimingType.unknown;
+      actionCondition = new StringBuilder();
+      actionStatement = new StringBuilder();
+    }
+
+    public void appendActionCondition(final String actionCondition)
+    {
+      if (actionCondition != null)
       {
-        description = description.substring(get.length());
+        this.actionCondition.append(actionCondition);
       }
-
-      for (final Entry<String, String> acronym: acronyms)
+    }
+
+    public void appendActionStatement(final String actionStatement)
+    {
+      if (actionStatement != null)
       {
-        description = description.replaceAll(acronym.getKey(),
-                                             acronym.getValue());
+        this.actionStatement.append(actionStatement);
       }
-
-      final int strLen = description.length();
-      final StringBuilder buffer = new StringBuilder(strLen);
-      for (int i = 0; i < strLen; i++)
-      {
-        final char ch = description.charAt(i);
-        if (Character.isUpperCase(ch) || Character.isTitleCase(ch))
-        {
-          buffer.append(' ').append(Character.toLowerCase(ch));
-        }
-        else
-        {
-          buffer.append(ch);
-        }
-      }
-      description = buffer.toString();
-
-      for (final Entry<String, String> acronym: acronyms)
-      {
-        description = description.replaceAll(acronym.getValue().toLowerCase(),
-                                             acronym.getKey());
-        description = description.replaceAll(acronym.getValue(),
-                                             acronym.getKey());
-      }
-
-      description = description.trim();
-    }
+    }
+
+    public Trigger biuld()
+    {
+      return new MutableTrigger(this);
+    }
+
+    public String getActionCondition()
+    {
+      return actionCondition.toString();
+    }
+
+    public int getActionOrder()
+    {
+      return actionOrder;
+    }
+
+    public ActionOrientationType getActionOrientation()
+    {
+      return actionOrientation;
+    }
+
+    public String getActionStatement()
+    {
+      return actionStatement.toString();
+    }
+
+    public ConditionTimingType getConditionTiming()
+    {
+      return conditionTiming;
+    }
+
+    public EventManipulationType getEventManipulationType()
+    {
+      return eventManipulationType;
+    }
+
+    public void setActionOrder(final int actionOrder)
+    {
+      this.actionOrder = actionOrder;
+    }
+
+    public void setActionOrientation(final ActionOrientationType actionOrientation)
+    {
+      this.actionOrientation = actionOrientation;
+    }
+
+    public void setConditionTiming(final ConditionTimingType conditionTiming)
+    {
+      this.conditionTiming = conditionTiming;
+    }
+
+    public void setEventManipulationType(final EventManipulationType eventManipulationType)
+    {
+      this.eventManipulationType = eventManipulationType;
+    }
+
+  }
+
+  private static final long serialVersionUID = -1619291073229701764L;
+  private final EventManipulationType eventManipulationType;
+  private final int actionOrder;
+  private final String actionCondition;
+  private final String actionStatement;
+  private final ActionOrientationType actionOrientation;
+
+  private final ConditionTimingType conditionTiming;
+
+  private MutableTrigger(final TriggerBuilder builder)
+  {
+    super(builder);
+    eventManipulationType = builder.eventManipulationType;
+    actionOrder = builder.actionOrder;
+    actionOrientation = builder.actionOrientation;
+    conditionTiming = builder.conditionTiming;
+    actionCondition = builder.getActionCondition();
+    actionStatement = builder.getActionStatement();
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  public String getActionCondition()
+  {
+    return actionCondition.toString();
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  public int getActionOrder()
+  {
+    return actionOrder;
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  public ActionOrientationType getActionOrientation()
+  {
+    return actionOrientation;
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  public String getActionStatement()
+  {
+    return actionStatement.toString();
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  public ConditionTimingType getConditionTiming()
+  {
+    return conditionTiming;
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  public EventManipulationType getEventManipulationType()
+  {
+    return eventManipulationType;
   }
 
 }
/builder.1/schemacrawler-api/src/main/java/schemacrawler/crawl/MutableView.java to /builder.1/schemacrawler-api/src/main/java/schemacrawler/build/NamedObjectSort.java
--- a/builder.1/schemacrawler-api/src/main/java/schemacrawler/crawl/MutableView.java
+++ b/builder.1/schemacrawler-api/src/main/java/schemacrawler/build/NamedObjectSort.java
@@ -2,7 +2,7 @@
  *
  * SchemaCrawler
  * http://sourceforge.net/projects/schemacrawler
- * Copyright (c) 2000-2011, Sualeh Fatehi.
+ * Copyright (c) 2000-2010, Sualeh Fatehi.
  *
  * This library is free software; you can redistribute it and/or modify it under the terms
  * of the GNU Lesser General Public License as published by the Free Software Foundation;
@@ -18,98 +18,64 @@
  *
  */
 
-package schemacrawler.crawl;
+package schemacrawler.build;
 
 
-import schemacrawler.schema.CheckOptionType;
-import schemacrawler.schema.Schema;
-import schemacrawler.schema.TableType;
-import schemacrawler.schema.View;
+import java.util.Comparator;
 
-/**
- * Represents a view in the database.
- * 
- * @author Sualeh Fatehi
- */
-class MutableView
-  extends MutableTable
-  implements View
+import schemacrawler.schema.NamedObject;
+import sf.util.Utility;
+
+enum NamedObjectSort
+  implements Comparator<NamedObject>
 {
 
-  private static final long serialVersionUID = 3257290248802284852L;
-
-  private final StringBuilder definition;
-  private CheckOptionType checkOption;
-  private boolean updatable;
-
-  MutableView(final Schema schema, final String name)
+  /**
+   * Alphabetical sort.
+   */
+  alphabetical
   {
-    super(schema, name);
-    definition = new StringBuilder();
-  }
+    @Override
+    public int compare(final NamedObject namedObject1,
+                       final NamedObject namedObject2)
+    {
+      return Utility.convertForComparison(namedObject1.getFullName())
+        .compareTo(Utility.convertForComparison(namedObject2.getFullName()));
+    }
+  },
 
   /**
-   * {@inheritDoc}
+   * Natural sort.
    */
-  public CheckOptionType getCheckOption()
+  natural
   {
-    return checkOption;
+    @Override
+    public int compare(final NamedObject namedObject1,
+                       final NamedObject namedObject2)
+    {
+      return namedObject1.compareTo(namedObject2);
+    }
+  };
+
+  static NamedObjectSort getNamedObjectSort(final boolean alphabeticalSort)
+  {
+    if (alphabeticalSort)
+    {
+      return NamedObjectSort.alphabetical;
+    }
+    else
+    {
+      return NamedObjectSort.natural;
+    }
   }
 
   /**
    * {@inheritDoc}
    * 
-   * @see schemacrawler.schema.View#getDefinition()
+   * @see java.util.Comparator#compare(java.lang.Object,
+   *      java.lang.Object)
    */
-  public String getDefinition()
-  {
-    return definition.toString();
-  }
-
-  /**
-   * {@inheritDoc}
-   * 
-   * @see View#getType()
-   */
-  @Override
-  public TableType getType()
-  {
-    return TableType.view;
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public boolean isUpdatable()
-  {
-    return updatable;
-  }
-
-  void appendDefinition(final String definition)
-  {
-    if (definition != null)
-    {
-      this.definition.append(definition);
-    }
-  }
-
-  void setCheckOption(final CheckOptionType checkOption)
-  {
-    this.checkOption = checkOption;
-  }
-
-  @Override
-  void setType(final TableType type)
-  {
-    if (type != TableType.view)
-    {
-      throw new UnsupportedOperationException("Cannot reset view type");
-    }
-  }
-
-  void setUpdatable(final boolean updatable)
-  {
-    this.updatable = updatable;
-  }
+  public abstract int compare(final NamedObject namedObject1,
+                              final NamedObject namedObject2);
 
 }
/builder.1/schemacrawler-api/src/main/java/schemacrawler/crawl/MutableCheckConstraint.java to /builder.1/schemacrawler-api/src/main/java/schemacrawler/build/ColumnMetadata.java
--- a/builder.1/schemacrawler-api/src/main/java/schemacrawler/crawl/MutableCheckConstraint.java
+++ b/builder.1/schemacrawler-api/src/main/java/schemacrawler/build/ColumnMetadata.java
@@ -2,7 +2,7 @@
  *
  * SchemaCrawler
  * http://sourceforge.net/projects/schemacrawler
- * Copyright (c) 2000-2011, Sualeh Fatehi.
+ * Copyright (c) 2000-2010, Sualeh Fatehi.
  *
  * This library is free software; you can redistribute it and/or modify it under the terms
  * of the GNU Lesser General Public License as published by the Free Software Foundation;
@@ -18,74 +18,231 @@
  *
  */
 
-package schemacrawler.crawl;
-
-
-import schemacrawler.schema.CheckConstraint;
+package schemacrawler.build;
+
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import schemacrawler.schema.Column;
 import schemacrawler.schema.DatabaseObject;
+import schemacrawler.schema.Privilege;
 
 /**
- * Represents a table constraint.
+ * Represents a column in a database table or procedure. Created from
+ * metadata returned by a JDBC call.
+ * 
+ * @author Sualeh Fatehi
  */
-class MutableCheckConstraint
-  extends AbstractDependantObject
-  implements CheckConstraint
+final class ColumnMetadata
+  extends BaseColumnMetadata
+  implements Column
 {
 
-  private static final long serialVersionUID = 1155277343302693656L;
-
-  private boolean deferrable;
-  private boolean initiallyDeferred;
-  private String definition;
-
-  MutableCheckConstraint(final DatabaseObject parent, final String name)
-  {
-    super(parent, name);
-  }
-
-  /**
-   * {@inheritDoc}
-   * 
-   * @see schemacrawler.schema.CheckConstraint#getDefinition()
-   */
-  public String getDefinition()
-  {
-    return definition;
-  }
-
-  /**
-   * {@inheritDoc}
-   * 
-   * @see schemacrawler.schema.CheckConstraint#isDeferrable()
-   */
-  public boolean isDeferrable()
-  {
-    return deferrable;
-  }
-
-  /**
-   * {@inheritDoc}
-   * 
-   * @see schemacrawler.schema.CheckConstraint#isInitiallyDeferred()
-   */
-  public boolean isInitiallyDeferred()
-  {
-    return initiallyDeferred;
-  }
-
-  void setDeferrable(final boolean deferrable)
-  {
-    this.deferrable = deferrable;
-  }
-
-  void setDefinition(final String definition)
-  {
-    this.definition = definition;
-  }
-
-  void setInitiallyDeferred(final boolean initiallyDeferred)
-  {
-    this.initiallyDeferred = initiallyDeferred;
+  public static final class ColumnBuilder
+    extends BaseColumnBuilder
+  {
+
+    private String defaultValue;
+    private boolean isPartOfPrimaryKey;
+    private boolean isPartOfUniqueIndex;
+    private ColumnMetadata referencedColumn;
+    private final List<Privilege> privileges = new ArrayList<Privilege>();
+
+    public ColumnBuilder(final DatabaseObject parent, final String name)
+    {
+      super(parent, name);
+    }
+
+    public void addPrivilege(final Privilege privilege)
+    {
+      privileges.add(privilege);
+    }
+
+    public Column build()
+    {
+      return new ColumnMetadata(this);
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see schemacrawler.schema.Column#getDefaultValue()
+     */
+    public String getDefaultValue()
+    {
+      return defaultValue;
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see Column#getPrivileges()
+     */
+    public Privilege[] getPrivileges()
+    {
+      final Privilege[] privilegesArray = privileges
+        .toArray(new Privilege[privileges.size()]);
+      Arrays.sort(privilegesArray);
+      return privilegesArray;
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see schemacrawler.schema.Column#getReferencedColumn()
+     */
+    public Column getReferencedColumn()
+    {
+      return referencedColumn;
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see schemacrawler.schema.Column#isPartOfForeignKey()
+     */
+    public boolean isPartOfForeignKey()
+    {
+      return referencedColumn != null;
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see schemacrawler.schema.Column#isPartOfPrimaryKey()
+     */
+    public boolean isPartOfPrimaryKey()
+    {
+      return isPartOfPrimaryKey;
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see schemacrawler.schema.Column#isPartOfUniqueIndex()
+     */
+    public boolean isPartOfUniqueIndex()
+    {
+      return isPartOfUniqueIndex;
+    }
+
+    public void setDefaultValue(final String defaultValue)
+    {
+      this.defaultValue = defaultValue;
+    }
+
+    public void setPartOfPrimaryKey(final boolean partOfPrimaryKey)
+    {
+      isPartOfPrimaryKey = partOfPrimaryKey;
+    }
+
+    public void setPartOfUniqueIndex(final boolean partOfUniqueIndex)
+    {
+      isPartOfUniqueIndex = partOfUniqueIndex;
+    }
+
+    public void setReferencedColumn(final ColumnMetadata referencedColumn)
+    {
+      this.referencedColumn = referencedColumn;
+    }
+
+  }
+
+  private static final long serialVersionUID = 3834591019449528633L;
+  private final String defaultValue;
+  private final boolean isPartOfPrimaryKey;
+  private final boolean isPartOfUniqueIndex;
+  private final ColumnMetadata referencedColumn;
+
+  private final Privilege[] privileges;
+
+  private ColumnMetadata(final ColumnBuilder builder)
+  {
+    super(builder);
+    defaultValue = builder.defaultValue;
+    isPartOfPrimaryKey = builder.isPartOfPrimaryKey;
+    isPartOfUniqueIndex = builder.isPartOfUniqueIndex;
+    referencedColumn = builder.referencedColumn;
+    privileges = builder.getPrivileges();
+  }
+
+  /**
+   * {@inheritDoc}
+   * 
+   * @see schemacrawler.schema.Column#getDefaultValue()
+   */
+  public String getDefaultValue()
+  {
+    return defaultValue;
+  }
+
+  /**
+   * {@inheritDoc}
+   * 
+   * @see schemacrawler.schema.Column#getPrivilege(java.lang.String)
+   */
+  public Privilege getPrivilege(final String name)
+  {
+    for (final Privilege privilege: privileges)
+    {
+      if (privilege.getFullName().equals(name))
+      {
+        return privilege;
+      }
+    }
+    return null;
+  }
+
+  /**
+   * {@inheritDoc}
+   * 
+   * @see Column#getPrivileges()
+   */
+  public Privilege[] getPrivileges()
+  {
+    return privileges;
+  }
+
+  /**
+   * {@inheritDoc}
+   * 
+   * @see schemacrawler.schema.Column#getReferencedColumn()
+   */
+  public Column getReferencedColumn()
+  {
+    return referencedColumn;
+  }
+
+  /**
+   * {@inheritDoc}
+   * 
+   * @see schemacrawler.schema.Column#isPartOfForeignKey()
+   */
+  public boolean isPartOfForeignKey()
+  {
+    return referencedColumn != null;
+  }
+
+  /**
+   * {@inheritDoc}
+   * 
+   * @see schemacrawler.schema.Column#isPartOfPrimaryKey()
+   */
+  public boolean isPartOfPrimaryKey()
+  {
+    return isPartOfPrimaryKey;
+  }
+
+  /**
+   * {@inheritDoc}
+   * 
+   * @see schemacrawler.schema.Column#isPartOfUniqueIndex()
+   */
+  public boolean isPartOfUniqueIndex()
+  {
+    return isPartOfUniqueIndex;
   }
 
 }
/builder.1/schemacrawler-api/src/main/java/schemacrawler/crawl/MutableIndexColumn.java to /builder.1/schemacrawler-api/src/main/java/schemacrawler/build/BaseColumnMetadata.java
--- a/builder.1/schemacrawler-api/src/main/java/schemacrawler/crawl/MutableIndexColumn.java
+++ b/builder.1/schemacrawler-api/src/main/java/schemacrawler/build/BaseColumnMetadata.java
@@ -1,31 +1,162 @@
-package schemacrawler.crawl;
-
-
-import schemacrawler.schema.Column;
+/* 
+ *
+ * SchemaCrawler
+ * http://sourceforge.net/projects/schemacrawler
+ * Copyright (c) 2000-2010, Sualeh Fatehi.
+ *
+ * This library is free software; you can redistribute it and/or modify it under the terms
+ * of the GNU Lesser General Public License as published by the Free Software Foundation;
+ * either version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License along with this
+ * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ */
+
+package schemacrawler.build;
+
+
+import schemacrawler.crawl.JavaSqlType.JavaSqlTypeGroup;
+import schemacrawler.crawl.JavaSqlTypesUtility;
+import schemacrawler.schema.BaseColumn;
 import schemacrawler.schema.ColumnDataType;
-import schemacrawler.schema.Index;
-import schemacrawler.schema.IndexColumn;
-import schemacrawler.schema.IndexColumnSortSequence;
+import schemacrawler.schema.DatabaseObject;
 import schemacrawler.schema.NamedObject;
-import schemacrawler.schema.Privilege;
-
-final class MutableIndexColumn
-  extends AbstractDependantObject
-  implements IndexColumn
+
+/**
+ * Represents a column in a database for tables and procedures. Created
+ * from metadata returned by a JDBC call.
+ * 
+ * @author Sualeh Fatehi
+ */
+abstract class BaseColumnMetadata
+  extends BaseDependantObjectMetadata
+  implements BaseColumn
 {
 
-  private static final long serialVersionUID = -6923211341742623556L;
-
-  private final Column column;
-  private final Index index;
-  private int indexOrdinalPosition;
-  private IndexColumnSortSequence sortSequence;
-
-  MutableIndexColumn(final Index index, final MutableColumn column)
-  {
-    super(column.getParent(), column.getName());
-    this.index = index;
-    this.column = column;
+  static abstract class BaseColumnBuilder
+    extends BaseDependantObjectBuilder
+  {
+
+    private ColumnDataType type;
+    private int ordinalPosition;
+    private int size;
+    private int decimalDigits;
+    private boolean nullable;
+
+    BaseColumnBuilder(final DatabaseObject parent, final String name)
+    {
+      super(parent, name);
+    }
+
+    public final int getDecimalDigits()
+    {
+      return decimalDigits;
+    }
+
+    public final int getOrdinalPosition()
+    {
+      return ordinalPosition;
+    }
+
+    public final int getSize()
+    {
+      return size;
+    }
+
+    public final ColumnDataType getType()
+    {
+      return type;
+    }
+
+    public final String getWidth()
+    {
+
+      final ColumnDataType columnDataType = getType();
+      if (columnDataType == null)
+      {
+        return "";
+      }
+
+      if (size == 0 || size == Integer.MIN_VALUE || size == Integer.MAX_VALUE)
+      {
+        return "";
+      }
+
+      final JavaSqlTypeGroup sqlDataTypeGroup = JavaSqlTypesUtility
+        .lookupSqlDataType(columnDataType.getType()).getJavaSqlTypeGroup();
+      final boolean needWidth = sqlDataTypeGroup == JavaSqlTypeGroup.character
+                                || sqlDataTypeGroup == JavaSqlTypeGroup.real;
+
+      final StringBuilder columnWidthBuffer = new StringBuilder();
+      if (needWidth)
+      {
+        columnWidthBuffer.append('(');
+        columnWidthBuffer.append(size);
+        if (sqlDataTypeGroup == JavaSqlTypeGroup.real)
+        {
+          columnWidthBuffer.append(", ").append(getDecimalDigits());
+        }
+        columnWidthBuffer.append(')');
+      }
+
+      return columnWidthBuffer.toString();
+
+    }
+
+    public final boolean isNullable()
+    {
+      return nullable;
+    }
+
+    public final void setDecimalDigits(final int decimalDigits)
+    {
+      this.decimalDigits = decimalDigits;
+    }
+
+    public final void setNullable(final boolean nullable)
+    {
+      this.nullable = nullable;
+    }
+
+    public final void setOrdinalPosition(final int ordinalPosition)
+    {
+      this.ordinalPosition = ordinalPosition;
+    }
+
+    public final void setSize(final int size)
+    {
+      this.size = size;
+    }
+
+    public final void setType(final ColumnDataType type)
+    {
+      this.type = type;
+    }
+
+  }
+
+  private static final long serialVersionUID = -8492662324895309485L;
+  private final ColumnDataType type;
+  private final int ordinalPosition;
+  private final int size;
+  private final int decimalDigits;
+
+  private final boolean nullable;
+
+  protected BaseColumnMetadata(final BaseColumnBuilder builder)
+  {
+    super(builder);
+    type = builder.type;
+    ordinalPosition = builder.ordinalPosition;
+    size = builder.size;
+    decimalDigits = builder.decimalDigits;
+    nullable = builder.nullable;
   }
 
   /**
@@ -39,12 +170,12 @@
       return -1;
     }
 
-    final MutableIndexColumn other = (MutableIndexColumn) obj;
+    final BaseColumn other = (BaseColumn) obj;
     int comparison = 0;
 
     if (comparison == 0)
     {
-      comparison = indexOrdinalPosition - other.indexOrdinalPosition;
+      comparison = ordinalPosition - other.getOrdinalPosition();
     }
     if (comparison == 0)
     {
@@ -59,39 +190,9 @@
    * 
    * @see schemacrawler.schema.BaseColumn#getDecimalDigits()
    */
-  public int getDecimalDigits()
-  {
-    return column.getDecimalDigits();
-  }
-
-  /**
-   * {@inheritDoc}
-   * 
-   * @see schemacrawler.schema.Column#getDefaultValue()
-   */
-  public String getDefaultValue()
-  {
-    return column.getDefaultValue();
-  }
-
-  /**
-   * {@inheritDoc}
-   * 
-   * @see schemacrawler.schema.IndexColumn#getIndex()
-   */
-  public Index getIndex()
-  {
-    return index;
-  }
-
-  /**
-   * {@inheritDoc}
-   * 
-   * @see schemacrawler.schema.IndexColumn#getIndexOrdinalPosition()
-   */
-  public int getIndexOrdinalPosition()
-  {
-    return indexOrdinalPosition;
+  public final int getDecimalDigits()
+  {
+    return decimalDigits;
   }
 
   /**
@@ -99,39 +200,9 @@
    * 
    * @see schemacrawler.schema.BaseColumn#getOrdinalPosition()
    */
-  public int getOrdinalPosition()
-  {
-    return column.getOrdinalPosition();
-  }
-
-  /**
-   * {@inheritDoc}
-   * 
-   * @see schemacrawler.schema.Column#getPrivilege(java.lang.String)
-   */
-  public Privilege getPrivilege(final String name)
-  {
-    return column.getPrivilege(name);
-  }
-
-  /**
-   * {@inheritDoc}
-   * 
-   * @see schemacrawler.schema.Column#getPrivileges()
-   */
-  public Privilege[] getPrivileges()
-  {
-    return column.getPrivileges();
-  }
-
-  /**
-   * {@inheritDoc}
-   * 
-   * @see schemacrawler.schema.Column#getReferencedColumn()
-   */
-  public Column getReferencedColumn()
-  {
-    return column.getReferencedColumn();
+  public final int getOrdinalPosition()
+  {
+    return ordinalPosition;
   }
 
   /**
@@ -139,24 +210,19 @@
    * 
    * @see schemacrawler.schema.BaseColumn#getSize()
    */
-  public int getSize()
-  {
-    return column.getSize();
-  }
-
-  /**
-   * {@inheritDoc}
-   * 
-   * @see schemacrawler.schema.IndexColumn#getSortSequence()
-   */
-  public IndexColumnSortSequence getSortSequence()
-  {
-    return sortSequence;
-  }
-
-  public ColumnDataType getType()
-  {
-    return column.getType();
+  public final int getSize()
+  {
+    return size;
+  }
+
+  /**
+   * {@inheritDoc}
+   * 
+   * @see schemacrawler.schema.BaseColumn#getType()
+   */
+  public final ColumnDataType getType()
+  {
+    return type;
   }
 
   /**
@@ -164,9 +230,39 @@
    * 
    * @see schemacrawler.schema.BaseColumn#getWidth()
    */
-  public String getWidth()
-  {
-    return column.getWidth();
+  public final String getWidth()
+  {
+
+    final ColumnDataType columnDataType = getType();
+    if (columnDataType == null)
+    {
+      return "";
+    }
+
+    if (size == 0 || size == Integer.MIN_VALUE || size == Integer.MAX_VALUE)
+    {
+      return "";
+    }
+
+    final JavaSqlTypeGroup sqlDataTypeGroup = JavaSqlTypesUtility
+      .lookupSqlDataType(columnDataType.getType()).getJavaSqlTypeGroup();
+    final boolean needWidth = sqlDataTypeGroup == JavaSqlTypeGroup.character
+                              || sqlDataTypeGroup == JavaSqlTypeGroup.real;
+
+    final StringBuilder columnWidthBuffer = new StringBuilder();
+    if (needWidth)
+    {
+      columnWidthBuffer.append('(');
+      columnWidthBuffer.append(size);
+      if (sqlDataTypeGroup == JavaSqlTypeGroup.real)
+      {
+        columnWidthBuffer.append(", ").append(getDecimalDigits());
+      }
+      columnWidthBuffer.append(')');
+    }
+
+    return columnWidthBuffer.toString();
+
   }
 
   /**
@@ -174,49 +270,9 @@
    * 
    * @see schemacrawler.schema.BaseColumn#isNullable()
    */
-  public boolean isNullable()
-  {
-    return column.isNullable();
-  }
-
-  /**
-   * {@inheritDoc}
-   * 
-   * @see schemacrawler.schema.Column#isPartOfForeignKey()
-   */
-  public boolean isPartOfForeignKey()
-  {
-    return column.isPartOfForeignKey();
-  }
-
-  /**
-   * {@inheritDoc}
-   * 
-   * @see schemacrawler.schema.Column#isPartOfPrimaryKey()
-   */
-  public boolean isPartOfPrimaryKey()
-  {
-    return column.isPartOfPrimaryKey();
-  }
-
-  /**
-   * {@inheritDoc}
-   * 
-   * @see schemacrawler.schema.Column#isPartOfUniqueIndex()
-   */
-  public boolean isPartOfUniqueIndex()
-  {
-    return column.isPartOfUniqueIndex();
-  }
-
-  void setIndexOrdinalPosition(final int indexOrdinalPosition)
-  {
-    this.indexOrdinalPosition = indexOrdinalPosition;
-  }
-
-  void setSortSequence(final IndexColumnSortSequence sortSequence)
-  {
-    this.sortSequence = sortSequence;
+  public final boolean isNullable()
+  {
+    return nullable;
   }
 
 }
/builder.1/schemacrawler-api/src/main/java/schemacrawler/crawl/MutableColumn.java to /builder.1/schemacrawler-api/src/main/java/schemacrawler/build/JavaSqlTypesUtility.java
--- a/builder.1/schemacrawler-api/src/main/java/schemacrawler/crawl/MutableColumn.java
+++ b/builder.1/schemacrawler-api/src/main/java/schemacrawler/build/JavaSqlTypesUtility.java
@@ -2,7 +2,7 @@
  *
  * SchemaCrawler
  * http://sourceforge.net/projects/schemacrawler
- * Copyright (c) 2000-2011, Sualeh Fatehi.
+ * Copyright (c) 2000-2010, Sualeh Fatehi.
  *
  * This library is free software; you can redistribute it and/or modify it under the terms
  * of the GNU Lesser General Public License as published by the Free Software Foundation;
@@ -18,130 +18,184 @@
  *
  */
 
-package schemacrawler.crawl;
-
-
-import schemacrawler.schema.Column;
-import schemacrawler.schema.DatabaseObject;
-import schemacrawler.schema.Privilege;
+package schemacrawler.build;
+
+
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import schemacrawler.build.JavaSqlType.JavaSqlTypeGroup;
+import schemacrawler.schemacrawler.Config;
 
 /**
- * Represents a column in a database table or procedure. Created from
- * metadata returned by a JDBC call.
+ * Utility to work with java.sql.Types, and Java class name mappings.
  * 
  * @author Sualeh Fatehi
  */
-class MutableColumn
-  extends AbstractColumn
-  implements Column
+public final class JavaSqlTypesUtility
 {
 
-  private static final long serialVersionUID = 3834591019449528633L;
-
-  private String defaultValue;
-  private boolean isPartOfPrimaryKey;
-  private boolean isPartOfUniqueIndex;
-  private MutableColumn referencedColumn;
-  private final NamedObjectList<MutablePrivilege> privileges = new NamedObjectList<MutablePrivilege>();
-
-  MutableColumn(final DatabaseObject parent, final String name)
-  {
-    super(parent, name);
+  private static final Logger LOGGER = Logger
+    .getLogger(JavaSqlTypesUtility.class.getName());
+
+  private static final Map<Integer, JavaSqlType> JAVA_SQL_TYPES_BY_TYPE;
+  private static final Map<String, JavaSqlType> JAVA_SQL_TYPES_BY_TYPE_NAME;
+
+  static
+  {
+    final List<JavaSqlType> javaSqlTypes = readJavaSqlTypes();
+    JAVA_SQL_TYPES_BY_TYPE = mapJavaSqlTypesByType(javaSqlTypes);
+    JAVA_SQL_TYPES_BY_TYPE_NAME = mapJavaSqlTypesByTypeName(javaSqlTypes);
   }
 
   /**
-   * {@inheritDoc}
+   * Lookup java.sql.Types type, and return more detailed information,
+   * including the mapped Java class.
    * 
-   * @see schemacrawler.schema.Column#getDefaultValue()
+   * @param type
+   *        java.sql.Types type
+   * @return JavaSqlType type
    */
-  public String getDefaultValue()
-  {
-    return defaultValue;
+  public static JavaSqlType lookupSqlDataType(final int type)
+  {
+    JavaSqlType sqlDataType = JAVA_SQL_TYPES_BY_TYPE.get(type);
+    if (sqlDataType == null)
+    {
+      sqlDataType = JavaSqlType.UNKNOWN;
+    }
+    return sqlDataType;
   }
 
   /**
-   * {@inheritDoc}
+   * Lookup java.sql.Types type, and return more detailed information,
+   * including the mapped Java class.
    * 
-   * @see schemacrawler.schema.Column#getPrivilege(java.lang.String)
+   * @param typeName
+   *        java.sql.Types type name
+   * @return JavaSqlType type
    */
-  public MutablePrivilege getPrivilege(final String name)
-  {
-    return privileges.lookup(this, name);
-  }
-
-  /**
-   * {@inheritDoc}
-   * 
-   * @see Column#getPrivileges()
-   */
-  public Privilege[] getPrivileges()
-  {
-    return privileges.values().toArray(new Privilege[privileges.size()]);
-  }
-
-  /**
-   * {@inheritDoc}
-   * 
-   * @see schemacrawler.schema.Column#getReferencedColumn()
-   */
-  public Column getReferencedColumn()
-  {
-    return referencedColumn;
-  }
-
-  /**
-   * {@inheritDoc}
-   * 
-   * @see schemacrawler.schema.Column#isPartOfForeignKey()
-   */
-  public boolean isPartOfForeignKey()
-  {
-    return referencedColumn != null;
-  }
-
-  /**
-   * {@inheritDoc}
-   * 
-   * @see schemacrawler.schema.Column#isPartOfPrimaryKey()
-   */
-  public boolean isPartOfPrimaryKey()
-  {
-    return isPartOfPrimaryKey;
-  }
-
-  /**
-   * {@inheritDoc}
-   * 
-   * @see schemacrawler.schema.Column#isPartOfUniqueIndex()
-   */
-  public boolean isPartOfUniqueIndex()
-  {
-    return isPartOfUniqueIndex;
-  }
-
-  void addPrivilege(final MutablePrivilege privilege)
-  {
-    privileges.add(privilege);
-  }
-
-  void setDefaultValue(final String defaultValue)
-  {
-    this.defaultValue = defaultValue;
-  }
-
-  void setPartOfPrimaryKey(final boolean partOfPrimaryKey)
-  {
-    isPartOfPrimaryKey = partOfPrimaryKey;
-  }
-
-  void setPartOfUniqueIndex(final boolean partOfUniqueIndex)
-  {
-    isPartOfUniqueIndex = partOfUniqueIndex;
-  }
-
-  void setReferencedColumn(final MutableColumn referencedColumn)
-  {
-    this.referencedColumn = referencedColumn;
+  public static JavaSqlType lookupSqlDataType(final String typeName)
+  {
+    JavaSqlType sqlDataType = JAVA_SQL_TYPES_BY_TYPE_NAME.get(typeName);
+    if (sqlDataType == null)
+    {
+      sqlDataType = JavaSqlType.UNKNOWN;
+    }
+    return sqlDataType;
+  }
+
+  private static Map<Integer, JavaSqlType> mapJavaSqlTypesByType(final List<JavaSqlType> javaSqlTypes)
+  {
+    final Map<Integer, JavaSqlType> javaSqlTypesByTypeMap = new HashMap<Integer, JavaSqlType>();
+    if (javaSqlTypes != null)
+    {
+      for (final JavaSqlType javaSqlType: javaSqlTypes)
+      {
+        javaSqlTypesByTypeMap.put(javaSqlType.getJavaSqlType(), javaSqlType);
+      }
+    }
+    return Collections.unmodifiableMap(javaSqlTypesByTypeMap);
+  }
+
+  private static Map<String, JavaSqlType> mapJavaSqlTypesByTypeName(final List<JavaSqlType> javaSqlTypes)
+  {
+    final Map<String, JavaSqlType> javaSqlTypesByTypeNameMap = new HashMap<String, JavaSqlType>();
+    if (javaSqlTypes != null)
+    {
+      for (final JavaSqlType javaSqlType: javaSqlTypes)
+      {
+        javaSqlTypesByTypeNameMap.put(javaSqlType.getJavaSqlTypeName(),
+                                      javaSqlType);
+      }
+    }
+    return Collections.unmodifiableMap(javaSqlTypesByTypeNameMap);
+  }
+
+  private static List<JavaSqlType> readJavaSqlTypes()
+  {
+    final Map<String, JavaSqlTypeGroup> javaSqlTypeGroupsMap = readJavaSqlTypesGroupsMap();
+    final Map<String, String> javaSqlTypesClassNames = readJavaSqlTypesClassNameMap();
+    final Map<String, String> javaSqlTypesProperties = readPropertiesResource("/java.sql.Types.properties");
+
+    final List<JavaSqlType> javaSqlTypes = new ArrayList<JavaSqlType>();
+
+    for (final Entry<String, String> javaSqlTypesEntry: javaSqlTypesProperties
+      .entrySet())
+    {
+      if (javaSqlTypesEntry.getKey() != null
+          && javaSqlTypesEntry.getValue() != null)
+      {
+        final Integer javaSqlType = Integer.parseInt(javaSqlTypesEntry
+          .getValue());
+        final String javaSqlTypeName = javaSqlTypesEntry.getKey();
+        final String javaSqlTypesClassName = javaSqlTypesClassNames
+          .get(javaSqlTypeName);
+        final JavaSqlTypeGroup javaSqlTypeGroup = javaSqlTypeGroupsMap
+          .get(javaSqlTypeName);
+
+        javaSqlTypes.add(new JavaSqlType(javaSqlType,
+                                         javaSqlTypeName,
+                                         javaSqlTypesClassName,
+                                         javaSqlTypeGroup));
+      }
+    }
+
+    return Collections.unmodifiableList(javaSqlTypes);
+  }
+
+  private static Map<String, String> readJavaSqlTypesClassNameMap()
+  {
+    return readPropertiesResource("/java.sql.Types.mappings.properties");
+  }
+
+  private static Map<String, JavaSqlTypeGroup> readJavaSqlTypesGroupsMap()
+  {
+    final Map<String, JavaSqlTypeGroup> javaSqlTypesGroupsMap = new HashMap<String, JavaSqlTypeGroup>();
+    final Map<String, String> javaSqlTypesGroups = readPropertiesResource("/java.sql.Types.groups.properties");
+    for (final Entry<String, String> javaSqlTypesGroupsEntry: javaSqlTypesGroups
+      .entrySet())
+    {
+      try
+      {
+        final String javaSqlTypeName = javaSqlTypesGroupsEntry.getKey();
+        final JavaSqlTypeGroup group = JavaSqlTypeGroup
+          .valueOf(javaSqlTypesGroupsEntry.getValue());
+        javaSqlTypesGroupsMap.put(javaSqlTypeName, group);
+      }
+      catch (final IllegalArgumentException e)
+      {
+        LOGGER.log(Level.WARNING, "Could not read java.sql.Types groups", e);
+        // continue
+      }
+    }
+    return Collections.unmodifiableMap(javaSqlTypesGroupsMap);
+  }
+
+  private static Map<String, String> readPropertiesResource(final String resource)
+  {
+    final Map<String, String> properties;
+    final InputStream inputStream = JavaSqlTypesUtility.class
+      .getResourceAsStream(resource);
+    if (inputStream != null)
+    {
+      properties = Config.load(inputStream);
+    }
+    else
+    {
+      properties = new HashMap<String, String>();
+    }
+    return properties;
+  }
+
+  private JavaSqlTypesUtility()
+  {
   }
 
 }
1 2 3 > >> (Page 1 of 3)