[Schmitzm-commits] r1116 - trunk/src/schmitzm/geotools/feature

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu Oct 14 20:54:16 CEST 2010


Author: mojays
Date: 2010-10-14 20:54:15 +0200 (Thu, 14 Oct 2010)
New Revision: 1116

Added:
   trunk/src/schmitzm/geotools/feature/AttributeModificationRule.java
Removed:
   trunk/src/schmitzm/geotools/feature/AttributeModificationDefinition.java
Modified:
   trunk/src/schmitzm/geotools/feature/FeatureUtil.java
Log:
AttributeModificationDefinition renamed to AttributeModificationRule

Deleted: trunk/src/schmitzm/geotools/feature/AttributeModificationDefinition.java
===================================================================
--- trunk/src/schmitzm/geotools/feature/AttributeModificationDefinition.java	2010-10-14 18:48:51 UTC (rev 1115)
+++ trunk/src/schmitzm/geotools/feature/AttributeModificationDefinition.java	2010-10-14 18:54:15 UTC (rev 1116)
@@ -1,32 +0,0 @@
-package schmitzm.geotools.feature;
-
-import java.util.Set;
-
-public class AttributeModificationDefinition {
-  protected int attrIdx;
-  protected String newAttrName;
-  protected Class<?> newAttrClass;
-  protected Set<Object> nullValues;
-  
-  public String getNewAttrName() {
-    return newAttrName;
-  }
-  public void setNewAttrName(String newAttrName) {
-    this.newAttrName = newAttrName;
-  }
-  public Class<?> getNewAttrClass() {
-    return newAttrClass;
-  }
-  public void setNewAttrClass(Class<?> newAttrClass) {
-    this.newAttrClass = newAttrClass;
-  }
-  public Set<Object> getNullValues() {
-    return nullValues;
-  }
-  public void setNullValues(Set<Object> nullValues) {
-    this.nullValues = nullValues;
-  }
-  public int getAttrIdx() {
-    return attrIdx;
-  } 
-}

