org.tmatesoft.svn.core
Class SVNMergeRangeList

java.lang.Object
  extended by org.tmatesoft.svn.core.SVNMergeRangeList

public class SVNMergeRangeList
extends java.lang.Object

The SVNMergeRangeList represents an array of merge ranges applied to a single target. Provides addition functionality to operate with merge range lists.

Since:
1.2

Field Summary
static java.lang.String MERGE_INFO_NONINHERITABLE_STRING
          A string that is used in mergeinfo to mark the mergeinfo as being non-inheritable.
 
Constructor Summary
SVNMergeRangeList(long start, long end, boolean inheritable)
          Creates a new merge range list initializing it with a single merge range which parameters are passed to this constructor.
SVNMergeRangeList(SVNMergeRange range)
          Creates a new merge range list initializing it with the specified single merge range.
SVNMergeRangeList(SVNMergeRange[] ranges)
          Creates a new merge range list initializing it with an array of merge ranges.
 
Method Summary
 SVNMergeRangeList diff(SVNMergeRangeList eraserRangeList, boolean considerInheritance)
          Removes eraserRangeList (the subtrahend) from this range list (the minuend), and places the resulting difference into a new SVNMergeRangeList object.
 SVNMergeRangeList dup()
          Makes a copy of this merge range list.
static SVNMergeRangeList fromCollection(java.util.Collection mergeRanges)
          Creates a new SVNMergeRangeList from a collection of merge ranges.
 SVNMergeRangeList getInheritableRangeList(long startRev, long endRev)
          Returns a sublist of this range list which excludes all non-inheritable merge ranges.
 SVNMergeRangeList getInheritableRangeList(long startRev, long endRev, boolean inheritable)
           
 SVNMergeRange[] getRanges()
          Returns an array of SVNMergeRange ranges backed by this merge range list object.
 java.util.List<SVNMergeRange> getRangesAsList()
          Returns a list of merge ranges backed by this merge range list.
 int getSize()
          Returns number of merge ranges stored in this merge range list.
 boolean includes(long revision)
          Runs through all merge ranges in this object and says, whether the specified revision falls between start and end revision of any of those ranges.
 SVNMergeRangeList intersect(SVNMergeRangeList rangeList, boolean considerInheritance)
          Finds the intersection of this range list and rangeList and places the result into a new SVNMergeRangeList object.
 boolean isEmpty()
          Checks whether this merge range list has no merge ranges.
 SVNMergeRangeList merge(SVNMergeRangeList rangeList)
          Merges two range lists placing the results into a new SVNMergeRangeList object.
 SVNMergeRangeList mergeRevision(long revision)
           
 void pushRange(long start, long end, boolean inheritable)
          Appends a new merge range to the end of the ranges list.
 SVNMergeRangeList remove(SVNMergeRangeList remove, boolean considerInheritance)
           
 SVNMergeRangeList reverse()
          Reverses this range list, and the start and end fields of each range in this range list, in place.
 void setInheritable(boolean inheritable)
           
 void setRanges(SVNMergeRange[] ranges)
          Replaces the array of SVNMergeRange objects backed by this object with a new one.
 java.lang.String toString()
          Returns a string representation of this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MERGE_INFO_NONINHERITABLE_STRING

public static java.lang.String MERGE_INFO_NONINHERITABLE_STRING
A string that is used in mergeinfo to mark the mergeinfo as being non-inheritable.

Constructor Detail

SVNMergeRangeList

public SVNMergeRangeList(long start,
                         long end,
                         boolean inheritable)
Creates a new merge range list initializing it with a single merge range which parameters are passed to this constructor.

Parameters:
start - merge range start revision
end - merge range end revision
inheritable - inheritance information

SVNMergeRangeList

public SVNMergeRangeList(SVNMergeRange range)
Creates a new merge range list initializing it with the specified single merge range.

Parameters:
range - merge range

SVNMergeRangeList

public SVNMergeRangeList(SVNMergeRange[] ranges)
Creates a new merge range list initializing it with an array of merge ranges.

Note: ranges are not copied to a separate array but stored immediately, as is.

Parameters:
ranges - merge ranges array
Method Detail

setRanges

public void setRanges(SVNMergeRange[] ranges)
Replaces the array of SVNMergeRange objects backed by this object with a new one.

This method was introduced because of purposes of convenience. Use this method with care as it changes the internal state of this SVNMergeRangeList object.

Parameters:
ranges - new merge ranges array
Since:
1.2.2

setInheritable

public void setInheritable(boolean inheritable)

