Class PropertyDatabase<KeyType extends FieldOrMethodDescriptor,ValueType>

java.lang.Object
edu.umd.cs.findbugs.ba.interproc.PropertyDatabase<KeyType,ValueType>
Type Parameters:
KeyType - key type: either MethodDescriptor or FieldDescriptor
ValueType - value type: a value that summarizes some property of the associated key
Direct Known Subclasses:
FieldPropertyDatabase, MethodPropertyDatabase

public abstract class PropertyDatabase<KeyType extends FieldOrMethodDescriptor,ValueType> extends Object
Property database for interprocedural analysis.
Author:
David Hovemeyer
  • Constructor Details

    • PropertyDatabase

      protected PropertyDatabase()
      Constructor. Creates an empty property database.
  • Method Details

    • setProperty

      public void setProperty(KeyType key, ValueType property)
      Set a property.
      Parameters:
      key - the key
      property - the property
    • getProperty

      @CheckForNull public ValueType getProperty(KeyType key)
      Get a property.
      Parameters:
      key - the key
      Returns:
      the property, or null if no property is set for this key
    • getKeys

      public Set<KeyType> getKeys()
    • entrySet

      public Collection<Map.Entry<KeyType,ValueType>> entrySet()
    • isEmpty

      public boolean isEmpty()
      Return whether or not the database is empty.
      Returns:
      true if the database is empty, false it it has at least one entry
    • removeProperty

      public ValueType removeProperty(KeyType key)
      Remove a property.
      Parameters:
      key - the key
      Returns:
      the old property, or null if there was no property defined for this key
    • readFromFile

      public void readFromFile(String fileName) throws IOException, PropertyDatabaseFormatException
      Read property database from given file.
      Parameters:
      fileName - name of the database file
      Throws:
      IOException
      PropertyDatabaseFormatException
    • read

      public void read(@WillClose InputStream in) throws IOException, PropertyDatabaseFormatException
      Read property database from an input stream. The InputStream is guaranteed to be closed, even if an exception is thrown.
      Parameters:
      in - the InputStream
      Throws:
      IOException
      PropertyDatabaseFormatException
    • writeToFile

      public void writeToFile(String fileName) throws IOException
      Write property database to given file.
      Parameters:
      fileName - name of the database file
      Throws:
      IOException
    • write

      public void write(@WillClose OutputStream out) throws IOException
      Write property database to an OutputStream. The OutputStream is guaranteed to be closed, even if an exception is thrown.
      Parameters:
      out - the OutputStream
      Throws:
      IOException
    • parseKey

      protected abstract KeyType parseKey(String s) throws PropertyDatabaseFormatException
      Parse a key from a String.
      Parameters:
      s - a String
      Returns:
      the decoded key
      Throws:
      PropertyDatabaseFormatException
    • writeKey

      protected abstract void writeKey(Writer writer, KeyType key) throws IOException
      Write an encoded key to given Writer.
      Parameters:
      writer - the Writer
      key - the key
      Throws:
      IOException
    • decodeProperty

      protected abstract ValueType decodeProperty(String propStr) throws PropertyDatabaseFormatException
      Subclasses must define this to instantiate the actual property value from its string encoding.
      Parameters:
      propStr - String containing the encoded property
      Returns:
      the property
      Throws:
      PropertyDatabaseFormatException
    • encodeProperty

      protected abstract String encodeProperty(ValueType property)
      Subclasses must define this to encode a property as a string for output to a file.
      Parameters:
      property - the property
      Returns:
      a String which encodes the property