Added: trunk/src/schmitzm/geotools/feature/AttributeModificationRule.java
===================================================================
--- trunk/src/schmitzm/geotools/feature/AttributeModificationRule.java	2010-10-14 18:48:51 UTC (rev 1115)
+++ trunk/src/schmitzm/geotools/feature/AttributeModificationRule.java	2010-10-14 18:54:15 UTC (rev 1116)
@@ -0,0 +1,108 @@
+package schmitzm.geotools.feature;
+
+import java.util.Set;
+
+import org.geotools.data.FeatureSource;
+
+/**
+ * Defines an attribute modification during the 
+ * {@link FeatureUtil#modifyFeatureSource(org.geotools.data.FeatureSource, org.geotools.data.AbstractDataStore, AttributeModificationRule...)}
+ * process.
+ * @author <a href="mailto:martin.schmitz at koeln.de">Martin Schmitz</a>
+ */
+public class AttributeModificationRule {
+  /** Holds the attribute index in the source {@link FeatureSource}, which
+   *  should be transfered to the destination (and modified).*/
+  protected int attrIdx;
+  /** Holds the new attribute name for the attribute. */
+  protected String newAttrName;
+  /** Holds the new attribute type for the attribute. */
+  protected Class<?> newAttrClass;
+  /** Holds attribute values, which are transformed to NULL in the
+   *  modification process. */
+  protected Set<Object> nullValues;
+  
+  /**
+   * Creates a new modification definition
+   * @param attrIdx attribute index in the source {@link FeatureSource}, which
+   *                should be transfered to the destination     
+   * @param newAttrName new attribute name for the attribute in the destination
+   *                    (if {@code null} the origin attribute name is used)
+   * @param newAttrClass new attribute type for the attribute in the destination
+   *                    (if {@code null} the origin attribute type is used)
+   * @param nullValues values which are transformed to NULL during the modification
+   *                   process (if {@code null} the values are copied unchanged)
+   */
+  public AttributeModificationRule(int attrIdx, String newAttrName, Class<?> newAttrClass, Set<Object> nullValues) {
+    this.attrIdx = attrIdx;
+    this.newAttrName = newAttrName;
+    this.newAttrClass = newAttrClass;
+    this.nullValues = nullValues;
+  }
+  
+  /**
+   * Creates a new modification definition
+   * @param attrIdx attribute index in the source {@link FeatureSource}, which
+   *                should be transfered to the destination     
+   */
+  public AttributeModificationRule(int attrIdx) {
+    this(attrIdx,null,null,null);
+  }
+
+  /**
+   * Returns the index in the source {@link FeatureSource} this modification rule
+   * is made for.
+   */
+  public int getAttrIdx() {
+    return attrIdx;
+  } 
+
+  /**
+   * Returns the new name for the attribute in the destination {@link FeatureSource}.
+   * @return {@code null} if the origin attribute name is used
+   */
+  public String getNewAttrName() {
+    return newAttrName;
+  }
+
+  /**
+   * Sets the new name for the attribute in the destination {@link FeatureSource}.
+   * If set to {@code null}, the origin attribute name is used.
+   */
+  public void setNewAttrName(String newAttrName) {
+    this.newAttrName = newAttrName;
+  }
+
+  /**
+   * Returns the new type for the attribute in the destination {@link FeatureSource}.
+   * @return {@code null} if the origin attribute type is used
+   */
+  public Class<?> getNewAttrClass() {
+    return newAttrClass;
+  }
+  
+  /**
+   * Sets the new type for the attribute in the destination {@link FeatureSource}.
+   * If set to {@code null}, the origin attribute type is used.
+   */
+  public void setNewAttrClass(Class<?> newAttrClass) {
+    this.newAttrClass = newAttrClass;
+  }
+  
+  /**
+   * Returns the attribute values which are transformed to NULL during the
+   * modification process.
+   * @return {@code null} if the origin attribute values are copied unchanged
+   */
+  public Set<Object> getNullValues() {
+    return nullValues;
+  }
+  /**
+   * Sets the attribute values which are transformed to NULL during the
+   * modification process.
+   * If set to {@code null}, the origin attribute values are copied unchanged
+   */
+  public void setNullValues(Set<Object> nullValues) {
+    this.nullValues = nullValues;
+  }
+}

Modified: trunk/src/schmitzm/geotools/feature/FeatureUtil.java
===================================================================
--- trunk/src/schmitzm/geotools/feature/FeatureUtil.java	2010-10-14 18:48:51 UTC (rev 1115)
+++ trunk/src/schmitzm/geotools/feature/FeatureUtil.java	2010-10-14 18:54:15 UTC (rev 1116)
@@ -2451,15 +2451,21 @@
 
 	/**
 	 * "Modifies" a {@link FeatureSource} according to the given
-	 * {@link AttributeModificationDefinition AttributeModificationDefinitions}
-	 * and stores the resulting {@link FeatureSource} in a data store. 
+	 * {@link AttributeModificationRule AttributeModificationDefinitions}
+	 * and stores the resulting {@link FeatureSource} in a data store.<br>
+	 * <b>Note</b>:
+	 * Only the attibutes for which a {@link AttributeModificationRule} is
+	 * specified, are copied to the destination {@link FeatureSource}. So even
+	 * if an attribute should be transfered unchanged, there must be an
+	 * {@link AttributeModificationRule} for it!!
+	 * 
 	 * @param fs source {@link FeatureSource}
 	 * @param destDataStore destination for the new {@link FeatureSource}
 	 * @param destAttr defines which attributes of the source {@link FeatureSource}
 	 *                 are copied in the destination, and (optionally) how the
 	 *                 attributes are modified during this procedure 
 	 */
-	public static void modifyFeatureSource(FeatureSource<SimpleFeatureType,SimpleFeature> fs, AbstractDataStore destDataStore, AttributeModificationDefinition... destAttr) {
+	public static void modifyFeatureSource(FeatureSource<SimpleFeatureType,SimpleFeature> fs, AbstractDataStore destDataStore, AttributeModificationRule... destAttr) {
 	  throw new UnsupportedOperationException("FeatureUtil.modifyFeatureSource(..) not yet implemented!");
 	}
 



More information about the Schmitzm-commits mailing list