Class BSimFilterType

java.lang.Object
ghidra.features.bsim.gui.filters.BSimFilterType
All Implemented Interfaces:
Comparable<BSimFilterType>
Direct Known Subclasses:
ArchitectureBSimFilterType, BlankBSimFilterType, CompilerBSimFilterType, DateBSimFilterType, ExecutableCategoryBSimFilterType, ExecutableNameBSimFilterType, FunctionTagBSimFilterType, HasNamedChildBSimFilterType, Md5BSimFilterType, NotArchitectureBSimFilterType, NotCompilerBSimFilterType, NotExecutableCategoryBSimFilterType, NotExecutableNameBSimFilterType, NotMd5BSimFilterType, PathStartsBSimFilterType

public abstract class BSimFilterType extends Object implements Comparable<BSimFilterType>
The base class for BSim filter types. Each filter type represents a different filter criteria that can be applied to a BSim Search query. They have a human readable description and a way to convert string values for the filter into SQL queries.
  • Field Details

  • Constructor Details

    • BSimFilterType

      public BSimFilterType(String label, String xmlval, String hint)
      Parameters:
      label - is the name used for display
      xmlval - is the name used for XML serialization
      hint - is the pop-up menu hint
  • Method Details

    • toString

      public String toString()
      Overrides:
      toString in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • compareTo

      public int compareTo(BSimFilterType op2)
      Specified by:
      compareTo in interface Comparable<BSimFilterType>
    • getXmlValue

      public String getXmlValue()
      Returns:
      the tag name for serialization
    • getHint

      public String getHint()
      Returns:
      the hint text
    • isChildFilter

      public boolean isChildFilter()
      Returns:
      true if this is a filter element based on callgraph information of functions
    • isBlank

      public boolean isBlank()
      Returns:
      true if this is a "blank" filter (i.e. an unused element within a gui)
    • isLocal

      public boolean isLocal()
      Returns:
      true if any id's relevant to this filter must be resolved relative to the local ColumnDatabase
    • isMultipleEntryAllowed

      public boolean isMultipleEntryAllowed()
      Returns:
      true if multiple filters of this type are allowed.
    • orMultipleEntries

      public boolean orMultipleEntries()
      Returns:
      true if multiple filters of this type should be OR'd. AND them otherwise.
    • saveXml

      public void saveXml(Writer fwrite) throws IOException
      Save XML attributes corresponding to this template
      Parameters:
      fwrite - is the output stream
      Throws:
      IOException - for problems writing to the stream
    • generateIDSQLResolution

      public abstract IDSQLResolution generateIDSQLResolution(FilterAtom atom)
      Construct a record describing the column id's that might need to be recovered before this filter element can be converted to an SQL clause
      Parameters:
      atom - is the specific FilterAtom to generate the record for
      Returns:
      the IDSQLResolution record or null if no ids need to be recovered
    • generateIDElasticResolution

      public IDElasticResolution generateIDElasticResolution(FilterAtom atom)
      Construct a record describing the document id's that might be needed before this filter element can be converted to an Elasticsearch filter script clause
      Parameters:
      atom - is the specific FilterAtom to generate the record for
      Returns:
      the record or null if no ids need to be recovered
    • gatherSQLEffect

      public abstract void gatherSQLEffect(SQLEffects effect, FilterAtom atom, IDSQLResolution resolution) throws SQLException
      Gather all pieces to successfully convert this filter element into an SQL clause
      Parameters:
      effect - is SQLEffects container for this filter elements pieces and others
      atom - holds the values for a particular instantiation of this filter element
      resolution - is the IDResolution containing relevant row ids for the filter, which must have been precalculated
      Throws:
      SQLException - for errors building the SQL clause
    • gatherElasticEffect

      public abstract void gatherElasticEffect(ElasticEffects effect, FilterAtom atom, IDElasticResolution resolution) throws ElasticException
      Gather pieces necessary to emit this filter as part of an elasticsearch query document
      Parameters:
      effect - is the ElasticEffects container holding the pieces
      atom - holds the values for a particular instantiation of this filter element
      resolution - contains relevant ids for the filter, which must have been precalculated
      Throws:
      ElasticException - for errors building the JSON subdocument
    • buildSQLCombinedClause

      public String buildSQLCombinedClause(List<String> subClauses)
      Given (multiple) clauses for a single filter type, combine into a single SQL where clause
      Parameters:
      subClauses - is the list of SQL clauses
      Returns:
      the combined clause
    • buildElasticCombinedClause

      public String buildElasticCombinedClause(List<String> subClauses)
      Given (multiple) clauses for a single filter type, combine into a single elasticsearch script conditional
      Parameters:
      subClauses - is the list of script clauses
      Returns:
      the combined clause
    • getEditor

      public BSimValueEditor getEditor(List<String> initialValues, Callback listener)
    • evaluate

      public abstract boolean evaluate(ExecutableRecord rec, String value)
      Evaluate this filter for a specific ExecutableRecord and a specific filter -value-
      Parameters:
      rec - is the ExecutableRecord to filter against
      value - is the String value for an instantiated filter
      Returns:
      true if this element would allow the ExecutableRecord to pass the filter
    • isValidValue

      public boolean isValidValue(String value)
      Tests if the given string is a valid value for this filter type.
      Parameters:
      value - the value to test
      Returns:
      true if the given string is valid for this filter
    • normalizeValue

      public String normalizeValue(String value)
      Returns a normalized version of the given value for this filter.
      Parameters:
      value - the value to be normalized
      Returns:
      a normalized version of the given value for this filter
    • getBlank

      public static BSimFilterType getBlank()
      Returns:
      the Blank FilterTemplate
    • getBaseFilters

      public static List<BSimFilterType> getBaseFilters()
    • nameToType

      public static BSimFilterType nameToType(XmlElement el)
      Convenience function for deserializing FilterTemplates
      Parameters:
      el - is the tag to deserialize
      Returns:
      the deserialized FilterTemplate
    • generateBsimFilters

      public static List<BSimFilterType> generateBsimFilters(DatabaseInformation info, boolean includeChildFilter)
      Generate a possibly restricted/extended set of FilterTemplates
      Parameters:
      info - is database information which informs about which filters to create
      includeChildFilter - toggles whether or not ChildFilters should be included in this particular set
      Returns:
      the list of filter templates
    • getLabel

      public String getLabel()