Index: SQLBuilderBase.java
===================================================================
--- SQLBuilderBase.java	(revision 43738)
+++ SQLBuilderBase.java	(revision 43739)
@@ -31,6 +31,7 @@
 import org.gvsig.fmap.dal.SQLBuilder.UpdateBuilder;
 import org.gvsig.fmap.dal.SQLBuilder.UpdateColumnBuilder;
 import org.gvsig.fmap.dal.SQLBuilder.UpdateTableStatisticsBuilder;
+import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
 import org.gvsig.fmap.dal.feature.spi.ExpressionBuilderBase.AbstractValue;
 import org.gvsig.fmap.geom.Geometry;
 import org.slf4j.Logger;
@@ -52,204 +53,6 @@
     protected CreateIndexBuilder create_index;
     protected List<Parameter> parameters;
 
-    protected class ColumnDescriptorBuilderBase implements ColumnDescriptorBuilder {
-
-        private String name;
-        private int type;
-        private int type_p;
-        private int type_s;
-        private boolean isPk;
-        private boolean _allowNulls;
-        private boolean _isAutomatic;
-        private Object defaultValue;
-        private int geom_type;
-        private int geom_subtype;
-        private Object geom_srsdbcode;
-        private boolean _isIndexed;
-
-        public ColumnDescriptorBuilderBase(String name, int type, Object defaultValue) {
-            this.name = name;
-            this.type = type;
-            this.type_p = -1;
-            this.type_s = -1;
-            this.isPk = false;
-            this._allowNulls = true;
-            this._isAutomatic = false;
-            this.defaultValue = defaultValue;
-            this.geom_type = Geometry.TYPES.GEOMETRY;
-            this.geom_subtype = Geometry.SUBTYPES.GEOM2D;
-            this.geom_srsdbcode = null;
-            this._isIndexed = false;
-        }
-
-        public ColumnDescriptorBuilderBase(String name, int type, int type_p, int type_s, boolean isPk, boolean isIndexed, boolean allowNulls, boolean isAutomatic, Object defaultValue) {
-            this.name = name;
-            this.type = type;
-            this.type_p = type_p;
-            this.type_s = type_s;
-            this.isPk = isPk;
-            this._allowNulls = allowNulls;
-            this._isAutomatic = isAutomatic;
-            this.defaultValue = defaultValue;
-            this.geom_type = Geometry.TYPES.GEOMETRY;
-            this.geom_subtype = Geometry.SUBTYPES.GEOM2D;
-            this.geom_srsdbcode = null;
-            this._isIndexed = isIndexed;
-        }
-        
-        public ColumnDescriptorBuilderBase(String name, int geom_type, int geom_subtype, IProjection proj, boolean isIndexed, boolean allowNulls) {
-            this.name = name;
-            this.type = DataTypes.GEOMETRY;
-            this.type_p = 0;
-            this.type_s = 0;
-            this.isPk = false;
-            this._allowNulls = allowNulls;
-            this._isAutomatic = false;
-            this.defaultValue = null;
-            this.geom_type = geom_type;
-            this.geom_subtype = geom_subtype;
-            this.geom_srsdbcode = getSRSId(proj);
-            this._isIndexed = isIndexed;
-        }
-        
-        public ColumnDescriptorBuilderBase(String name, int geom_type, int geom_subtype, Object srsdbcode, boolean isIndexed, boolean allowNulls) {
-            this.name = name;
-            this.type = DataTypes.GEOMETRY;
-            this.type_p = 0;
-            this.type_s = 0;
-            this.isPk = false;
-            this._allowNulls = allowNulls;
-            this._isAutomatic = false;
-            this.defaultValue = null;
-            this.geom_type = geom_type;
-            this.geom_subtype = geom_subtype;
-            this.geom_srsdbcode = srsdbcode;
-            this._isIndexed = isIndexed;
-        }
-        
-        @Override
-        public String getName() {
-            return this.name;
-        }
-        
-        @Override
-        public void setName(String name) {
-            this.name = name;
-        }
-
-        @Override
-        public int getType() {
-            return this.type;
-        }
-
-        @Override
-        public void setType(int type) {
-            this.type = type;
-        }
-
-        @Override
-        public int getPrecision() {
-            return type_p;
-        }
-
-        @Override
-        public void setPrecision(int precision) {
-            this.type_p = precision;
-        }
-
-        @Override
-        public int getSize() {
-            return type_s;
-        }
-
-        @Override
-        public void setSize(int size) {
-            this.type_s = size;
-        }
-
-        @Override
-        public boolean isPrimaryKey() {
-            return isPk;
-        }
-
-        @Override
-        public void setIsPrimaryKey(boolean isPk) {
-            this.isPk = isPk;
-        }
-
-        @Override
-        public boolean allowNulls() {
-            return _allowNulls;
-        }
-
-        @Override
-        public void setAllowNulls(boolean allowNulls) {
-            this._allowNulls = allowNulls;
-        }
-
-        @Override
-        public boolean isAutomatic() {
-            return _isAutomatic;
-        }
-
-        @Override
-        public boolean isIndexed() {
-            return _isIndexed;
-        }
-
-        @Override
-        public void setIsAutomatic(boolean isAutomatic) {
-            this._isAutomatic = isAutomatic;
-        }
-
-        @Override
-        public Object getDefaultValue() {
-            return defaultValue;
-        }
-
-        @Override
-        public void setDefaultValue(Object defaultValue) {
-            this.defaultValue = defaultValue;
-        }
-
-        @Override
-        public int getGeometryType() {
-            return geom_type;
-        }
-
-        @Override
-        public void setGeometryType(int geom_type) {
-            this.geom_type = geom_type;
-        }
-
-        @Override
-        public int getGeometrySubtype() {
-            return geom_subtype;
-        }
-
-        @Override
-        public void setGeometrySubtype(int geom_subtype) {
-            this.geom_subtype = geom_subtype;
-        }
-
-        @Override
-        public Object getGeometrySRSId() {
-            return geom_srsdbcode;
-        }
-
-        @Override
-        public void setGeometrySRSId(Object geom_srsid) {
-            this.geom_srsdbcode = geom_srsid;
-        }        
-
-        @Override
-        public boolean isGeometry() {
-            return this.type == DataTypes.GEOMETRY;
-        }
-                
-    }
-    
-
     public class TableNameBuilderBase implements TableNameBuilder {
 
         public String tableName;
@@ -1309,8 +1112,8 @@
 
         protected TableNameBuilder table;
         protected List<String> drops;
-        protected List<ColumnDescriptorBuilderBase> adds;
-        protected List<ColumnDescriptorBuilderBase> alters;
+        protected List<ColumnDescriptor> adds;
+        protected List<ColumnDescriptor> alters;
         protected List<Pair<String,String>> renames;
 
         public AlterTableBuilderBase() {
@@ -1351,13 +1154,19 @@
             this.drops.add(columnName);
             return this;
         }
+        
+        @Override
+        public AlterTableBuilder add_column(FeatureAttributeDescriptor fad) {
+            this.adds.add(column(fad).getDescriptor());
+            return this;            
+        }
 
         @Override
         public AlterTableBuilder add_column(String columnName, int type, int type_p, int type_s, boolean isPk, boolean isIndexed, boolean allowNulls, boolean isAutomatic, Object defaultValue) {
             if (isPk || isAutomatic) {
                 allowNulls = false;
             }
-            this.adds.add(new ColumnDescriptorBuilderBase(columnName, type, type_p, type_s, isPk, isIndexed, allowNulls, isAutomatic, defaultValue));
+            this.adds.add(new ColumnDescriptorBase(columnName, type, type_p, type_s, isPk, isIndexed, allowNulls, isAutomatic, defaultValue));
             return this;
         }
 
@@ -1366,7 +1175,7 @@
             if( StringUtils.isEmpty(columnName) ) {
                 throw new IllegalArgumentException("Argument 'columnName' can't be empty.");
             }
-            this.adds.add(new ColumnDescriptorBuilderBase(columnName, type, subtype, proj, isIndexed, allowNulls));
+            this.adds.add(new ColumnDescriptorBase(columnName, type, subtype, proj, isIndexed, allowNulls));
             return this;
         }
 
