/* * GeoTools - The Open Source Java GIS Toolkit * http://geotools.org * * (C) 2006-2008, Open Source Geospatial Foundation (OSGeo) * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; * version 2.1 of the License. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ package org.geotools.data; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.CopyOnWriteArrayList; import org.geotools.geometry.jts.ReferencedEnvelope; import org.opengis.feature.GeometryAttribute; import org.opengis.feature.IllegalAttributeException; import org.opengis.feature.Property; import org.opengis.feature.simple.SimpleFeature; import org.opengis.feature.simple.SimpleFeatureType; import org.opengis.feature.type.AttributeDescriptor; import org.opengis.feature.type.Name; import org.opengis.filter.identity.FeatureId; import org.opengis.geometry.BoundingBox; import com.vividsolutions.jts.geom.Envelope; import com.vividsolutions.jts.geom.Geometry; import com.vividsolutions.jts.index.SpatialIndex; import com.vividsolutions.jts.index.quadtree.Quadtree; /** * Captures changes made to a FeatureStore prior to being committed. *
* This is used to simulate the functionality of a database including transaction
* independence.
*
* @author Jody Garnett
*
* @source $URL$
*/
public class Diff{
/** Map of modified features; by feature id */
private final Map
* Note deleted features are represented as a null value recorded against their feature id
*/
private final Map
* The returned map will be serializable if the specified map is serializable.
* @deprecated Please use getModified();
*/
public final Map
* The returned map will be serializable if the specified map is serializable.
* @deprecated please use getAdded()
*/
public final Map
* The returned map will be serializable if the specified map is serializable.
*
* @return Map of modified features, null user to represent a removed feature
*/
public Map
* The returned map will be serializable if the specified map is serializable.
*
* @return Map of added features
*/
public Map
* This class is used by TransactionStateDiff as a placeholder to represent features that have been removed. The concept is generally useful and
* may wish to be taken out as a separate class (used for example to represent deleted rows in a shapefile).
*/
public static final SimpleFeature NULL = new SimpleFeature() {
public Object getAttribute(String path) {
return null;
}
public Object getAttribute(int index) {
return null;
}
// public Object[] getAttributes(Object[] attributes) {
// return null;
// }
public ReferencedEnvelope getBounds() {
return null;
}
public Geometry getDefaultGeometry() {
return null;
}
public SimpleFeatureType getFeatureType() {
return null;
}
public String getID() {
return null;
}
public FeatureId getIdentifier() {
return null;
}
// public int getNumberOfAttributes() {
// return 0;
// }
public void setAttribute(int position, Object val) {
}
public void setAttribute(String path, Object attribute) throws IllegalAttributeException {
}
// public void setDefaultGeometry(Geometry geometry)
// throws IllegalAttributeException {
// }
public Object getAttribute(Name name) {
return null;
}
public int getAttributeCount() {
return 0;
}
public List
* Set s = diff.modified2.keySet(); // Needn't be in synchronized block
* ...
* synchronized(diff) { // Synchronizing on diff, not diff.modified2 or s!
* Iterator i = s.iterator(); // Must be in synchronized block
* while (i.hasNext())
* foo(i.next());
* }
*
*
* Failure to follow this advice may result in non-deterministic behavior.
*
*
* Set s = diff.added.keySet(); // Needn't be in synchronized block
* ...
* synchronized(diff) { // Synchronizing on m, not diff.added or s!
* Iterator i = s.iterator(); // Must be in synchronized block
* while (i.hasNext())
* foo(i.next());
* }
*
*
* Failure to follow this advice may result in non-deterministic behavior.
*
*
* Set s = diff.modified2.keySet(); // Needn't be in synchronized block
* ...
* synchronized(diff) { // Synchronizing on diff, not diff.modified2 or s!
* Iterator i = s.iterator(); // Must be in synchronized block
* while (i.hasNext())
* foo(i.next());
* }
*
*
* Failure to follow this advice may result in non-deterministic behavior.
*
*
* Set s = diff.added.keySet(); // Needn't be in synchronized block
* ...
* synchronized(diff) { // Synchronizing on m, not diff.added or s!
* Iterator i = s.iterator(); // Must be in synchronized block
* while (i.hasNext())
* foo(i.next());
* }
*
*
* Failure to follow this advice may result in non-deterministic behavior.
*
*