Package ghidra.program.util
Class ProgramMergeFilter
- java.lang.Object
-
- ghidra.program.util.ProgramMergeFilter
-
public class ProgramMergeFilter extends java.lang.Object
TheProgramMergeFilter
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 toIGNORE
orREPLACE
.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 toMERGE
.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 int
ALL
Indicates all merge filters for all types of differences.static int
BOOKMARKS
Indicates the merge filter for bookmark differences.static int
BYTES
Indicates the merge filter for the byte differences.static int
CODE_UNITS
Indicates to merge code unit differences.static int
COMMENTS
Indicates to merge all comment differences.static int
DATA
Indicates the merge filter for the data code unit differences.static int
EOL_COMMENTS
Indicates the merge filter for the eol comment differences.static int
EQUATES
Indicates the merge filter for the equates differences.static int
FUNCTION_TAGS
Indicates the merge filter for function tags.static int
FUNCTIONS
Indicates the merge filter for the functions differences.static int
IGNORE
IGNORE is a filter value indicating that the type of difference isn't to be changed in the merged program.static int
INSTRUCTIONS
Indicates the merge filter for the instruction code unit differences.static int
INVALID
Indicates the merge filter difference type specified was not valid.static 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.)static int
PLATE_COMMENTS
Indicates the merge filter for the plate comment differences.static int
POST_COMMENTS
Indicates the merge filter for the post comment differences.static int
PRE_COMMENTS
Indicates the merge filter for the pre comment differences.static int
PRIMARY_SYMBOL
Indicates the merge filter for replacing the primary symbol with the one from program 2 when merging labels.static int
PROGRAM_CONTEXT
Indicates the merge filter for the program context differences.static int
PROPERTIES
Indicates the merge filter for the user defined property differences.static int
REFERENCES
Indicates the merge filter for the memory, variable, and external reference differences.static int
REPEATABLE_COMMENTS
Indicates the merge filter for the repeatable comment differences.static int
REPLACE
REPLACE is a filter value indicating that the type of difference in program1 should be replaced with the difference from program2.static int
SYMBOLS
Indicates the merge filter for the label differences.
-
Constructor Summary
Constructors Constructor Description ProgramMergeFilter()
Creates 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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object obj)
Determines whether or not this filter is equal to the object that is passed in.static java.lang.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[]
getPrimaryTypes()
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).java.lang.String
toString()
Returns a printable string indicating the current settings of this filter.static java.lang.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 Detail
-
INVALID
public static final int INVALID
Indicates the merge filter difference type specified was not valid.- See Also:
- Constant Field Values
-
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:
- Constant Field Values
-
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:
- Constant Field Values
-
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:
- Constant Field Values
-
PROGRAM_CONTEXT
public static final int PROGRAM_CONTEXT
Indicates the merge filter for the program context differences.- See Also:
- Constant Field Values
-
BYTES
public static final int BYTES
Indicates the merge filter for the byte differences.- See Also:
- Constant Field Values
-
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:
- Constant Field Values
-
DATA
public static final int DATA
Indicates the merge filter for the data code unit differences.- See Also:
- Constant Field Values
-
REFERENCES
public static final int REFERENCES
Indicates the merge filter for the memory, variable, and external reference differences.- See Also:
- Constant Field Values
-
PLATE_COMMENTS
public static final int PLATE_COMMENTS
Indicates the merge filter for the plate comment differences.- See Also:
- Constant Field Values
-
PRE_COMMENTS
public static final int PRE_COMMENTS
Indicates the merge filter for the pre comment differences.- See Also:
- Constant Field Values
-
EOL_COMMENTS
public static final int EOL_COMMENTS
Indicates the merge filter for the eol comment differences.- See Also:
- Constant Field Values
-
REPEATABLE_COMMENTS
public static final int REPEATABLE_COMMENTS
Indicates the merge filter for the repeatable comment differences.- See Also:
- Constant Field Values
-
POST_COMMENTS
public static final int POST_COMMENTS
Indicates the merge filter for the post comment differences.- See Also:
- Constant Field Values
-
SYMBOLS
public static final int SYMBOLS
Indicates the merge filter for the label differences.- See Also:
- Constant Field Values
-
BOOKMARKS
public static final int BOOKMARKS
Indicates the merge filter for bookmark differences.- See Also:
- Constant Field Values
-
PROPERTIES
public static final int PROPERTIES
Indicates the merge filter for the user defined property differences.- See Also:
- Constant Field Values
-
FUNCTIONS
public static final int FUNCTIONS
Indicates the merge filter for the functions differences.- See Also:
- Constant Field Values
-
EQUATES
public static final int EQUATES
Indicates the merge filter for the equates differences.- See Also:
- Constant Field Values
-
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:
- Constant Field Values
-
FUNCTION_TAGS
public static final int FUNCTION_TAGS
Indicates the merge filter for function tags.- See Also:
- Constant Field Values
-
CODE_UNITS
public static final int CODE_UNITS
Indicates to merge code unit differences. This includes instructions, data, and equates.- See Also:
- Constant Field Values
-
COMMENTS
public static final int COMMENTS
Indicates to merge all comment differences.- See Also:
- Constant Field Values
-
ALL
public static final int ALL
Indicates all merge filters for all types of differences.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
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 Detail
-
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
public java.lang.String toString()
Returns a printable string indicating the current settings of this filter.- Overrides:
toString
in classjava.lang.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 java.lang.String typeToName(int type)
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
public static java.lang.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(java.lang.Object obj)
Determines whether or not this filter is equal to the object that is passed in.- Overrides:
equals
in classjava.lang.Object
- Parameters:
obj
- the object to compare this one with.- Returns:
- true if the filter matches this one.
-
-