@@ -1375,16 +1184,22 @@
             if( StringUtils.isEmpty(columnName) ) {
                 throw new IllegalArgumentException("Argument 'columnName' can't be empty.");
             }
-            this.adds.add(new ColumnDescriptorBuilderBase(columnName, type, subtype, srsdbcode, isIndexed, allowNulls));
+            this.adds.add(new ColumnDescriptorBase(columnName, type, subtype, srsdbcode, isIndexed, allowNulls));
             return this;
         }
-
+        
         @Override
+        public AlterTableBuilder alter_column(FeatureAttributeDescriptor fad) {
+            this.alters.add(column(fad).getDescriptor());
+            return this;            
+        }
+        
+        @Override
         public AlterTableBuilder alter_column(String columnName, int type, int type_p, int type_s, boolean isPk, boolean isIndexed, boolean allowNulls, boolean isAutomatic, Object defaultValue) {
             if (isPk || isAutomatic) {
                 allowNulls = false;
             }
-            this.alters.add(new ColumnDescriptorBuilderBase(columnName, type, type_p, type_s, isPk, isIndexed, allowNulls, isAutomatic, defaultValue));
+            this.alters.add(new ColumnDescriptorBase(columnName, type, type_p, type_s, isPk, isIndexed, allowNulls, isAutomatic, defaultValue));
             return this;
         }
 
