Class Difference

java.lang.Object
org.netbeans.api.diff.Difference
All Implemented Interfaces:
Serializable

public class Difference extends Object implements Serializable
This class represents a single difference between two files.
See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final class 
    This class represents a difference on a single line.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Add type of difference - a portion of a file was added in the other
    static final int
    Change type of difference - a portion of a file was changed in the other
    static final int
    Delete type of difference - a portion of a file was removed in the other
  • Constructor Summary

    Constructors
    Constructor
    Description
    Difference(int type, int firstStart, int firstEnd, int secondStart, int secondEnd)
    Creates a new instance of Difference
    Difference(int type, int firstStart, int firstEnd, int secondStart, int secondEnd, String firstText, String secondText)
    Creates a new instance of Difference
    Difference(int type, int firstStart, int firstEnd, int secondStart, int secondEnd, String firstText, String secondText, Difference.Part[] firstLineDiffs, Difference.Part[] secondLineDiffs)
    Creates a new instance of Difference
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Get the line number on which the difference ends in the first file.
    The list of differences on lines in the first file.
    int
    Get the line number on which the difference starts in the first file.
    Get the text content of the difference in the first file.
    int
    Get the line number on which the difference ends in the second file.
    The list of differences on lines in the second file.
    int
    Get the line number on which the difference starts in the second file.
    Get the text content of the difference in the second file.
    int
    Get the difference type.
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • DELETE

      public static final int DELETE
      Delete type of difference - a portion of a file was removed in the other
      See Also:
    • ADD

      public static final int ADD
      Add type of difference - a portion of a file was added in the other
      See Also:
    • CHANGE

      public static final int CHANGE
      Change type of difference - a portion of a file was changed in the other
      See Also:
  • Constructor Details

    • Difference

      public Difference(int type, int firstStart, int firstEnd, int secondStart, int secondEnd)
      Creates a new instance of Difference
      Parameters:
      type - The type of the difference. Must be one of the DELETE, ADD or CHANGE
      firstStart - The line number on which the difference starts in the first file.
      firstEnd - The line number on which the difference ends in the first file.
      secondStart - The line number on which the difference starts in the second file.
      secondEnd - The line number on which the difference ends in the second file.
    • Difference

      public Difference(int type, int firstStart, int firstEnd, int secondStart, int secondEnd, String firstText, String secondText)
      Creates a new instance of Difference
      Parameters:
      type - The type of the difference. Must be one of the DELETE, ADD or CHANGE
      firstStart - The line number on which the difference starts in the first file.
      firstEnd - The line number on which the difference ends in the first file.
      secondStart - The line number on which the difference starts in the second file.
      secondEnd - The line number on which the difference ends in the second file.
      firstText - The text content of the difference in the first file.
      secondText - The text content of the difference in the second file.
    • Difference

      public Difference(int type, int firstStart, int firstEnd, int secondStart, int secondEnd, String firstText, String secondText, Difference.Part[] firstLineDiffs, Difference.Part[] secondLineDiffs)
      Creates a new instance of Difference
      Parameters:
      type - The type of the difference. Must be one of the DELETE, ADD or CHANGE
      firstStart - The line number on which the difference starts in the first file.
      firstEnd - The line number on which the difference ends in the first file.
      secondStart - The line number on which the difference starts in the second file.
      secondEnd - The line number on which the difference ends in the second file.
      firstText - The text content of the difference in the first file.
      secondText - The text content of the difference in the second file.
      firstLineDiffs - The list of differences on lines in the first file. The list contains instances of Difference.Part. Can be null when there are no line differences.
      secondLineDiffs - The list of differences on lines in the second file. The list contains instances of Difference.Part. Can be null when there are no line differences.
  • Method Details

    • getType

      public int getType()
      Get the difference type. It's one of DELETE, ADD or CHANGE meaning respective change in second source.
    • getFirstStart

      public int getFirstStart()
      Get the line number on which the difference starts in the first file.

      For ADD changes it returns previous line number e.g. 0 for add file start.

    • getFirstEnd

      public int getFirstEnd()
      Get the line number on which the difference ends in the first file.

      Does not have any meaning for ADD changes.

    • getSecondStart

      public int getSecondStart()
      Get the line number on which the difference starts in the second file.
    • getSecondEnd

      public int getSecondEnd()
      Get the line number on which the difference ends in the second file.

      Does not have any meaning for DELETE changes.

    • getFirstLineDiffs

      public Difference.Part[] getFirstLineDiffs()
      The list of differences on lines in the first file. The list contains instances of Difference.Part. Can be null when there are no line differences.
    • getSecondLineDiffs

      public Difference.Part[] getSecondLineDiffs()
      The list of differences on lines in the second file. The list contains instances of Difference.Part. Can be null when there are no line differences.
    • getFirstText

      public String getFirstText()
      Get the text content of the difference in the first file.
    • getSecondText

      public String getSecondText()
      Get the text content of the difference in the second file.
    • toString

      public String toString()
      Overrides:
      toString in class Object