Class ProgramMergeFilter

java.lang.Object
ghidra.program.util.ProgramMergeFilter

public class ProgramMergeFilter extends Object
The ProgramMergeFilter is used to specify which portions of a program should be merged into another program. It indicates the types of program differences to merge. Each merge type can have its filter set to IGNORE or REPLACE. IGNORE indicates no interest in replacing or merging that type of difference. REPLACE indicates to replace differences in program1 with differences of that type from program2. Some merge types (for example, COMMENTS and SYMBOLS) allow the filter to be set to MERGE. MERGE indicates that the type should be taken from Program2 and merged into Program1 with whatever is alreaady there.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Indicates all merge filters for all types of differences.
    static final int
    Indicates the merge filter for bookmark differences.
    static final int
    Indicates the merge filter for the byte differences.
    static final int
    Indicates to merge code unit differences.
    static final int
    Indicates to merge all comment differences.
    static final int
    Indicates the merge filter for the data code unit differences.
    static final int
    Indicates the merge filter for the eol comment differences.
    static final int
    Indicates the merge filter for the equates differences.
    static final int
    Indicates the merge filter for function tags.
    static final int
    Indicates the merge filter for the functions differences.
    static final int
    IGNORE is a filter value indicating that the type of difference isn't to be changed in the merged program.
    static final int
    Indicates the merge filter for the instruction code unit differences.
    static final int
    Indicates the merge filter difference type specified was not valid.
    static final int
    MERGE is a filter value indicating that the type of difference should be merged from program2 with what is already in program1 (the property type should be taken from both program1 and program2.)
    static final int
    Indicates the merge filter for the plate comment differences.
    static final int
    Indicates the merge filter for the post comment differences.
    static final int
    Indicates the merge filter for the pre comment differences.
    static final int
    Indicates the merge filter for replacing the primary symbol with the one from program 2 when merging labels.
    static final int
    Indicates the merge filter for the program context differences.
    static final int
    Indicates the merge filter for the user defined property differences.
    static final int
    Indicates the merge filter for the memory, variable, and external reference differences.
    static final int
    Indicates the merge filter for the repeatable comment differences.
    static final int
    REPLACE is a filter value indicating that the type of difference in program1 should be replaced with the difference from program2.
    static final int
    Indicates the merge filter for the label differences.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates new ProgramMergeFilter with none of the merge types selected.
    ProgramMergeFilter(int type, int filter)
    Creates new ProgramMergeFilter with the specified merge types selected.
    Creates new ProgramMergeFilter that is equal to the specified ProgramMergeFilter.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Determines whether or not this filter is equal to the object that is passed in.
    static String
    filterToName(int type)
    filterToName returns the string associated with an individual (primary) merge difference setting.
    int
    getFilter(int type)
    getFilter determines whether or not the specified type of filter is set.
    static int[]
    Gets all the valid individual types of differences for this filter.
    boolean
    Determines if at least one of the filter types is set to REPLACE or MERGE.
    void
    setFilter(int type, int filter)
    setFilter specifies whether or not the indicated type of item will not be included by the filter (IGNORE), replaced in the first program using the type of item in the second program (REPLACE), or included from both programs (MERGE).
    Returns a printable string indicating the current settings of this filter.
    static String
    typeToName(int type)
    typeToName() returns the name of a predefined merge type.
    boolean
    validatePredefinedType determines whether or not the indicated type of filter item is a valid predefined type.

    Methods inherited from class java.lang.Object

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

    • INVALID

      public static final int INVALID
      Indicates the merge filter difference type specified was not valid.
      See Also:
    • IGNORE

      public static final int IGNORE
      IGNORE is a filter value indicating that the type of difference isn't to be changed in the merged program.
      See Also:
    • REPLACE

      public static final int REPLACE
      REPLACE is a filter value indicating that the type of difference in program1 should be replaced with the difference from program2.
      See Also:
    • MERGE

      public static final int MERGE
      MERGE is a filter value indicating that the type of difference should be merged from program2 with what is already in program1 (the property type should be taken from both program1 and program2.)
      See Also:
    • PROGRAM_CONTEXT

      public static final int PROGRAM_CONTEXT
      Indicates the merge filter for the program context differences.
      See Also:
    • BYTES

      public static final int BYTES
      Indicates the merge filter for the byte differences.
      See Also:
    • INSTRUCTIONS

      public static final int INSTRUCTIONS
      Indicates the merge filter for the instruction code unit differences. This includes mnemonic, operand, and value references, and equates.
      See Also:
    • DATA

      public static final int DATA
      Indicates the merge filter for the data code unit differences.
      See Also:
    • REFERENCES

      public static final int REFERENCES
      Indicates the merge filter for the memory, variable, and external reference differences.
      See Also:
    • PLATE_COMMENTS

      public static final int PLATE_COMMENTS
      Indicates the merge filter for the plate comment differences.
      See Also:
    • PRE_COMMENTS

      public static final int PRE_COMMENTS
      Indicates the merge filter for the pre comment differences.
      See Also:
    • EOL_COMMENTS

      public static final int EOL_COMMENTS
      Indicates the merge filter for the eol comment differences.
      See Also:
    • REPEATABLE_COMMENTS

      public static final int REPEATABLE_COMMENTS
      Indicates the merge filter for the repeatable comment differences.
      See Also:
    • POST_COMMENTS

      public static final int POST_COMMENTS
      Indicates the merge filter for the post comment differences.
      See Also:
    • SYMBOLS

      public static final int SYMBOLS
      Indicates the merge filter for the label differences.
      See Also:
    • BOOKMARKS

      public static final int BOOKMARKS
      Indicates the merge filter for bookmark differences.
      See Also:
    • PROPERTIES

      public static final int PROPERTIES
      Indicates the merge filter for the user defined property differences.
      See Also:
    • FUNCTIONS

      public static final int FUNCTIONS
      Indicates the merge filter for the functions differences.
      See Also:
    • EQUATES

      public static final int EQUATES
      Indicates the merge filter for the equates differences.
      See Also:
    • PRIMARY_SYMBOL

      public static final int PRIMARY_SYMBOL
      Indicates the merge filter for replacing the primary symbol with the one from program 2 when merging labels.
      See Also:
    • FUNCTION_TAGS

      public static final int FUNCTION_TAGS
      Indicates the merge filter for function tags.
      See Also:
    • CODE_UNITS

      public static final int CODE_UNITS
      Indicates to merge code unit differences. This includes instructions, data, and equates.
      See Also:
    • COMMENTS

      public static final int COMMENTS
      Indicates to merge all comment differences.
      See Also:
    • ALL

      public static final int ALL
      Indicates all merge filters for all types of differences.
      See Also:
  • Constructor Details

    • ProgramMergeFilter

      public ProgramMergeFilter()
      Creates new ProgramMergeFilter with none of the merge types selected.
    • ProgramMergeFilter

      public ProgramMergeFilter(ProgramMergeFilter filter)
      Creates new ProgramMergeFilter that is equal to the specified ProgramMergeFilter.
    • ProgramMergeFilter

      public ProgramMergeFilter(int type, int filter)
      Creates new ProgramMergeFilter with the specified merge types selected.
      Parameters:
      type - the type of difference to look for between the programs.
      filter - IGNORE, REPLACE, or MERGE. Indicates which program difference to include of the specified type. If a particular type cannot be set to MERGE then it will be set to REPLACE.
  • Method Details

    • getFilter

      public int getFilter(int type)
      getFilter determines whether or not the specified type of filter is set. Valid types are: BYTES, INSTRUCTIONS, DATA, SYMBOLS, PRIMARY_SYMBOL, COMMENTS, PROGRAM_CONTEXT, PROPERTIES, BOOKMARKS, FUNCTIONS. INVALID is returned if combinations of merge types (e.g. ALL) are passed in.
      Parameters:
      type - the merge type.
      Returns:
      IGNORE, REPLACE, or MERGE. INVALID if parameter is a combination of types or not a predefined primary type.
    • validatePredefinedType

      public boolean validatePredefinedType(int type)
      validatePredefinedType determines whether or not the indicated type of filter item is a valid predefined type. Valid types are: BYTES, INSTRUCTIONS, DATA, SYMBOLS, PRIMARY_SYMBOL, COMMENTS, PROGRAM_CONTEXT, PROPERTIES, BOOKMARKS, FUNCTIONS, ALL.
      Parameters:
      type - the type of difference to look for between the programs.
      Returns:
      true if this is a pre-defined merge type.
    • isSet

      public boolean isSet()
      Determines if at least one of the filter types is set to REPLACE or MERGE.
      Returns:
      true if at least one type is set.
    • setFilter

      public void setFilter(int type, int filter)
      setFilter specifies whether or not the indicated type of item will not be included by the filter (IGNORE), replaced in the first program using the type of item in the second program (REPLACE), or included from both programs (MERGE). Valid types are: BYTES, INSTRUCTIONS, DATA, REFERENCES, SYMBOLS, PRIMARY_SYMBOL, COMMENTS, PROPERTIES, BOOKMARKS, FUNCTIONS, ALL, or combinations of these "OR"ed together. if MERGE is not valid for an included primary type, then it will be set to REPLACE instead for that primary type.
      Parameters:
      type - the type(s) of difference(s) to include.
      filter - IGNORE, REPLACE, or MERGE. Indicates whether to include none, one, or both programs' differences of the specified type.
    • toString

      public String toString()
      Returns a printable string indicating the current settings of this filter.
      Overrides:
      toString in class Object
      Returns:
      the current settings for this filter.
    • getPrimaryTypes

      public static int[] getPrimaryTypes()
      Gets all the valid individual types of differences for this filter.
      Returns:
      an array containing all the currently defined primary difference types.
    • typeToName

      public static String typeToName(int type)
      typeToName() returns the name of a predefined merge type. Only predefined types, as specified in ProgramMergeFilter, will return a name. Otherwise, an empty string is returned.
      Parameters:
      type - the type of merge difference whose name is wanted. Valid types are: BYTES, INSTRUCTIONS, DATA, REFERENCES, SYMBOLS, PRIMARY_SYMBOL, COMMENTS, PROGRAM_CONTEXT, PROPERTIES, BOOKMARKS, FUNCTIONS, ALL.
      Returns:
      the name of the predefined merge difference type. Otherwise, the empty string.
    • filterToName

      public static String filterToName(int type)
      filterToName returns the string associated with an individual (primary) merge difference setting.
      Parameters:
      type - the type of filter. Valid types are: IGNORE, REPLACE, MERGE.
      Returns:
      the string indicating the merge difference setting.
    • equals

      public boolean equals(Object obj)
      Determines whether or not this filter is equal to the object that is passed in.
      Overrides:
      equals in class Object
      Parameters:
      obj - the object to compare this one with.
      Returns:
      true if the filter matches this one.