edu.umd.cs.findbugs.ba.interproc

Class PropertyDatabase<KeyType,ValueType>

public abstract class PropertyDatabase<KeyType extends ClassMember,ValueType> extends Object

Property database for interprocedural analysis.

Parameters: key type: either XMethod or XField value type: a value that summarizes some property of the associated key

Author: David Hovemeyer

Constructor Summary
protected PropertyDatabase()
Constructor.
Method Summary
protected abstract ValueTypedecodeProperty(String propStr)
Subclasses must define this to instantiate the actual property value from its string encoding.
protected abstract StringencodeProperty(ValueType property)
Subclasses must define this to encode a property as a string for output to a file.
Set<KeyType>getKeys()
ValueTypegetProperty(KeyType key)
Get a property.
booleanisEmpty()
Return whether or not the database is empty.
protected abstract KeyTypeparseKey(String s)
Parse a key from a String.
voidread(InputStream in)
Read property database from an input stream.
voidreadFromFile(String fileName)
Read property database from given file.
ValueTyperemoveProperty(KeyType key)
Remove a property.
voidsetProperty(KeyType key, ValueType property)
Set a property.
voidwrite(OutputStream out)
Write property database to an OutputStream.
protected abstract voidwriteKey(Writer writer, KeyType key)
Write an encoded key to given Writer.
voidwriteToFile(String fileName)
Write property database to given file.

Constructor Detail

PropertyDatabase

protected PropertyDatabase()
Constructor. Creates an empty property database.

Method Detail

decodeProperty

protected abstract ValueType decodeProperty(String propStr)
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: MethodPropertyDatabaseFormatException

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

getKeys

public Set<KeyType> getKeys()

getProperty

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

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

parseKey

protected abstract KeyType parseKey(String s)
Parse a key from a String.

Parameters: s a String

Returns: the decoded key

Throws: PropertyDatabaseFormatException

read

public void read(InputStream in)
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 MethodPropertyDatabaseFormatException

readFromFile

public void readFromFile(String fileName)
Read property database from given file.

Parameters: fileName name of the database file

Throws: IOException MethodPropertyDatabaseFormatException

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

setProperty

public void setProperty(KeyType key, ValueType property)
Set a property.

Parameters: key the key property the property

write

public void write(OutputStream out)
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

writeKey

protected abstract void writeKey(Writer writer, KeyType key)
Write an encoded key to given Writer.

Parameters: writer the Writer key the key

writeToFile

public void writeToFile(String fileName)
Write property database to given file.

Parameters: fileName name of the database file

Throws: IOException

FindBugs™ is licenced under the LGPL. Copyright © 2006 University of Maryland.