001: /*
002: * GeoTools - OpenSource mapping toolkit
003: * http://geotools.org
004: * (C) 2005-2006, GeoTools Project Managment Committee (PMC)
005: * (C) 2005, Refractions Research Inc.
006: *
007: * This library is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU Lesser General Public
009: * License as published by the Free Software Foundation;
010: * version 2.1 of the License.
011: *
012: * This library is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: */
017: package org.geotools.catalog;
018:
019: import java.io.IOException;
020: import java.util.Collections;
021: import java.util.List;
022: import java.util.Set;
023:
024: /**
025: * Constants used to communicate Catalog Deltas.
026: * <p>
027: * For those familiar with IResourceChangeEvent and IResourceDelta from eclipse development there is
028: * one <b>important addition</b>. The constant REPLACE indicates a reaname, or substiution, you
029: * will need to replace any references you have to the oldObject with the newObject.
030: * </p>
031: * <p>
032: * For "bit mask" style interation please use: <code>EnumSet.of(Kind.ADDED, Kind.REPLACED)</code>
033: * </p>
034: *
035: * @author Jody Garnett
036: * @author Justin Deoliveira, The Open Planning Project
037: * @since 0.6.0
038: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/api/src/main/java/org/geotools/catalog/ResolveDelta.java $
039: */
040: public interface ResolveDelta {
041: /** List indicating no children are present */
042: static final List NO_CHILDREN = Collections.EMPTY_LIST;
043:
044: /**
045: * Returns the kind of this delta.
046: * <p>
047: * Normally, one of <code>ADDED</code>, <code>REMOVED</code>, <code>CHANGED</code> or
048: * <code>REPLACED</code>.
049: * </p>
050: * <p>
051: * This set is still open, during shutdown we may throw a few more kinds around. Eclipse makes
052: * use of PHANTOM, and NON_PHANTOM not sure we care
053: * </p>
054: *
055: * @return the kind of this resource delta
056: * @see Kind.ADDED
057: * @see Kind.REMOVED
058: * @see Kind.CHANGED
059: * @see Kind.REPLACED
060: */
061: Kind getKind();
062:
063: /**
064: * Accepts the given visitor.
065: * <p>
066: * The only kinds of resource delta that our visited are ADDED, REMOVED, CHANGED and REPLACED.
067: * </p>
068: * <p>
069: * This is a convenience method, equivalent to accepts( visitor, IService.NONE )
070: * </p>
071: *
072: * @param visitor
073: * @throws CoreException
074: */
075: void accept(ResolveDeltaVisitor visitor) throws IOException;
076:
077: /**
078: * Resource deltas for all added, removed, changed, or replaced.
079: * <p>
080: * This is a short cut for:
081: *
082: * <pre><code>
083: * finally List list = new ArrayList();
084: * accept( IServiceDeltaVisitor() {
085: * public boolean visit(IResolveDelta delta) {
086: * switch (delta.getKind()) {
087: * case IDelta.ADDED :
088: * case IDelta.REMOVED :
089: * case IDelta.CHANGED :
090: * case IDelta.REPLACED :
091: * list.add( delta );
092: * default: // ignore
093: * }
094: * return true;
095: * }
096: * });
097: * return list.toArray();
098: * </code></pre>
099: *
100: * </p>
101: *
102: * @return A list of type ResolveDelta.
103: */
104: List getChildren();
105:
106: /**
107: * Finds and returns the delta information for a given resource.
108: *
109: * @param kindMask Set of IDelta.Kind
110: * @return List of IGeoResourceDelta
111: */
112: List getChildren(Set kindMask);
113:
114: /**
115: * Returns a handle for the affected handle.
116: * <p>
117: * For additions (<code>ADDED</code>), this handle describes the newly-added resolve; i.e.,
118: * the one in the "after" state.
119: * <p>
120: * For changes (<code>CHANGED</code>), this handle also describes the resource in the
121: * "after" state.
122: * <p>
123: * For removals (<code>REMOVED</code>), this handle describes the resource in the "before"
124: * state. Even though this handle not normally exist in the current workspace, the type of
125: * resource that was removed can be determined from the handle.
126: * <p>
127: * For removals (<code>REPLACE</code>), this handle describes the resource in the "before"
128: * state. The new handle can be determined with getNewResolve().
129: * <p>
130: *
131: * @return the affected resource (handle)
132: */
133: Resolve getResolve();
134:
135: /**
136: * For replacement (<code>REPLACE</code>), this handle describes the resource in the "after"
137: * state. The old handle can be determined with getResolve().
138: * <p>
139: *
140: * @return The new resolve replacing the affected handle.
141: */
142: Resolve getNewResolve();
143:
144: /**
145: * Kind of Delta, used to indicate change.
146: *
147: * @author jgarnett
148: * @since 0.9.0
149: */
150: class Kind {
151: /**
152: * Delta kind constant indicating no change.
153: *
154: * @see #getKind()
155: */
156: public static final Kind NO_CHANGE = new Kind();
157:
158: /**
159: * The resource has been added to the catalog.
160: *
161: * @see #getKind()
162: */
163: public static final Kind ADDED = new Kind();
164:
165: /**
166: * The resource has been removed from the catalog.
167: *
168: * @see #getKind()
169: */
170: public static final Kind REMOVED = new Kind();
171:
172: /**
173: * The resource has been changed.
174: *
175: * @see #getKind()
176: */
177: public static final Kind CHANGED = new Kind();
178:
179: /**
180: * The resource has been replaced with another entry in the catalog.
181: *
182: * @see #getKind()
183: */
184: public static final Kind REPLACED = new Kind();
185: }
186: }
|