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 base class for data-type filters that tests either for either a range or an enumerated list of sizes. Any filter that inherits from this, can use ATTRIB_MINSIZE, ATTRIB_MAXSIZE, or ATTRIB_SIZES 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

  • Constructor Details

    • SizeRestrictedFilter

      public SizeRestrictedFilter()
    • SizeRestrictedFilter

      public SizeRestrictedFilter(int min, int max)
    • SizeRestrictedFilter

      public SizeRestrictedFilter(SizeRestrictedFilter op2)
      Copy constructor
      Parameters:
      op2 - is the filter to copy
  • Method Details

    • initFromSizeList

      protected void initFromSizeList(String str) throws XmlParseException
      Parse the given string as a comma or space separated list of decimal integers, populating the sizes set.
      Parameters:
      str - is the given string to parse
      Throws:
      XmlParseException - if the string does not valid (positive) integers
    • 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. If enumerated sizes are present, also check that the particular size is in the enumerated set.
      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) throws XmlParseException
      Throws:
      XmlParseException
    • 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