Class TwoWayDiff

    • Field Detail

      • FLAG_MASK

        protected static final int FLAG_MASK
        Constant (bit mask) that defines the area of the status that is reserved for use by this abstract class for encoding the flags of the diff. However, subclasses may include their own bits in the flag as long as they do not overlap with the bits in the FLAG_MASK
        See Also:
        Diff.getStatus(), Constant Field Values
    • Constructor Detail

      • TwoWayDiff

        public TwoWayDiff​(IPath path,
                          int kind,
                          int flags)
        Create a two-way diff
        Parameters:
        path - the path of the model object that has changed
        kind - the kind of change
        flags - additional flags that describe the change
    • Method Detail

      • getFlags

        public int getFlags()
        Description copied from interface: ITwoWayDiff
        Returns flags which describe in more detail how a object has been affected.

        The following codes (bit masks) are used when kind is CHANGE, and also when the object is involved in a move:

        • CONTENT - The bytes contained by the resource have been altered.
        • REPLACE - The object was deleted (either by a delete or move), and was subsequently re-created (either by a create, move, or copy).
        The following code is only used if kind is REMOVE (or CHANGE in conjunction with REPLACE):
        • MOVE_TO - The object has moved. getToPath will return the path of where it was moved to.
        The following code is only used if kind is ADD (or CHANGE in conjunction with REPLACE):
        • MOVE_FROM - The object has moved. getFromPath will return the path of where it was moved from.
        • COPY_FROM - The object has copied. getFromPath will return the path of where it was copied from.

        A simple move operation would result in the following diff information. If a object is moved from A to B (with no other changes to A or B), then A will have kind REMOVE, with flag MOVE_TO, and getToPath on A will return the path for B. B will have kind ADD, with flag MOVE_FROM, and getFromPath on B will return the path for A. B's other flags will describe any other changes to the resource, as compared to its previous location at A.

        Note that the move flags only describe the changes to a single object; they don't necessarily imply anything about the parent or children of the object. If the children were moved as a consequence of a subtree move operation, they will have corresponding move flags as well.

        Specified by:
        getFlags in interface ITwoWayDiff
        Returns:
        the flags
        See Also:
        ITwoWayDiff.CONTENT, ITwoWayDiff.MOVE_TO, ITwoWayDiff.MOVE_FROM, ITwoWayDiff.COPY_FROM, ITwoWayDiff.REPLACE, IDiff.getKind(), ITwoWayDiff.getFromPath(), ITwoWayDiff.getToPath()
      • getFromPath

        public IPath getFromPath()
        Description copied from interface: ITwoWayDiff
        Returns the full path (in the "before" state) from which this resource (in the "after" state) was moved. This value is only valid if the MOVE_FROM change flag is set; otherwise, null is returned.

        Note: the returned path never has a trailing separator.

        Specified by:
        getFromPath in interface ITwoWayDiff
        Returns:
        a path, or null
        See Also:
        ITwoWayDiff.getToPath(), IDiff.getPath(), ITwoWayDiff.getFlags()
      • equals

        public boolean equals​(Object obj)
        Overrides:
        equals in class Diff