KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > team > core > diff > ITwoWayDiff


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.team.core.diff;
12
13 import org.eclipse.core.resources.IResourceDelta;
14 import org.eclipse.core.runtime.IPath;
15 import org.eclipse.team.core.diff.provider.TwoWayDiff;
16
17 /**
18  * A two-way diff represents the changes between two states of the same object,
19  * referred to as the "before" state and the "after" state.
20  * It is modeled after the {@link IResourceDelta} but is simplified.
21  * <p>
22  * This interface is not intended to be implemented by clients. Clients that
23  * need to create two-way diffs should instead use or subclass {@link TwoWayDiff}
24  * </p>
25  *
26  * @see IDiffTree
27  *
28  * @since 3.2
29  */

30 public interface ITwoWayDiff extends IDiff {
31
32     /*====================================================================
33      * Constants which describe resource changes:
34      *====================================================================*/

35
36     /**
37      * Change constant (bit mask) indicating that the content of the object has changed.
38      *
39      * @see ITwoWayDiff#getFlags()
40      */

41     public static final int CONTENT = 0x100;
42
43     /**
44      * Change constant (bit mask) indicating that the object was moved from another location.
45      * The location in the "before" state can be retrieved using <code>getFromPath()</code>.
46      *
47      * @see ITwoWayDiff#getFlags()
48      */

49     public static final int MOVE_FROM = 0x200;
50
51     /**
52      * Change constant (bit mask) indicating that the object was moved to another location.
53      * The location in the new state can be retrieved using <code>getToPath()</code>.
54      *
55      * @see ITwoWayDiff#getFlags()
56      */

57     public static final int MOVE_TO = 0x400;
58
59     /**
60      * Change constant (bit mask) indicating that the object was copied from another location.
61      * The location in the "before" state can be retrieved using <code>getFromPath()</code>.
62      *
63      * @see ITwoWayDiff#getFlags()
64      */

65     public static final int COPY_FROM = 0x800;
66     
67     /**
68      * Change constant (bit mask) indicating that the object has been
69      * replaced by another at the same location (i.e., the object has
70      * been deleted and then added).
71      *
72      * @see ITwoWayDiff#getFlags()
73      */

74     public static final int REPLACE = 0x1000;
75     
76     /**
77      * Returns flags which describe in more detail how a object has been affected.
78      * <p>
79      * The following codes (bit masks) are used when kind is <code>CHANGE</code>, and
80      * also when the object is involved in a move:
81      * <ul>
82      * <li><code>CONTENT</code> - The bytes contained by the resource have
83      * been altered.</li>
84      * <li><code>REPLACE</code> - The object
85      * was deleted (either by a delete or move), and was subsequently re-created
86      * (either by a create, move, or copy).</li>
87      * </ul>
88      * The following code is only used if kind is <code>REMOVE</code>
89      * (or <code>CHANGE</code> in conjunction with <code>REPLACE</code>):
90      * <ul>
91      * <li><code>MOVE_TO</code> - The object has moved.
92      * <code>getToPath</code> will return the path of where it was moved to.</li>
93      * </ul>
94      * The following code is only used if kind is <code>ADD</code>
95      * (or <code>CHANGE</code> in conjunction with <code>REPLACE</code>):
96      * <ul>
97      * <li><code>MOVE_FROM</code> - The object has moved.
98      * <code>getFromPath</code> will return the path of where it was moved from.</li>
99      * <li><code>COPY_FROM</code> - The object has copied.
100      * <code>getFromPath</code> will return the path of where it was copied from.</li>
101      * </ul>
102      * A simple move operation would result in the following diff information.
103      * If a object is moved from A to B (with no other changes to A or B),
104      * then A will have kind <code>REMOVE</code>, with flag <code>MOVE_TO</code>,
105      * and <code>getToPath</code> on A will return the path for B.
106      * B will have kind <code>ADD</code>, with flag <code>MOVE_FROM</code>,
107      * and <code>getFromPath</code> on B will return the path for A.
108      * B's other flags will describe any other changes to the resource, as compared
109      * to its previous location at A.
110      * </p>
111      * <p>
112      * Note that the move flags only describe the changes to a single object; they
113      * don't necessarily imply anything about the parent or children of the object.
114      * If the children were moved as a consequence of a subtree move operation,
115      * they will have corresponding move flags as well.
116      * </p>
117      *
118      * @return the flags
119      * @see ITwoWayDiff#CONTENT
120      * @see ITwoWayDiff#MOVE_TO
121      * @see ITwoWayDiff#MOVE_FROM
122      * @see ITwoWayDiff#COPY_FROM
123      * @see ITwoWayDiff#REPLACE
124      * @see #getKind()
125      * @see #getFromPath()
126      * @see #getToPath()
127      */

128     public int getFlags();
129     
130     /**
131      * Returns the full path (in the "before" state) from which this resource
132      * (in the "after" state) was moved. This value is only valid
133      * if the <code>MOVE_FROM</code> change flag is set; otherwise,
134      * <code>null</code> is returned.
135      * <p>
136      * Note: the returned path never has a trailing separator.
137      *
138      * @return a path, or <code>null</code>
139      * @see #getToPath()
140      * @see #getPath()
141      * @see #getFlags()
142      */

143     public IPath getFromPath();
144
145     /**
146      * Returns the full path (in the "after" state) to which this resource
147      * (in the "before" state) was moved. This value is only valid if the
148      * <code>MOVE_TO</code> change flag is set; otherwise,
149      * <code>null</code> is returned.
150      * <p>
151      * Note: the returned path never has a trailing separator.
152      *
153      * @return a path, or <code>null</code>
154      * @see #getFromPath()
155      * @see #getPath()
156      * @see #getFlags()
157      */

158     public IPath getToPath();
159
160 }
161
Popular Tags