Package org.geotools.data
Class Diff
Object
Diff
- Direct Known Subclasses:
WFSDiff
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
-
Field Summary
FieldsModifier and TypeFieldDescriptionint
counter used to genreate the "next" new feature idstatic final SimpleFeature
A NullObject used to represent the absence of a SimpleFeature. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(String fid, SimpleFeature f) protected void
void
clear()
Clear diff - called during rollback.protected Quadtree
copySTRtreeFrom
(Diff diff) getAdded()
Unmodifiable view of added features.Unmodifieable list indicating the order features were addedUnmodifiable view of modified features.boolean
isEmpty()
Check if modifiedFeatures and addedFeatures are empty.void
modify
(String fid, SimpleFeature f) Record a modification to the indicated fidqueryIndex
(Envelope env) void
-
Field Details
-
nextFID
public int nextFIDcounter used to genreate the "next" new feature id -
NULL
A NullObject used to represent the absence of a SimpleFeature.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).
-
-
Constructor Details
-
Diff
public Diff()Create an empty Diff -
Diff
Diff copy.
-
-
Method Details
-
isEmpty
public boolean isEmpty()Check if modifiedFeatures and addedFeatures are empty.- Returns:
- true if Diff is empty
-
clear
public void clear()Clear diff - called during rollback. -
modify
Record a modification to the indicated fid- Parameters:
f
- replacement feature; null to indicate remove
-
add
-
addToSpatialIndex
-
remove
-
queryIndex
-
getAddedOrder
Unmodifieable list indicating the order features were added -
getModified
Unmodifiable view of modified features. It is imperative that the user manually synchronize on the map when iterating over any of its collection views: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.The returned map will be serializable if the specified map is serializable.
- Returns:
- Map of modified features, null user to represent a removed feature
-
getAdded
Unmodifiable view of added features. It is imperative that the user manually synchronize on the map when iterating over any of its collection views: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.The returned map will be serializable if the specified map is serializable.
- Returns:
- Map of added features
-
copySTRtreeFrom
-