@@ -1393,7 +1208,7 @@
             if( StringUtils.isEmpty(columnName) ) {
                 throw new IllegalArgumentException("Argument 'columnName' can't be empty.");
             }
-            this.alters.add(new ColumnDescriptorBuilderBase(columnName, type, subtype, proj, isIndexed, allowNulls));
+            this.alters.add(new ColumnDescriptorBase(columnName, type, subtype, proj, isIndexed, allowNulls));
             return this;
         }
 
@@ -1402,7 +1217,7 @@
             if( StringUtils.isEmpty(columnName) ) {
                 throw new IllegalArgumentException("Argument 'columnName' can't be empty.");
             }
-            this.alters.add(new ColumnDescriptorBuilderBase(columnName, type, subtype, srsdbcode, isIndexed, allowNulls));
+            this.alters.add(new ColumnDescriptorBase(columnName, type, subtype, srsdbcode, isIndexed, allowNulls));
             return this;
         }
 
@@ -1444,7 +1259,7 @@
                 builder.append(identifier(column)); 
                 sqls.add(builder.toString());
             }
-            for (ColumnDescriptorBuilderBase column : adds) {
+            for (ColumnDescriptor column : adds) {
                 StringBuilder builder = new StringBuilder();
                 builder.append("ALTER TABLE ");
                 builder.append(this.table.toString());
@@ -1483,7 +1298,7 @@
                 }
                 sqls.add(builder.toString());
             }
-            for (ColumnDescriptorBuilderBase column : alters) {
+            for (ColumnDescriptor column : alters) {
                 StringBuilder builder = new StringBuilder();
                 builder.append("ALTER TABLE ");
                 builder.append(this.table.toString());
@@ -1534,7 +1349,7 @@
     public class CreateTableBuilderBase implements CreateTableBuilder {
 
         protected TableNameBuilder table;
-        protected List<ColumnDescriptorBuilderBase> columns;
+        protected List<ColumnDescriptor> columns;
 
         public CreateTableBuilderBase() {
             this.columns = new ArrayList<>();
@@ -1559,6 +1374,12 @@
         }
 
         @Override
+        public CreateTableBuilderBase add_column(FeatureAttributeDescriptor fad) {
+            this.columns.add(column(fad).getDescriptor());
+            return this;            
+        }
+
+        @Override
         public CreateTableBuilderBase add_column(String columnName, int type, int type_p, int type_s, boolean isPk, boolean isIndexed, boolean allowNulls, boolean isAutomatic, Object defaultValue) {
             if( StringUtils.isEmpty(columnName) ) {
                 throw new IllegalArgumentException("Argument 'columnName' can't be empty.");
@@ -1566,7 +1387,7 @@
             if (isPk || isAutomatic) {
                 allowNulls = false;
             }
-            this.columns.add(new ColumnDescriptorBuilderBase(columnName, type, type_p, type_s, isPk, isIndexed, allowNulls, isAutomatic, defaultValue));
+            this.columns.add(new ColumnDescriptorBase(columnName, type, type_p, type_s, isPk, isIndexed, allowNulls, isAutomatic, defaultValue));
             return this;
         }
 
@@ -1575,7 +1396,7 @@
             if( StringUtils.isEmpty(columnName) ) {
                 throw new IllegalArgumentException("Argument 'columnName' can't be empty.");
             }
-            this.columns.add(new ColumnDescriptorBuilderBase(columnName, type, subtype, proj, isIndexed, allowNulls));
+            this.columns.add(new ColumnDescriptorBase(columnName, type, subtype, proj, isIndexed, allowNulls));
             return this;
         }
 
@@ -1584,16 +1405,16 @@
             if( StringUtils.isEmpty(columnName) ) {
                 throw new IllegalArgumentException("Argument 'columnName' can't be empty.");
             }
-            this.columns.add(new ColumnDescriptorBuilderBase(columnName, type, subtype, srsdbcode, isIndexed, allowNulls));
+            this.columns.add(new ColumnDescriptorBase(columnName, type, subtype, srsdbcode, isIndexed, allowNulls));
             return this;
         }
 
         @Override
-        public ColumnDescriptorBuilder getColumnDescriptor(String columnName) {
+        public ColumnDescriptor getColumnDescriptor(String columnName) {
             if( StringUtils.isEmpty(columnName) ) {
                 return null;
             }
-            for (ColumnDescriptorBuilderBase column : columns) {
+            for (ColumnDescriptor column : columns) {
                 if( columnName.equals(column.getName()) ) {
                     return column;
                 }
@@ -1653,7 +1474,7 @@
             builder.append(this.table.toString());
             builder.append(" (");
             boolean first = true;
-            for (ColumnDescriptorBuilderBase column : columns) {
+            for (ColumnDescriptor column : columns) {
                 if (first) {
                     first = false;
                 } else {
