Package ghidra.program.util
Class ProgramMergeFilter
java.lang.Object
ghidra.program.util.ProgramMergeFilter
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
Modifier and TypeFieldDescriptionstatic 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
ConstructorDescriptionCreates new ProgramMergeFilter with none of the merge types selected.ProgramMergeFilter
(int type, int filter) Creates new ProgramMergeFilter with the specified merge types selected.ProgramMergeFilter
(ProgramMergeFilter filter) Creates new ProgramMergeFilter that is equal to the specified ProgramMergeFilter. -
Method Summary
Modifier and TypeMethodDescriptionboolean
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
isSet()
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).toString()
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
(int type) validatePredefinedType determines whether or not the indicated type of filter item is a valid predefined type.
-
Field Details
-
INVALID
public static final int INVALIDIndicates the merge filter difference type specified was not valid.- See Also:
-
IGNORE
public static final int IGNOREIGNORE 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 REPLACEREPLACE 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 MERGEMERGE 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_CONTEXTIndicates the merge filter for the program context differences.- See Also:
-
BYTES
public static final int BYTESIndicates the merge filter for the byte differences.- See Also:
-
INSTRUCTIONS
public static final int INSTRUCTIONSIndicates 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 DATAIndicates the merge filter for the data code unit differences.- See Also:
-
REFERENCES
public static final int REFERENCESIndicates the merge filter for the memory, variable, and external reference differences.- See Also:
-
PLATE_COMMENTS
public static final int PLATE_COMMENTSIndicates the merge filter for the plate comment differences.- See Also:
-
PRE_COMMENTS
public static final int PRE_COMMENTSIndicates the merge filter for the pre comment differences.- See Also:
-
EOL_COMMENTS
public static final int EOL_COMMENTSIndicates the merge filter for the eol comment differences.- See Also:
-
REPEATABLE_COMMENTS
public static final int REPEATABLE_COMMENTSIndicates the merge filter for the repeatable comment differences.- See Also:
-
POST_COMMENTS
public static final int POST_COMMENTSIndicates the merge filter for the post comment differences.- See Also:
-
SYMBOLS
public static final int SYMBOLSIndicates the merge filter for the label differences.- See Also:
-
BOOKMARKS
public static final int BOOKMARKSIndicates the merge filter for bookmark differences.- See Also:
-
PROPERTIES
public static final int PROPERTIESIndicates the merge filter for the user defined property differences.- See Also:
-
FUNCTIONS
public static final int FUNCTIONSIndicates the merge filter for the functions differences.- See Also:
-
EQUATES
public static final int EQUATESIndicates the merge filter for the equates differences.- See Also:
-
PRIMARY_SYMBOL
public static final int PRIMARY_SYMBOLIndicates 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_TAGSIndicates the merge filter for function tags.- See Also:
-
CODE_UNITS
public static final int CODE_UNITSIndicates to merge code unit differences. This includes instructions, data, and equates.- See Also:
-
COMMENTS
public static final int COMMENTSIndicates to merge all comment differences.- See Also:
-
ALL
public static final int ALLIndicates 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
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. ifMERGE
is not valid for an included primary type, then it will be set toREPLACE
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
Returns a printable string indicating the current settings of 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
typeToName()
returns the name of a predefined merge type. Only predefined types, as specified inProgramMergeFilter
, 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
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
Determines whether or not this filter is equal to the object that is passed in.
-