Package ghidra.program.util
Class CommentFieldLocation
java.lang.Object
ghidra.program.util.ProgramLocation
ghidra.program.util.CodeUnitLocation
ghidra.program.util.CommentFieldLocation
- All Implemented Interfaces:
Cloneable
,Comparable<ProgramLocation>
- Direct Known Subclasses:
AutomaticCommentFieldLocation
,BlockStartLocation
,EolCommentFieldLocation
,MemoryBlockStartFieldLocation
,PlateFieldLocation
,PostCommentFieldLocation
,RefRepeatCommentFieldLocation
,RepeatableCommentFieldLocation
The
CommentFieldLocation
class contains specific location information
within the COMMENTS field of a CodeUnitLocation object.-
Field Summary
Fields inherited from class ghidra.program.util.ProgramLocation
addr, program, refAddr
-
Constructor Summary
ConstructorDescriptionDefault constructor needed for restoring a comment field location from XML.CommentFieldLocation
(Program program, Address addr, int[] componentPath, String[] comment, int type, int row, int charOffset) Construct a new CommentFieldLocation. -
Method Summary
Modifier and TypeMethodDescriptionboolean
String[]
Returns the array of strings that make up the comment.int
Returns the comment type.int
hashCode()
void
restoreState
(Program p, SaveState obj) Restore this program location using the given program and save state object.void
Save this program location to the given save state object.toString()
Returns a String representation of this location.protected void
Checks that the type is a valid comment type.Methods inherited from class ghidra.program.util.CodeUnitLocation
isValid
Methods inherited from class ghidra.program.util.ProgramLocation
clone, compareAddr, compareTo, getAddress, getByteAddress, getCharOffset, getColumn, getComponentPath, getLocation, getProgram, getRefAddress, getRow, getTranslatedCopy
-
Field Details
-
comment
-
type
protected int type
-
-
Constructor Details
-
CommentFieldLocation
public CommentFieldLocation(Program program, Address addr, int[] componentPath, String[] comment, int type, int row, int charOffset) Construct a new CommentFieldLocation.- Parameters:
program
- the program of the locationaddr
- address of the location; should not be null hierarchy names; this parameter may be nullcomponentPath
- if not null, it is the array of indexes that point to a specific data type inside of another data typecomment
- The array of strings that make up the commenttype
- The type of this comment. Can be either CodeUnit.PRE_COMMENT, CodeUnit.POST_COMMENT, CodeUnit.PLATE_COMMENT, CodeUnit.EOL_COMMENT, or CodeUnit.REPEATABLE_COMMENT.row
- The index of the string that contains the exact location.charOffset
- The position within the string that specifies the exact location.- Throws:
IllegalArgumentException
- Thrown if type is not one of the comment values given inCodeUnit
-
CommentFieldLocation
public CommentFieldLocation()Default constructor needed for restoring a comment field location from XML.
-
-
Method Details
-
validateType
protected void validateType()Checks that the type is a valid comment type.- Throws:
IllegalArgumentException
- if this doesn't have a valid comment type.
-
getComment
Returns the array of strings that make up the comment.- Returns:
- the comment
-
getCommentType
public int getCommentType()Returns the comment type. The type is either CodeUnit.EOL_COMMENT, CodeUnit.POST_COMMENT, CodeUnit.PLATE_COMMENT, CodeUnit.PRE_COMMENT, or CodeUnit.REPEATABLE_COMMENT.- Returns:
- the comment type
-
toString
Returns a String representation of this location.- Overrides:
toString
in classProgramLocation
-
hashCode
public int hashCode()- Overrides:
hashCode
in classProgramLocation
-
equals
- Overrides:
equals
in classProgramLocation
-
saveState
Description copied from class:ProgramLocation
Save this program location to the given save state object.- Overrides:
saveState
in classProgramLocation
- Parameters:
obj
- the save state object for saving the location
-
restoreState
Description copied from class:ProgramLocation
Restore this program location using the given program and save state object.- Overrides:
restoreState
in classProgramLocation
- Parameters:
p
- program to restore fromobj
- the save state to restore from
-