Class FieldFactory

java.lang.Object
ghidra.app.util.viewer.field.FieldFactory
All Implemented Interfaces:
ExtensionPoint
Direct Known Subclasses:
AbstractVariableFieldFactory, AddressFieldFactory, ArrayValuesFieldFactory, AssignedVariableFieldFactory, BytesFieldFactory, DummyFieldFactory, EolCommentFieldFactory, FieldNameFieldFactory, FileOffsetFieldFactory, FunctionCallFixupFieldFactory, FunctionPurgeFieldFactory, FunctionRepeatableCommentFieldFactory, FunctionSignatureFieldFactory, FunctionSignatureSourceFieldFactory, FunctionTagFieldFactory, InstructionMaskValueFieldFactory, LabelFieldFactory, MemoryBlockStartFieldFactory, MnemonicFieldFactory, OpenCloseFieldFactory, OperandFieldFactory, ParallelInstructionFieldFactory, PcodeFieldFactory, PlateFieldFactory, PostCommentFieldFactory, PreCommentFieldFactory, RegisterFieldFactory, RegisterTransitionFieldFactory, SeparatorFieldFactory, SpaceFieldFactory, SpacerFieldFactory, ThunkedFunctionFieldFactory, XRefFieldFactory

public abstract class FieldFactory extends Object implements ExtensionPoint
NOTE: ALL FIELDFACTORY CLASSES MUST END IN "FieldFactory". If not, the ClassSearcher will not find them. Base class for Field Factories.
  • Field Details

    • FONT_OPTION_NAME

      public static final String FONT_OPTION_NAME
      See Also:
    • BASE_LISTING_FONT_ID

      public static final String BASE_LISTING_FONT_ID
      See Also:
    • model

      protected FieldFormatModel model
    • name

      protected String name
    • startX

      protected int startX
    • width

      protected int width
    • baseFont

      protected Font baseFont
    • style

      protected int style
    • enabled

      protected boolean enabled
    • hlProvider

      protected ListingHighlightProvider hlProvider
    • colorOptionName

      protected String colorOptionName
    • styleOptionName

      protected String styleOptionName
  • Constructor Details

    • FieldFactory

      protected FieldFactory(String name, FieldFormatModel model, ListingHighlightProvider highlightProvider, Options displayOptions, Options fieldOptions)
      Base constructor
      Parameters:
      name - the name of the field
      model - the model that the field belongs to.
      highlightProvider - the HightLightStringProvider.
      displayOptions - the Options for display properties.
      fieldOptions - the Options for field specific properties.
    • FieldFactory

      public FieldFactory(String name)
      Constructs a FieldFactory with given name. Used only as potential field.
      Parameters:
      name - the name of the field.
  • Method Details

    • initFieldOptions

      protected void initFieldOptions(Options fieldOptions)
    • initDisplayOptions

      protected void initDisplayOptions(Options displayOptions)
    • servicesChanged

      public void servicesChanged()
      Notification the services changed. Subclasses should override this method if they care about service changes.
    • newInstance

      public abstract FieldFactory newInstance(FieldFormatModel formatModel, ListingHighlightProvider highlightProvider, ToolOptions options, ToolOptions fieldOptions)
      Returns a new instance of this FieldFactory that can be used to generate fields instead of being used as a prototype.
      Parameters:
      formatModel - the model that the field belongs to.
      highlightProvider - the HightLightProvider.
      options - the Options for display properties.
      fieldOptions - the Options for field specific properties.
      Returns:
      the factory
    • displayOptionsChanged

      public void displayOptionsChanged(Options options, String optionName, Object oldValue, Object newValue)
      Notifications that the display options changed.
      Parameters:
      options - the Display Options object that changed.
      optionName - the name of the property that changed.
      oldValue - the old value of the property.
      newValue - the new value of the property.
    • fieldOptionsChanged

      public void fieldOptionsChanged(Options options, String optionName, Object oldValue, Object newValue)
      Notifications that the field options changed.
      Parameters:
      options - the Field Options object that changed.
      optionName - the name of the property that changed.
      oldValue - the old value of the property.
      newValue - the new value of the property.
    • getFieldName

      public String getFieldName()
      Returns the Field name.
      Returns:
      the name.
    • getStartX

      public int getStartX()
      Returns the starting x position for the fields generated by this factory.
      Returns:
      the start x.
    • setStartX

      public void setStartX(int x)
      Sets the starting x position for the fields generated by this factory.
      Parameters:
      x - the x position.
    • getWidth

      public int getWidth()
      Returns the width of the fields generated by this factory.
      Returns:
      the width.
    • setWidth

      public void setWidth(int w)
      Sets the width of the fields generated by this factory.
      Parameters:
      w - the width.
    • getFieldModel

      public FieldFormatModel getFieldModel()
      Returns the FieldModel that this factory belongs to.
      Returns:
      the model.
    • isEnabled

      public boolean isEnabled()
      Returns true if this FieldFactory is currently enabled to generate Fields.
      Returns:
      true if enabled.
    • setEnabled

      public void setEnabled(boolean state)
      Turns on or off the generating of Fields by this FieldFactory.
      Parameters:
      state - if true, this factory will generate fields.
    • supportsLocation

      public boolean supportsLocation(ListingField listingField, ProgramLocation location)
      Returns true if this given field represents the given location
      Parameters:
      listingField - the field
      location - the location
      Returns:
      true if this given field represents the given location
    • getField

      public abstract ListingField getField(ProxyObj<?> obj, int varWidth)
      Generates a Field based on the given information.
      Parameters:
      obj - The object that the generated field will report some information about.
      varWidth - the additional distance along the x axis to place the generated field.
      Returns:
      the newly generated FactoryField that shows some property or information about the given object.
    • getFieldLocation

      public abstract FieldLocation getFieldLocation(ListingField bf, BigInteger index, int fieldNum, ProgramLocation loc)
      Return a FieldLocation that corresponds to the given index, fieldNum, and ProgramLocation IF and ONLY IF the given programLocation is the type generated by this class's getFieldLocation(ListingField, BigInteger, int, ProgramLocation). Each FieldFactory should generate and process a unique ProgramLocation class.
      Parameters:
      bf - the ListingField at the current cursor.
      index - the line index (corresponds to an address)
      fieldNum - the index of field within the layout to try and get a FieldLocation.
      loc - the ProgramLocation to be converted into a FieldLocation.
      Returns:
      the location.
    • getProgramLocation

      public abstract ProgramLocation getProgramLocation(int row, int col, ListingField bf)
      Returns the Program location for the given object, row, col, and groupPath
      Parameters:
      row - the row within this field
      col - the col on the given row within this field.
      bf - the ListingField containing the cursor.
      Returns:
      the location.
    • acceptsType

      public abstract boolean acceptsType(int category, Class<?> proxyObjectClass)
      Used to specify which format models this field can belong to.
      Parameters:
      category - the category for this field
      proxyObjectClass - the type of proxy object used by this field
      Returns:
      true if this class accepts the given category.
    • hasSamePath

      protected boolean hasSamePath(ListingField bf, ProgramLocation loc)
    • getFieldText

      public String getFieldText()
      Returns a description of the fields generated by this factory.
      Returns:
      the text.
    • getMetrics

      public FontMetrics getMetrics()
      Returns the font metrics used by this field factory
      Returns:
      the metrics.
    • getMetrics

      protected FontMetrics getMetrics(int fontStyle)
    • simplifyTemplates

      protected String simplifyTemplates(String input)