Class SizeRestrictedFilter

java.lang.Object
ghidra.program.model.lang.protorules.SizeRestrictedFilter
All Implemented Interfaces:
DatatypeFilter
Direct Known Subclasses:
HomogeneousAggregate, MetaTypeFilter

public class SizeRestrictedFilter extends Object implements DatatypeFilter
A common base class for data-type filters that tests for a size range. Any filter that inherits from this, can use ATTRIB_MINSIZE and ATTRIB_MAXSIZE to place bounds on the possible sizes of data-types. The bounds are enforced by calling filterOnSize() within the inheriting classes filter() method.
  • Field Details

    • NAME

      public static final String NAME
      See Also:
    • minSize

      protected int minSize
    • maxSize

      protected int maxSize
  • Constructor Details

    • SizeRestrictedFilter

      public SizeRestrictedFilter()
    • SizeRestrictedFilter

      public SizeRestrictedFilter(int min, int max)
  • Method Details

    • filterOnSize

      public boolean filterOnSize(DataType dt)
      Enforce any size bounds on a given data-type. If \b maxSize is not zero, the data-type is checked to see if its size in bytes falls between \b minSize and \b maxSize inclusive.
      Parameters:
      dt - is the data-type to test
      Returns:
      true if the data-type meets the size restrictions
    • clone

      public DatatypeFilter clone()
      Description copied from interface: DatatypeFilter
      Make a copy of this filter
      Specified by:
      clone in interface DatatypeFilter
      Overrides:
      clone in class Object
      Returns:
      the new copy
    • isEquivalent

      public boolean isEquivalent(DatatypeFilter op)
      Description copied from interface: DatatypeFilter
      Test if the given filter is configured and performs identically to this
      Specified by:
      isEquivalent in interface DatatypeFilter
      Parameters:
      op - is the given filter
      Returns:
      true if the two filters are equivalent
    • filter

      public boolean filter(DataType dt)
      Description copied from interface: DatatypeFilter
      Test whether the given data-type belongs to this filter's data-type class
      Specified by:
      filter in interface DatatypeFilter
      Parameters:
      dt - is the given data-type to test
      Returns:
      true if the data-type is in the class, false otherwise
    • encodeAttributes

      protected void encodeAttributes(Encoder encoder) throws IOException
      Throws:
      IOException
    • restoreAttributesXml

      protected void restoreAttributesXml(XmlElement el)
    • encode

      public void encode(Encoder encoder) throws IOException
      Description copied from interface: DatatypeFilter
      Encode this filter and its configuration to a stream
      Specified by:
      encode in interface DatatypeFilter
      Parameters:
      encoder - is the stream encoder
      Throws:
      IOException - for problems writing to the stream
    • restoreXml

      public void restoreXml(XmlPullParser parser) throws XmlParseException
      Description copied from interface: DatatypeFilter
      Configure details of the data-type class being filtered from the given stream
      Specified by:
      restoreXml in interface DatatypeFilter
      Parameters:
      parser - is the given stream decoder
      Throws:
      XmlParseException - if there are problems with the stream