if (layer != null && layer instanceof FeatureLayer) {
FeatureLayer featureLayer = (FeatureLayer) layer;
try {
QueryParam queryParam = new QueryParam();
queryParam.setWhere(where);
FeatureCollection<? extends FeatureType, ? extends Feature> layerFeatureCollection = featureLayer
.query(queryParam);
if (layerFeatureCollection != null
&& !layerFeatureCollection.isEmpty()) {
for (FeatureIterator<? extends Feature> itr = layerFeatureCollection
.features(); itr.hasNext();) {