I think that I finally have it now. I'm sure that it isn't perfect but it
works.
public void updateFeature(SimpleFeature feature) throws Exception {
FeatureStore featureStore = ((FeatureStore) mainFeatureSource);
Collection<PropertyDescriptor> descriptors =
mainFeatureSource.getSchema().getDescriptors();
Name fipsName = null;
for (PropertyDescriptor descriptor : descriptors) {
Name name = descriptor.getName();
if (name.toString().equalsIgnoreCase("FIPS")) {
fipsName = name;
}
}
try {
Filter filter =
filterFactory.id(Collections.singleton(feature.getIdentifier()));
Name[] attributeNames = new Name[1];
attributeNames[0] = fipsName;
Object[] attributeValues = new Object[1];
attributeValues[0] = feature.getAttribute("FIPS");
featureStore.modifyFeatures(attributeNames,
attributeValues, filter);
}
catch (Exception e) {
e.printStackTrace();
}
}
Hopefully this helps someone avoid the painful learning curve that I'm going
through.
--
View this message in context:
http://osgeo-org.1560.x6.nabble.com/How-to-modify-a-single-Feature-tp5058350p5061175.html
Sent from the geotools-gt2-users mailing list archive at Nabble.com.
------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:
Build for Windows Store.
http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
GeoTools-GT2-Users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users