Class ComparisonItem

java.lang.Object
ghidra.app.merge.structures.ComparisonItem
All Implemented Interfaces:
Comparable<ComparisonItem>

public abstract class ComparisonItem extends Object implements Comparable<ComparisonItem>
Base class for items that can be displayed in a CoordinatedStructureDisplay. These are basically different views from a CoordinatedStructureLine where each coordinated line has three comparison items, one for the left side structure, one for the right side structure, and for the merged structure.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static int
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Applies all the information in this item to the merged structure.
    boolean
    Returns true if any information in this item is not currently applied to the merged item.
    boolean
    Returns true if the information from this item can be cleared.
    void
    Clears this item from the merged structure.
    int
     
    getColumnText(int column)
    Returns the text to be display for the given column index.
    int
    Return the line number for this item in the coordinated display.
    int
    getMinWidth(int column)
    Returns the minimum width of this column.
    protected String
    Returns the type for this item.
    boolean
    Returns true if this items represents something that can be applied or not applied.
    boolean
    isAppliable(int column)
    Returns true if the specific information represented by the given column index is something can be applied whether or not it is currently applied.
    boolean
    isApplied(int column)
    Returns true if the specific information represented by the given column index is applied.
    boolean
    Returns if this item represent a blank line.
    boolean
    isLeftJustified(int column)
    Specifies if the column text should be left or right justified within it column.

    Methods inherited from class Object

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

    • MAX_COLS

      public static int MAX_COLS
  • Method Details

    • getColumnText

      public String getColumnText(int column)
      Returns the text to be display for the given column index.
      Parameters:
      column - the index of the column to get text for
      Returns:
      the text to be display for the given column index.
    • isAppliable

      public boolean isAppliable()
      Returns true if this items represents something that can be applied or not applied. Used to determine if a button should be created for this item. For example, a structure name can applied from either side, but the simple syntax line "{" is the same for all sides, so it is never appliable and should not have a corresponding button.
      Returns:
      true if this item can potentially be applied.
    • canApplyAny

      public boolean canApplyAny()
      Returns true if any information in this item is not currently applied to the merged item. if true, the button should be displayed as unselected, indicating to the user that this item has information that can be applied.
      Returns:
      true if any information in this item can be applied.
    • canClear

      public boolean canClear()
      Returns true if the information from this item can be cleared. Currently only items from component lines can be cleared. Items such as the structure name can never be cleared and can only change by selecting the other side value. If true, the button will be allowed to become unselected without the other side being selected.
      Returns:
      true if the information from this item can be cleared
    • isApplied

      public boolean isApplied(int column)
      Returns true if the specific information represented by the given column index is applied. This is used by the renderer to bold information that is applied and fade information that is not applied.
      Parameters:
      column - the column index to check if it is applied
      Returns:
      true if this column information is currently applied
    • isAppliable

      public boolean isAppliable(int column)
      Returns true if the specific information represented by the given column index is something can be applied whether or not it is currently applied. This is used by the renderer to render this columns test normally (not faded or bold)
      Parameters:
      column - the column index to check if it is appliable
      Returns:
      true if this columns information is changeable
    • getMinWidth

      public int getMinWidth(int column)
      Returns the minimum width of this column. Used to reserve space for a column even when there is no text to display in the column. The column may be wider if its text is wider than the minimum width. Used to help the renderer allocate available extra space when the view is resized.
      Parameters:
      column - the column to get the min width for
      Returns:
      the minimum width of this column
    • isLeftJustified

      public boolean isLeftJustified(int column)
      Specifies if the column text should be left or right justified within it column.
      Parameters:
      column - the column index
      Returns:
      true if the column text should be justified to the left side of the column
    • applyAll

      public void applyAll()
      Applies all the information in this item to the merged structure.
    • clear

      public void clear()
      Clears this item from the merged structure. Normally items from one side or the other are cleared when the corresponding item for the other side is applied. This allows the state where neither side is applied.
    • isBlank

      public boolean isBlank()
      Returns if this item represent a blank line. Useful for removing blank lines from the merge structure view.
      Returns:
      true if this item represents a blank line
    • getLine

      public int getLine()
      Return the line number for this item in the coordinated display. Note that this may be different from its index in its list model. The merged display removes blank lines, but maintains the line number where it matches in the left/right displays. This is uses to coordinated the left/right/merged views.
      Returns:
      the line number for this item
    • getType

      protected String getType()
      Returns the type for this item. Used to align the columns of like items. For example, all the fields in the component lines must line up, but that alignment is not coordinated with other categories such as the structure name line.
      Returns:
      the category for this item.
    • compareTo

      public int compareTo(ComparisonItem o)
      Specified by:
      compareTo in interface Comparable<ComparisonItem>