Package adams.core
Class DiffUtils.SideBySideDiff
- java.lang.Object
-
- adams.core.DiffUtils.SideBySideDiff
-
- All Implemented Interfaces:
Serializable,Cloneable
- Enclosing class:
- DiffUtils
public static class DiffUtils.SideBySideDiff extends Object implements Serializable, Cloneable
Container object for a side-by-side diff.- Version:
- $Revision$
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description SideBySideDiff()Initializes the container with an empty diff.SideBySideDiff(List[] diff)Initializes the container.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DiffUtils.SideBySideDiffclone()Returns a clone if itself.intdeltaToLine(int delta, boolean start)Returns the line number (start or end) of the given delta.intdifferences()Returns the number of differences.ListgetIndicator()Returns the indicator list.ListgetLeft()Return the diff of the left/first list/file.intgetNextDelta(int line)Returns the next delta after the current line.intgetPreviousDelta(int line)Returns the previous delta after the current line.ListgetRight()Return the diff of the right/second list/file.ListgetStartPos()Return the list with starting positions of the deltas.booleanhasDifferences()Returns whether there are any differences between the two files/lists.booleanhasNextDelta(int line)Checks whether there is a next delta after the current line.booleanhasPreviousDelta(int line)Checks whether there is a previous delta after the current line.intlineToDelta(int line)Returns the closest patch delta index for the given line number.StringtoString()Generates a string representation of the diff information.StringtoString(String separator)Generates a string representation of the diff information.
-
-
-
Field Detail
-
m_Diff
protected List[] m_Diff
the diff information.
-
-
Constructor Detail
-
SideBySideDiff
public SideBySideDiff()
Initializes the container with an empty diff.
-
SideBySideDiff
public SideBySideDiff(List[] diff)
Initializes the container.
-
-
Method Detail
-
getLeft
public List getLeft()
Return the diff of the left/first list/file.- Returns:
- the diff
-
getRight
public List getRight()
Return the diff of the right/second list/file.- Returns:
- the diff
-
getIndicator
public List getIndicator()
Returns the indicator list.- Returns:
- the indicator
-
getStartPos
public List getStartPos()
Return the list with starting positions of the deltas.- Returns:
- the list with start positions
-
hasDifferences
public boolean hasDifferences()
Returns whether there are any differences between the two files/lists.- Returns:
- true if there are differences
-
differences
public int differences()
Returns the number of differences.- Returns:
- the number of differences
-
lineToDelta
public int lineToDelta(int line)
Returns the closest patch delta index for the given line number.- Parameters:
line- the 0-based line number- Returns:
- the index of the delta, -1 if no delta matched
-
deltaToLine
public int deltaToLine(int delta, boolean start)Returns the line number (start or end) of the given delta.- Parameters:
delta- the 0-based delta index- Returns:
- the line number, -1 if failed to determine
-
hasNextDelta
public boolean hasNextDelta(int line)
Checks whether there is a next delta after the current line.- Parameters:
line- the current line number (0-based)- Returns:
- the next delta index, -1 if none available
-
getNextDelta
public int getNextDelta(int line)
Returns the next delta after the current line.- Parameters:
line- the current line number (0-based)- Returns:
- the next delta index, -1 if none available
-
hasPreviousDelta
public boolean hasPreviousDelta(int line)
Checks whether there is a previous delta after the current line.- Parameters:
line- the current line number (0-based)- Returns:
- the previous delta index, -1 if none available
-
getPreviousDelta
public int getPreviousDelta(int line)
Returns the previous delta after the current line.- Parameters:
line- the current line number (0-based)- Returns:
- the previous delta index, -1 if none available
-
clone
public DiffUtils.SideBySideDiff clone()
Returns a clone if itself.
-
toString
public String toString(String separator)
Generates a string representation of the diff information.- Parameters:
separator- the separator between the columns- Returns:
- the string representation
-
-