edu.umd.cs.findbugs.ba.obl

Class StateSet

public class StateSet extends Object

A dataflow fact used in ObligationAnalysis. It is a set of State objects, plus the additional capability to represent top and bottom elements.

Invariant: no StateSet may contain more than one State with the same ObligationSet.

See Weimer and Necula, Finding and preventing run-time error handling mistakes, OOPSLA 2004.

Author: David Hovemeyer

Nested Class Summary
interfaceStateSet.StateCallback
Constructor Summary
StateSet(ObligationFactory factory)
Method Summary
voidaddObligation(Obligation obligation)
Add an obligation to every State in the StateSet.
voidapplyToAllStates(StateSet.StateCallback callback)
Apply a callback to all States in the StateSet.
voidapplyToAllStatesAndUpdateMap(StateSet.StateCallback callback, Map<ObligationSet,State> updatedStateMap)
Apply a callback to all States and replace the ObligationSet -> State map with the one given (which is assumed to be updated by the callback.)
voidcopyFrom(StateSet other)
Make this StateSet an exact copy of the given StateSet.
Map<ObligationSet,State>createEmptyMap()
Return a newly allocated Map of ObligationSet to State that may be passed to applyToAllStatesAndUpdateMap().
voiddeleteObligation(Obligation obligation)
Remove an Obligation from every State in the StateSet.
StateSetduplicate()
Return an exact deep copy of this StateSet.
StategetStateWithObligationSet(ObligationSet obligationSet)
Get the State which has the given ObligationSet.
voidinitEntryFact(ObligationFactory factory)
Initialize this object as the entry fact for a method: a single state with empty obligation set and path.
booleanisBottom()
booleanisTop()
booleanisValid()
voidsetBottom()
voidsetTop()
Iterator<State>stateIterator()
Return an Iterator over the States in the StateSet.

Constructor Detail

StateSet

public StateSet(ObligationFactory factory)

Method Detail

addObligation

public void addObligation(Obligation obligation)
Add an obligation to every State in the StateSet.

Parameters: obligation the obligation to add

applyToAllStates

public void applyToAllStates(StateSet.StateCallback callback)
Apply a callback to all States in the StateSet.

Parameters: callback

applyToAllStatesAndUpdateMap

public void applyToAllStatesAndUpdateMap(StateSet.StateCallback callback, Map<ObligationSet,State> updatedStateMap)
Apply a callback to all States and replace the ObligationSet -> State map with the one given (which is assumed to be updated by the callback.)

Parameters: callback the callback updatedStateMap updated map of ObligationSets to States

copyFrom

public void copyFrom(StateSet other)
Make this StateSet an exact copy of the given StateSet.

Parameters: other a StateSet; this StateSet will be made identical to it

createEmptyMap

public Map<ObligationSet,State> createEmptyMap()
Return a newly allocated Map of ObligationSet to State that may be passed to applyToAllStatesAndUpdateMap().

deleteObligation

public void deleteObligation(Obligation obligation)
Remove an Obligation from every State in the StateSet.

Parameters: obligation the obligation to remove

Throws: NonexistentObligationException

duplicate

public StateSet duplicate()
Return an exact deep copy of this StateSet.

Returns: an exact deep copy of this StateSet

getStateWithObligationSet

public State getStateWithObligationSet(ObligationSet obligationSet)
Get the State which has the given ObligationSet. Returns null if there is no such state.

Parameters: obligationSet we want to get the State with this ObligationSet

Returns: the State with the given ObligationSet, or null if there is no such State

initEntryFact

public void initEntryFact(ObligationFactory factory)
Initialize this object as the entry fact for a method: a single state with empty obligation set and path.

Parameters: factory the ObligationFactory used for the analysis

isBottom

public boolean isBottom()

isTop

public boolean isTop()

isValid

public boolean isValid()

setBottom

public void setBottom()

setTop

public void setTop()

stateIterator

public Iterator<State> stateIterator()
Return an Iterator over the States in the StateSet.

Returns: an Iterator over the States in the StateSet

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