Index: FeatureType.java
===================================================================
--- FeatureType.java	(revision 44261)
+++ FeatureType.java	(revision 44262)
@@ -23,12 +23,17 @@
  */
 package org.gvsig.fmap.dal.feature;
 
+import java.util.Comparator;
 import java.util.Iterator;
 import java.util.List;
+import java.util.function.Predicate;
+import org.apache.commons.lang3.StringUtils;
 
 import org.cresques.cts.IProjection;
 
 import org.gvsig.fmap.geom.Geometry;
+import org.gvsig.tools.dataTypes.DataType;
+import org.gvsig.tools.dataTypes.DataTypes;
 import org.gvsig.tools.dynobject.DynClass;
 import org.gvsig.tools.dynobject.DynStruct_v2;
 import org.gvsig.tools.evaluator.Evaluator;
@@ -36,8 +41,8 @@
 
 /**
  * <p>
- * This interface provides all the information that describes the structure of
- * a type of feature, methods for managing it and also offers a variety of utility
+ * This interface provides all the information that describes the structure of a
+ * type of feature, methods for managing it and also offers a variety of utility
  * methods for simplicity's sake.
  * </p>
  *
@@ -45,24 +50,26 @@
  * The relevant information that compounds a FeatureType includes:
  * </p>
  *
- *  <ul>
- *  <li> {@link FeatureAttributeDescriptor}(s)
- *  <li> {@link FeatureRule}(s)
- *  <li> Its size
- *  <li> Its SRS(s)
- *  <li> Its identifier
- *  <li> Whether features of this type have an OID or not (identifier assigned by the store).
+ * <ul>
+ * <li> {@link FeatureAttributeDescriptor}(s)
+ * <li> {@link FeatureRule}(s)
+ * <li> Its size
+ * <li> Its SRS(s)
+ * <li> Its identifier
+ * <li> Whether features of this type have an OID or not (identifier assigned by
+ * the store).
  * </ul>
  *
  * <p>
  * Methods for management include:
  * </p>
  *
- *  <ul>
- *  <li>Obtaining its editable instance.
- *  <li>Obtaining an iterator over its attributes.
- *  <li>Knowing whether this FeatureType has any associated evaluator for calculated attributes.
- *  </ul>
+ * <ul>
+ * <li>Obtaining its editable instance.
+ * <li>Obtaining an iterator over its attributes.
+ * <li>Knowing whether this FeatureType has any associated evaluator for
+ * calculated attributes.
+ * </ul>
  *
  * <p>
  * Utility methods include:
@@ -76,248 +83,247 @@
  */
 public interface FeatureType extends DynClass, DynStruct_v2, UnmodifiableBasicList<FeatureAttributeDescriptor> {
 
-	/**
-	 * Returns a new copy of this FeatureType
-	 *
-	 * @return
-	 * 		a new copy of this FeatureType
-	 */
-	public FeatureType getCopy();
+    public static final Predicate<FeatureAttributeDescriptor> BASIC_TYPES_FILTER = new Predicate<FeatureAttributeDescriptor>() {
+        @Override
+        public boolean test(FeatureAttributeDescriptor attrdesc) {
+            DataType t = attrdesc.getDataType();
+            boolean r = !(t.isContainer() || t.isDynObject() || t.isObject());
+            return r;
+        }
+    };
 
-	/**
-	 * Returns a {@link FeatureRules} containing
-	 * all rules applicable to features of this type.
-	 *
-	 * @return
-	 * 		a {@link FeatureRules} containing all rules
-	 * 		applicable to features of this type.
-	 */
-	public FeatureRules getRules();
+    public static Predicate<FeatureAttributeDescriptor> ALL_FILTER = new Predicate<FeatureAttributeDescriptor>() {
+        @Override
+        public boolean test(FeatureAttributeDescriptor t) {
+            return true;
+        }
+    };
+    /**
+     * Returns a new copy of this FeatureType
+     *
+     * @return a new copy of this FeatureType
+     */
+    public FeatureType getCopy();
 
-	/**
-	 * Returns an editable instance of this FeatureType.
-	 * Any modifications on a FeatureType must be done
-	 * through its editable instance.
-	 *
-	 * @return
-	 * 		the editable instance of this FeatureType.
-	 *
-	 * @see EditableFeatureType
-	 */
-	public EditableFeatureType getEditable();
+    /**
+     * Returns a {@link FeatureRules} containing all rules applicable to
+     * features of this type.
+     *
+     * @return a {@link FeatureRules} containing all rules applicable to
+     * features of this type.
+     */
+    public FeatureRules getRules();
 
-	/**
-	 * Given the name of an attribute, this method returns
-	 * its position in this FeatureType.
-	 *
-	 * @param name
-	 * 			of the attribute
-	 * @return
-	 * 		position of the attribute
-	 */
-	public int getIndex(String name);
+    /**
+     * Returns an editable instance of this FeatureType. Any modifications on a
+     * FeatureType must be done through its editable instance.
+     *
+     * @return the editable instance of this FeatureType.
+     *
+     * @see EditableFeatureType
+     */
+    public EditableFeatureType getEditable();
 
-	/**
-	 * Returns an attribute descriptor given its name.
-	 *
-	 * @param name
-	 * 			of the attribute
-	 * @return
-	 * 		descriptor of the attribute, a {@link FeatureAttributeDescriptor}.
-	 */
-	public Object get(String name);
+    /**
+     * Given the name of an attribute, this method returns its position in this
+     * FeatureType.
+     *
+     * @param name of the attribute
+     * @return position of the attribute
+     */
+    public int getIndex(String name);
 
-	/**
-	 * Returns an attribute descriptor given its index
-	 *
-	 * @param index
-	 * 			of the attribute
-	 *
-	 * @return
-	 * 		descriptor of the attribute, a {@link FeatureAttributeDescriptor}
-	 */
-	public FeatureAttributeDescriptor get(int index);
+    /**
+     * Returns an attribute descriptor given its name.
+     *
+     * @param name of the attribute
+     * @return descriptor of the attribute, a
+     * {@link FeatureAttributeDescriptor}.
+     */
+    public Object get(String name);
 
-	/**
-	 * Returns a {@link FeatureAttributeDescriptor} given the attribute name,
-	 * or null if an attribute with the given name does not exist.
-	 *
-	 * @param name
-	 * 			of the attribute
-	 *
-	 * @return
-	 * 		a {@link FeatureAttributeDescriptor}
-	 */
-	public FeatureAttributeDescriptor getAttributeDescriptor(String name);
+    /**
+     * Returns an attribute descriptor given its index
+     *
+     * @param index of the attribute
+     *
+     * @return descriptor of the attribute, a {@link FeatureAttributeDescriptor}
+     */
+    public FeatureAttributeDescriptor get(int index);
 
-	/**
-	 * Returns a {@link FeatureAttributeDescriptor} given the attribute index.
-	 *
-	 * @param index
-	 * 			of the attribute
-	 *
-	 * @return
-	 * 		a {@link FeatureAttributeDescriptor}
-	 */
-	public FeatureAttributeDescriptor getAttributeDescriptor(int index);
+    /**
+     * Returns a {@link FeatureAttributeDescriptor} given the attribute name, or
+     * null if an attribute with the given name does not exist.
+     *
+     * @param name of the attribute
+     *
+     * @return a {@link FeatureAttributeDescriptor}
+     */
+    public FeatureAttributeDescriptor getAttributeDescriptor(String name);
 
-	/**
-	 * Returns an iterator over this FeatureType's attributes. Elements
-	 * returned by this iterator are of type {@link FeatureAttributeDescriptor}.
-	 *
-	 * @return
-	 * 		An iterator over this FeatureType's {@link FeatureAttributeDescriptor}s.
-	 */
-	public Iterator iterator();
+    /**
+     * Returns a {@link FeatureAttributeDescriptor} given the attribute index.
+     *
+     * @param index of the attribute
+     *
+     * @return a {@link FeatureAttributeDescriptor}
+     */
+    public FeatureAttributeDescriptor getAttributeDescriptor(int index);
 
-	/**
-	 * Returns this FeatureType size. The size of a FeatureType is determined
-	 * by its number of attributes.
-	 *
-	 * @return
-	 * 		this FeatureType size, defined as the number of attributes it is composed of.
-	 *
-	 */
-	public int size();
-        
-        public boolean isEmpty();
+    /**
+     * Returns an iterator over this FeatureType's attributes. Elements returned
+     * by this iterator are of type {@link FeatureAttributeDescriptor}.
+     *
+     * @return An iterator over this FeatureType's
+     * {@link FeatureAttributeDescriptor}s.
+     */
+    public Iterator iterator();
 
-	/**
-	 * Returns this FeatureType identifier. This identifier must always be equal
-	 * to a store.
-	 *
-	 * @return the identifier.
-	 */
-	public String getId();
+    /**
+     * Returns this FeatureType size. The size of a FeatureType is determined by
+     * its number of attributes.
+     *
+     * @return this FeatureType size, defined as the number of attributes it is
+     * composed of.
+     *
+     */
+    public int size();
 
-	/**
-	 * Returns the name of the attribute that will be used as default
-	 * geometry attribute for those processes that require a geometry (for
-	 * instance rendering).
-	 *
-	 * @return
-	 * 		name of the default geometry attribute.
-	 */
-	public String getDefaultGeometryAttributeName();
+    public boolean isEmpty();
 
-	/**
-	 * Returns the index of the attribute that will be used as default
-	 * geometry attribute.
-	 *
-	 * @return
-	 * 		index of the default geometry attribute.
-	 */
-	public int getDefaultGeometryAttributeIndex();
+    /**
+     * Returns this FeatureType identifier. This identifier must always be equal
+     * to a store.
+     *
+     * @return the identifier.
+     */
+    public String getId();
 
-	/**
-	 * Returns a list with the SRSs in which this FeatureType geometries are
-	 * expressed. Normally there may be one SRS for each attribute of type
-	 * {@link Geometry}.
-	 *
-	 * @return
-	 * 		a list with the SRS in which this FeatureType geometries are expressed.
-	 */
-	public List getSRSs();
+    /**
+     * Returns the name of the attribute that will be used as default geometry
+     * attribute for those processes that require a geometry (for instance
+     * rendering).
+     *
+     * @return name of the default geometry attribute.
+     */
+    public String getDefaultGeometryAttributeName();
 
-	/**
-	 * Returns the SRS in which the default geometry attribute is expressed.
-	 *
-	 * @return
-	 * 		the SRS in which the default geometry attribute is expressed,
-	 *      null if not has a default geometry attribute.
-	 */
-	public IProjection getDefaultSRS();
+    /**
+     * Returns the index of the attribute that will be used as default geometry
+     * attribute.
+     *
+     * @return index of the default geometry attribute.
+     */
+    public int getDefaultGeometryAttributeIndex();
 
-	/**
-	 * Indicates whether this FeatureType has any assigned {@link Evaluator}(s).
-	 * Evaluators are used to obtain the values for calculated
-	 * attributes.
-	 *
-	 * @return
-	 * 		true if this FeatureType has any assigned {@link Evaluator}(s).
-	 */
-	public boolean hasEvaluators(); // FIXME: Quitar del interface y dejar en DefaultFeatureType
+    /**
+     * Returns a list with the SRSs in which this FeatureType geometries are
+     * expressed. Normally there may be one SRS for each attribute of type
+     * {@link Geometry}.
+     *
+     * @return a list with the SRS in which this FeatureType geometries are
+     * expressed.
+     */
+    public List getSRSs();
 
-	/**
-	 * Indicates whether {@link Feature}(s) of this FeatureType have an OID defined.
-	 * An OID is the Feature unique identifier.
-	 *
-	 * Some stores provide their own OIDs which are always unique
-	 * (such as Postgre) while others don't support this concept and
-	 * then it is the library who creates runtime ad-hoc OIDs as
-	 * it see fits, but then integrity of this OIDs among different
-	 * work sessions cannot be guaranteed (this is the case for shape
-	 * files).
-	 *
-	 * @return
-	 * 		true if this FeatureType has an OID defined, false otherwise.
-	 *
-	 */
-	public boolean hasOID();
+    /**
+     * Returns the SRS in which the default geometry attribute is expressed.
+     *
+     * @return the SRS in which the default geometry attribute is expressed,
+     * null if not has a default geometry attribute.
+     */
+    public IProjection getDefaultSRS();
 
-	/**
-	 * Incicates if attibutes with automatic values are allowed in the source
-	 *
-	 * @return true if source supports this feature, false otherwise
-	 */
-	public boolean allowAutomaticValues();
+    /**
+     * Indicates whether this FeatureType has any assigned {@link Evaluator}(s).
+     * Evaluators are used to obtain the values for calculated attributes.
+     *
+     * @return true if this FeatureType has any assigned {@link Evaluator}(s).
+     */
+    public boolean hasEvaluators(); // FIXME: Quitar del interface y dejar en DefaultFeatureType
 
-	/**
-	 * Returns an Array of the FeatureAttributeDescriptor
-	 *
-	 * @return
-	 */
-	public FeatureAttributeDescriptor[] getAttributeDescriptors();
+    /**
+     * Indicates whether {@link Feature}(s) of this FeatureType have an OID
+     * defined. An OID is the Feature unique identifier.
+     *
+     * Some stores provide their own OIDs which are always unique (such as
+     * Postgre) while others don't support this concept and then it is the
+     * library who creates runtime ad-hoc OIDs as it see fits, but then
+     * integrity of this OIDs among different work sessions cannot be guaranteed
+     * (this is the case for shape files).
+     *
+     * @return true if this FeatureType has an OID defined, false otherwise.
+     *
+     */
+    public boolean hasOID();
 
-	/**
-	 * Returns an Array of the FeatureAttributeDescriptor that compounds the
-	 * primary key. If not have primary keys return a empty array.
-	 *
-	 * @return
-	 */
-	public FeatureAttributeDescriptor[] getPrimaryKey();
+    /**
+     * Incicates if attibutes with automatic values are allowed in the source
+     *
+     * @return true if source supports this feature, false otherwise
+     */
+    public boolean allowAutomaticValues();
 
-	/**
-	 * Returns the default geometry FeatureAttributeDescriptor. Return null if
-	 * it's not set
-	 *
-	 * @return
-	 */
-	public FeatureAttributeDescriptor getDefaultGeometryAttribute();
-	
-	/**
-     * Returns the default time FeatureAttributeDescriptor. Return null if
-     * it's not set.
+    /**
+     * Returns an Array of the FeatureAttributeDescriptor
      *
      * @return
-     *          the default time attribute
      */
-    public FeatureAttributeDescriptor getDefaultTimeAttribute();
+    public FeatureAttributeDescriptor[] getAttributeDescriptors();
 
     /**
-     * Returns the name of the attribute that will be used as default
-     * geometry attribute for those processes that require a geometry (for
-     * instance rendering).
+     * Returns an Array of the FeatureAttributeDescriptor that compounds the
+     * primary key. If not have primary keys return a empty array.
      *
      * @return
-     * 		name of the default geometry attribute.
      */
-    public String getDefaultTimeAttributeName();
+    public FeatureAttributeDescriptor[] getPrimaryKey();
 
     /**
-     * Returns the index of the attribute that will be used as default
-     * geometry attribute.
+     * Returns the default geometry FeatureAttributeDescriptor. Return null if
+     * it's not set
      *
      * @return
-     * 		index of the default geometry attribute.
      */
+    public FeatureAttributeDescriptor getDefaultGeometryAttribute();
+
+    /**
+     * Returns the default time FeatureAttributeDescriptor. Return null if it's
+     * not set.
+     *
+     * @return the default time attribute
+     */
+    public FeatureAttributeDescriptor getDefaultTimeAttribute();
+
+    /**
+     * Returns the name of the attribute that will be used as default geometry
+     * attribute for those processes that require a geometry (for instance
+     * rendering).
+     *
+     * @return name of the default geometry attribute.
+     */
+    public String getDefaultTimeAttributeName();
+
+    /**
+     * Returns the index of the attribute that will be used as default geometry
+     * attribute.
+     *
+     * @return index of the default geometry attribute.
+     */
     public int getDefaultTimeAttributeIndex();
 
     /**
      * Return the store associated to this type.
-     * 
+     *
      * @return the FeatureStore of the type.
      */
-    public FeatureStore getStore();        
+    public FeatureStore getStore();
 
+    public List<FeatureAttributeDescriptor> getFilteredAttributes(
+            Predicate<FeatureAttributeDescriptor> filter,
+            int max
+    );
+
+    public List<FeatureAttributeDescriptor> getRecentUseds();
+
 }