getRanges

public SVNMergeRange[] getRanges()
Returns an array of SVNMergeRange ranges backed by this merge range list object.

Note: this method does not make a copy of the original array, instead it returns the original array itself. If you want a safe copy of merge ranges, use getRangesAsList() instead.

Note: merge ranges returned in the array are not copied.

Returns:
array of merge ranges

getRangesAsList

public java.util.List<SVNMergeRange> getRangesAsList()
Returns a list of merge ranges backed by this merge range list.

Note: ranges themselves are not copied but placed in the list as is.

Returns:
a new list instance containing all of the ranges stored in this merge range list

pushRange

public void pushRange(long start,
                      long end,
                      boolean inheritable)
Appends a new merge range to the end of the ranges list. A new SVNMergeRange is created used the parameters passed to this method.

Parameters:
start - merge range start revision
end - merge range end revision
inheritable - inheritance information

getSize

public int getSize()
Returns number of merge ranges stored in this merge range list.

Returns:
number of merge ranges

isEmpty

public boolean isEmpty()
Checks whether this merge range list has no merge ranges.

Returns:
true if this merge range list is empty; otherwise false

dup

public SVNMergeRangeList dup()
Makes a copy of this merge range list. All merge ranges stored in this list will be copied to a new array which will be covered into a new SVNMergeRangeList instance.

Returns:
copy of this merge range list

merge

public SVNMergeRangeList merge(SVNMergeRangeList rangeList)
                        throws SVNException
Merges two range lists placing the results into a new SVNMergeRangeList object. Either range list may be empty.

When intersecting range lists are merged, the inheritability of the resulting SVNMergeRange depends on the inheritability of the operands. If two non-inheritable ranges are merged the result is always non-inheritable, in all other cases the resulting range is inheritable.

Note: range lists must be sorted in ascending order. The return range list is guaranteed to remain in sorted order and be compacted to the minimal number of ranges needed to represent the merged result.

Note: this method does not change the state of this object. Instead it produces a result in a new object.

Parameters:
rangeList - range list to merge with
Returns:
resultant range list
Throws:
SVNException

toString

public java.lang.String toString()
Returns a string representation of this object.

Overrides:
toString in class java.lang.Object
Returns:
this object as a string

diff

public SVNMergeRangeList diff(SVNMergeRangeList eraserRangeList,
                              boolean considerInheritance)
Removes eraserRangeList (the subtrahend) from this range list (the minuend), and places the resulting difference into a new SVNMergeRangeList object.

Parameters:
eraserRangeList - ranges to remove from this range list
considerInheritance - whether inheritance information should be taken into account
Returns:
the resultant difference

intersect

public SVNMergeRangeList intersect(SVNMergeRangeList rangeList,
                                   boolean considerInheritance)
Finds the intersection of this range list and rangeList and places the result into a new SVNMergeRangeList object.

Parameters:
rangeList - range list to intersect with
considerInheritance - whether inheritance information should be taken into account
Returns:
the result of intersection

includes

public boolean includes(long revision)
Runs through all merge ranges in this object and says, whether the specified revision falls between start and end revision of any of those ranges.

Parameters:
revision - revision to find in ranges
Returns:
true if one of the ranges in this list includes the specified revision

reverse

public SVNMergeRangeList reverse()
Reverses this range list, and the start and end fields of each range in this range list, in place.

Returns:
this object itself

getInheritableRangeList

public SVNMergeRangeList getInheritableRangeList(long startRev,
                                                 long endRev)
Returns a sublist of this range list which excludes all non-inheritable merge ranges. If startRev and endRev are valid revisions and startRev is less than or equal to endRev, then excludes only the non-inheritable revision ranges that intersect inclusively with the range defined by startRev and endRev. If this range list contains no elements, returns an empty array.

Parameters:
startRev - start revision
endRev - end revision
Returns:
a new SVNMergeRangeList object with only inheritable ranges from this range list

getInheritableRangeList

public SVNMergeRangeList getInheritableRangeList(long startRev,
                                                 long endRev,
                                                 boolean inheritable)

fromCollection

public static SVNMergeRangeList fromCollection(java.util.Collection mergeRanges)
Creates a new SVNMergeRangeList from a collection of merge ranges.

Parameters:
mergeRanges - merge ranges collection
Returns:
merge range list containing all the ranges from mergeRanges

remove

public SVNMergeRangeList remove(SVNMergeRangeList remove,
                                boolean considerInheritance)

mergeRevision

public SVNMergeRangeList mergeRevision(long revision)