Package ghidra.program.database.code

# Class StringDiff

java.lang.Object
ghidra.program.database.code.StringDiff

public class StringDiff extends Object
Container object that holds a start and end position within a string. A list of StringDiffs is used to keep track of changes made to a string.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `String`
  `text`
  String being inserted.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static StringDiff`
  `allTextReplaced(String newText)`
  Construct a new StringDiff with pos1 and pos2 are initialized to -1
  `boolean`
  `equals(Object obj)`
  `int`
  `hashCode()`
  `static StringDiff`
  `restore(String text, int start, int end)`
  `static StringDiff`
  `textDeleted(int start, int end)`
  Construct a new StringDiff that indicates text was deleted from pos1 to pos2
  `static StringDiff`
  `textInserted(String newText, int start)`
  Construct a new StringDiff that indicates that insertData was inserted at the given position
  `String`
  `toString()`

  ### Methods inherited from class java.lang.Object

  `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- ## Field Details

  - ### text

    public String text
    String being inserted. This can be an insert or a complete replace (the positions will both be -1 in a replace; pos1 will be non-negative during an insert).

- ## Method Details

  - ### allTextReplaced

    public static StringDiff allTextReplaced(String newText)
    Construct a new StringDiff with pos1 and pos2 are initialized to -1
    Parameters:
      `newText` - string
    Returns:
      the new diff

  - ### textDeleted

    public static StringDiff textDeleted(int start, int end)
    Construct a new StringDiff that indicates text was deleted from pos1 to pos2
    Parameters:
      `start` - position 1 for the diff
      `end` - position 2 for the diff
    Returns:
      the new diff

  - ### textInserted

    public static StringDiff textInserted(String newText, int start)
    Construct a new StringDiff that indicates that insertData was inserted at the given position
    Parameters:
      `newText` - inserted string
      `start` - position where the text was inserted
    Returns:
      the new diff

  - ### restore

    public static StringDiff restore(String text, int start, int end)

  - ### hashCode

    public int hashCode()
    Overrides:
      `hashCode` in class `Object`

  - ### equals

    public boolean equals(Object obj)
    Overrides:
      `equals` in class `Object`

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`