Package edu.umd.cs.findbugs.ba.interproc
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 FieldDescriptorValueType- 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 java.lang.ObjectProperty database for interprocedural analysis.- Author:
- David Hovemeyer
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedPropertyDatabase()Constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract ValueTypedecodeProperty(java.lang.String propStr)Subclasses must define this to instantiate the actual property value from its string encoding.protected abstract java.lang.StringencodeProperty(ValueType property)Subclasses must define this to encode a property as a string for output to a file.java.util.Collection<java.util.Map.Entry<KeyType,ValueType>>entrySet()java.util.Set<KeyType>getKeys()ValueTypegetProperty(KeyType key)Get a property.booleanisEmpty()Return whether or not the database is empty.protected abstract KeyTypeparseKey(java.lang.String s)Parse a key from a String.voidread(java.io.InputStream in)Read property database from an input stream.voidreadFromFile(java.lang.String fileName)Read property database from given file.ValueTyperemoveProperty(KeyType key)Remove a property.voidsetProperty(KeyType key, ValueType property)Set a property.voidwrite(java.io.OutputStream out)Write property database to an OutputStream.protected abstract voidwriteKey(java.io.Writer writer, KeyType key)Write an encoded key to given Writer.voidwriteToFile(java.lang.String fileName)Write property database to given file.
-
-
-
Method Detail
-
setProperty
public void setProperty(KeyType key, ValueType property)
Set a property.- Parameters:
key- the keyproperty- 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 java.util.Set<KeyType> getKeys()
-
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(java.lang.String fileName) throws java.io.IOException, PropertyDatabaseFormatExceptionRead property database from given file.- Parameters:
fileName- name of the database file- Throws:
java.io.IOExceptionPropertyDatabaseFormatException
-
read
public void read(@WillClose java.io.InputStream in) throws java.io.IOException, PropertyDatabaseFormatExceptionRead property database from an input stream. The InputStream is guaranteed to be closed, even if an exception is thrown.- Parameters:
in- the InputStream- Throws:
java.io.IOExceptionPropertyDatabaseFormatException
-
writeToFile
public void writeToFile(java.lang.String fileName) throws java.io.IOExceptionWrite property database to given file.- Parameters:
fileName- name of the database file- Throws:
java.io.IOException
-
write
public void write(@WillClose java.io.OutputStream out) throws java.io.IOExceptionWrite property database to an OutputStream. The OutputStream is guaranteed to be closed, even if an exception is thrown.- Parameters:
out- the OutputStream- Throws:
java.io.IOException
-
parseKey
protected abstract KeyType parseKey(java.lang.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(java.io.Writer writer, KeyType key) throws java.io.IOExceptionWrite an encoded key to given Writer.- Parameters:
writer- the Writerkey- the key- Throws:
java.io.IOException
-
decodeProperty
protected abstract ValueType decodeProperty(java.lang.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 java.lang.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
-
-