[Schmitzm-commits] r1928 - in branches/2.6.x/schmitzm-gt/src/main/java/de/schmitzm/geotools: feature gui
scm-commit at wald.intevation.org
scm-commit at wald.intevation.org
Sat Mar 31 09:44:50 CEST 2012
Author: keeb
Date: 2012-03-31 09:44:50 +0200 (Sat, 31 Mar 2012)
New Revision: 1928
Modified:
branches/2.6.x/schmitzm-gt/src/main/java/de/schmitzm/geotools/feature/FeatureUtil.java
branches/2.6.x/schmitzm-gt/src/main/java/de/schmitzm/geotools/gui/JMapEditorPane.java
Log:
backporting new method createFeatureInstance to solve problems with ambiguous methods in java7
Modified: branches/2.6.x/schmitzm-gt/src/main/java/de/schmitzm/geotools/feature/FeatureUtil.java
===================================================================
--- branches/2.6.x/schmitzm-gt/src/main/java/de/schmitzm/geotools/feature/FeatureUtil.java 2012-03-30 10:44:45 UTC (rev 1927)
+++ branches/2.6.x/schmitzm-gt/src/main/java/de/schmitzm/geotools/feature/FeatureUtil.java 2012-03-31 07:44:50 UTC (rev 1928)
@@ -1076,7 +1076,7 @@
.getDefaultValue());
// Erweitertes SimpleFeature erzeugen und FeatureCollection
// fuellen
- resultFc.add(createFeature(resultType, fValues));
+ resultFc.add(createFeatureInstance(resultType, null, null, fValues));
}
} finally {
fc.close(fi);
@@ -1226,7 +1226,7 @@
// Erweitertes SimpleFeature erzeugen und
// FeatureCollection
// fuellen
- resultFc.add(createFeature(resultType, fValues));
+ resultFc.add(createFeatureInstance(resultType, null, null, fValues));
} else {
for (SimpleFeature f2 = null; joinedFeaturesIterator
.hasNext();) {
@@ -1707,7 +1707,7 @@
for (int i = 0; i < rsFeatureType.getAttributeCount(); i++)
rsFeatureValues[i] = rs.getObject(rsFeatureType
.getDescriptor(i).getName().getLocalPart());
- rsFeatureCollection.add(createFeature(rsFeatureType,
+ rsFeatureCollection.add(createFeatureInstance(rsFeatureType,null,null,
rsFeatureValues));
}
@@ -2050,18 +2050,45 @@
* @param schema
* schema for the feature
* @param forceNewBuilder
- * forces the creation of a new {@link SimpleFeatureBuilder}
+ * forces the creation of a new {@link SimpleFeatureBuilder}. If
+ * <code>null</code> <code>false</code> is used.
* @param fID
- * feature id for the new feature
+ * feature id for the new feature. If <code>null</code> a random
+ * ID will be generated
* @param attrValues
* values of the attributes
*/
- public static SimpleFeature createFeature(SimpleFeatureType schema,
- boolean forceNewBuilder, String fID, Object... attrValues) {
+ public static SimpleFeature createFeatureInstance(SimpleFeatureType schema,
+ Boolean forceNewBuilder, String fID, Object... attrValues) {
+
+ if (fID == null)
+ fID = "FID_" + new Random().nextInt();
+
+ if (forceNewBuilder == null)
+ forceNewBuilder = false;
+
SimpleFeatureBuilder builder = getFeatureBuilderFromCache(schema,
forceNewBuilder);
return builder.buildFeature(fID, attrValues);
}
+
+ /**
+ * Creates a new feature for a given schema.
+ *
+ * @param schema
+ * schema for the feature
+ * @param fID
+ * feature id for the new feature
+ * @param attrValues
+ * values of the attributes
+ * @deprecated use
+ * {@link #createFeatureInstance(SimpleFeatureType, Boolean, String, Object...)}
+ * to avoid ambiguous method calls. http://stackoverflow.com/questions/7689386/why-doesnt-autoboxing-overrule-varargs-when-using-method-overloading-in-java-7
+ */
+ public static SimpleFeature createFeature(SimpleFeatureType schema,
+ Boolean forceNewBuilder, String fID, Object... attrValues) {
+ return createFeatureInstance(schema, forceNewBuilder, fID, attrValues);
+ }
/**
* Creates a new feature for a given schema.
@@ -2072,6 +2099,9 @@
* feature id for the new feature
* @param attrValues
* values of the attributes
+ * @deprecated use
+ * {@link #createFeatureInstance(SimpleFeatureType, Boolean, String, Object...)}
+ * to avoid ambiguous method calls. http://stackoverflow.com/questions/7689386/why-doesnt-autoboxing-overrule-varargs-when-using-method-overloading-in-java-7
*/
public static SimpleFeature createFeature(SimpleFeatureType schema,
String fID, Object... attrValues) {
@@ -2085,6 +2115,9 @@
* schema for the feature
* @param attrValues
* values of the attributes
+ * @deprecated use
+ * {@link #createFeatureInstance(SimpleFeatureType, Boolean, String, Object...)}
+ * to avoid ambiguous method calls. http://stackoverflow.com/questions/7689386/why-doesnt-autoboxing-overrule-varargs-when-using-method-overloading-in-java-7
*/
public static SimpleFeature createFeature(SimpleFeatureType schema,
Object... attrValues) {
Modified: branches/2.6.x/schmitzm-gt/src/main/java/de/schmitzm/geotools/gui/JMapEditorPane.java
===================================================================
--- branches/2.6.x/schmitzm-gt/src/main/java/de/schmitzm/geotools/gui/JMapEditorPane.java 2012-03-30 10:44:45 UTC (rev 1927)
+++ branches/2.6.x/schmitzm-gt/src/main/java/de/schmitzm/geotools/gui/JMapEditorPane.java 2012-03-31 07:44:50 UTC (rev 1928)
@@ -872,7 +872,7 @@
LineString lineString = createGeometryFromPoints(LineString.class,
coord);
try {
- return FeatureUtil.createFeature(segmLineFeatureType, lineString);
+ return FeatureUtil.createFeatureInstance(segmLineFeatureType, null, null, lineString);
} catch (Exception e) {
throw new RuntimeException(e);
}
@@ -893,7 +893,7 @@
MultiPoint multiPoint = createGeometryFromPoints(MultiPoint.class,
coord);
try {
- return FeatureUtil.createFeature(segmPointFeatureType, multiPoint);
+ return FeatureUtil.createFeatureInstance(segmPointFeatureType, null, null, multiPoint);
} catch (Exception e) {
throw new RuntimeException(e);
}
@@ -924,7 +924,7 @@
attr[i] = FeatureUtil.getNextAutoValue(aType);
}
// create new feature
- feature = FeatureUtil.createFeature(editorFeatureType, attr);
+ feature = FeatureUtil.createFeatureInstance(editorFeatureType, null, null, attr);
}
feature.setDefaultGeometry(createGeometryFromPoints(
getGeometryType(editorMode), coord));
More information about the Schmitzm-commits
mailing list