001: /*
002: * GeoTools - OpenSource mapping toolkit
003: * http://geotools.org
004: * (C) 2002-2006, GeoTools Project Managment Committee (PMC)
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation;
009: * version 2.1 of the License.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: */
016: package org.geotools.data.postgis;
017:
018: import java.util.Collections;
019: import java.util.Set;
020:
021: /**
022: * Contains the three sets of feature ids that identify those changes occurred between two versions
023: * in the versioned datastore
024: *
025: * @author aaime
026: * @since 2.4
027: *
028: */
029: public class ModifiedFeatureIds {
030: RevisionInfo fromRevision;
031:
032: RevisionInfo toRevision;
033:
034: Set created;
035:
036: Set deleted;
037:
038: Set modified;
039:
040: public ModifiedFeatureIds(RevisionInfo fromRevision,
041: RevisionInfo toRevision) {
042: this (fromRevision, toRevision, Collections.EMPTY_SET,
043: Collections.EMPTY_SET, Collections.EMPTY_SET);
044: }
045:
046: public ModifiedFeatureIds(RevisionInfo fromRevision,
047: RevisionInfo toRevision, Set created, Set deleted,
048: Set modified) {
049: this .fromRevision = fromRevision;
050: this .toRevision = toRevision;
051: this .deleted = deleted;
052: this .created = created;
053: this .modified = modified;
054: }
055:
056: /**
057: * Contains all ids for features that were deleted before endVersion (a feature may be both in
058: * this set and in created if it was created and then deleted)
059: *
060: * @return
061: */
062: public Set getDeleted() {
063: return Collections.unmodifiableSet(deleted);
064: }
065:
066: /**
067: * Contains all ids for features that were created after startVersion (a feature may be both in
068: * this set and in deleted if it was created and then deleted)
069: *
070: * @return
071: */
072: public Set getCreated() {
073: return Collections.unmodifiableSet(created);
074: }
075:
076: /**
077: * Contains all ids for features that were already there at startVersion, were modified before
078: * endVersion and were not deleted.
079: *
080: * @return
081: */
082: public Set getModified() {
083: return Collections.unmodifiableSet(modified);
084: }
085:
086: public String getToVersion() {
087: return toRevision.getVersion();
088: }
089:
090: public String getFromVersion() {
091: return fromRevision.getVersion();
092: }
093:
094: public String toString() {
095: StringBuffer sb = new StringBuffer();
096: sb.append(
097: "Diff between: " + fromRevision + " and " + toRevision)
098: .append("\n");
099: sb.append("Created: ").append(created).append("\n");
100: sb.append("Deleted: ").append(deleted).append("\n");
101: sb.append("Modified: ").append(modified);
102: return sb.toString();
103: }
104:
105: }
|