String lastHandle = null;
boolean first = true;
if (insertResults != null) {
for (Iterator i = insertResults.getFeature().iterator(); i.hasNext();) {
InsertedFeatureType insertedFeature = (InsertedFeatureType) i.next();
String handle = insertedFeature.getHandle();
if (first || ((lastHandle == null) && (handle != null))
|| ((lastHandle != null) && (handle != null) && handle.equals(lastHandle))) {
if (!first) {
//close last one, if not the first time through
writer.write("</wfs:InsertResult>");
}
writer.write("<wfs:InsertResult");
if (insertedFeature.getHandle() != null) {
writer.write(" handle=\"" + insertedFeature.getHandle() + "\"");
}
writer.write(">");
}
for (Iterator id = insertedFeature.getFeatureId().iterator(); id.hasNext();) {
FeatureId featureId = (FeatureId) id.next();
writer.write("<ogc:FeatureId fid=\"" + featureId.toString() + "\"/>");
}
first = false;