com.bluemarsh.jswat.breakpoint
Class DefaultBreakpoint

java.lang.Object
  |
  +--com.bluemarsh.jswat.breakpoint.DefaultBreakpoint
All Implemented Interfaces:
Breakpoint, java.io.Serializable
Direct Known Subclasses:
ResolvableBreakpoint

public abstract class DefaultBreakpoint
extends java.lang.Object
implements Breakpoint

Defines the default breakpoint class. This class implements most of the default behavior for all breakpoints.

Author:
Nathan Fiedler
See Also:
Serialized Form

Field Summary
protected  BreakpointGroup breakpointGroup
          Breakpoint group that contains us (always non-null).
protected  java.util.List conditionList
          List of conditions this breakpoint depends on.
protected  boolean deleteOnExpire
          True if the breakpoint should be deleted on expiration.
protected  int expireCount
          Number of times this breakpoint can be hit before it expires.
protected  boolean isEnabled
          True if this breakpoint is enabled.
protected  java.util.List monitorList
          List of monitors this breakpoint executes when it stops.
protected  java.util.Hashtable propertyList
          Table of named properties stored in this breakpoint.
protected  int skipCount
          Number of times this breakpoint will be hit before it stops.
protected  int stoppedCount
          Number of times this breakpoint has stopped.
protected  int suspendPolicy
          The thread suspension policy for this request.
 
Fields inherited from interface com.bluemarsh.jswat.breakpoint.Breakpoint
serialVersionUID
 
Constructor Summary
DefaultBreakpoint()
          Creates a DefaultBreakpoint with the default parameters.
 
Method Summary
 void addCondition(Condition condition)
          Add the given condition to this breakpoint.
 void addMonitor(Monitor monitor)
          Add the given monitor to this breakpoint.
 java.util.ListIterator conditions()
          Returns an iterator of the conditions associated with this breakpoint.
 void deleteOnExpire()
          Ensures that this breakpoint will be deleted when it has expired.
 void destroy()
          Tear down this breakpoint in preparation for deletion.
 com.sun.jdi.request.EventRequest eventRequest()
          Returns the event request for this breakpoint, if the breakpoint has been resolved.
protected  void fireChange()
          Notify breakpoint listeners that this breakpoint has changed.
 BreakpointGroup getBreakpointGroup()
          Gets the breakpoint group to which this breakpoint belongs.
protected  BreakpointManager getBreakpointManager()
          Acquires the breakpoint manager instance.
 int getExpireCount()
          Return the number of times this breakpoint can be hit before it expires and no longer stops.
 java.lang.Object getProperty(java.lang.String key)
          Retrieves the named property.
 int getSkipCount()
          Return the number of times this breakpoint can be hit before it starts stopping the debuggee VM.
 int getSuspendPolicy()
          Retrieve the suspend policy for this breakpoint.
abstract  BreakpointUI getUIAdapter()
          Returns the user interface widget for customizing this breakpoint.
 boolean hasExpired()
          Returns true if the breakpoint has expired and will no longer cause execution to halt.
protected  void incrementStoppedCount()
          Increments the stoppedCount value and sends out notifications that the breakpoint has been modified.
 void init()
          Initialize the breakpoint so it may operate normally.
 boolean isEnabled()
          Returns true if and only if the breakpoint is enabled and the group containing this breakpoint is also enabled.
abstract  boolean isResolved()
          Returns true if the breakpoint has been resolved against the intended object in the debuggee VM.
 boolean isSkipping()
          Returns true if this breakpoint is currently skipping.
 java.util.ListIterator monitors()
          Returns an iterator of the monitors associated with this breakpoint.
protected  void performStop(com.sun.jdi.event.Event e)
          This breakpoint has caused the debuggee VM to stop.
 void removeCondition(Condition condition)
          Remove the given condition from this breakpoint.
 void removeMonitor(Monitor monitor)
          Remove the given monitor from this breakpoint.
 void reset()
          Reset the stopped count to zero and clear any other attributes such that this breakpoint can be used again for a new session.
 void setBreakpointGroup(BreakpointGroup group)
          Sets the breakpoint group to which this breakpoint will belong.
 void setEnabled(boolean enabled)
          Enables or disables this breakpoint, according to the parameter.
 void setExpireCount(int expireCount)
          Set the number of times this breakpoint can be hit before it expires and no longer stops.
 void setProperty(java.lang.String key, java.lang.Object value)
          Stores a named property in this breakpoint.
 void setSkipCount(int skipCount)
          Set the number of times this breakpoint can be hit before it starts stopping the debuggee VM.
 void setSuspendPolicy(int policy)
          Set the suspend policy for the request.
protected  boolean shouldResume(com.sun.jdi.event.Event event)
          Determines if this breakpoint is to halt execution.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.bluemarsh.jswat.breakpoint.Breakpoint
toString
 

Field Detail

suspendPolicy

protected int suspendPolicy
The thread suspension policy for this request. Must be one of the com.sun.jdi.request.EventRequest suspend constants. Defaults to SUSPEND_ALL.

isEnabled

protected boolean isEnabled
True if this breakpoint is enabled.

breakpointGroup

protected BreakpointGroup breakpointGroup
Breakpoint group that contains us (always non-null).

stoppedCount

protected int stoppedCount
Number of times this breakpoint has stopped.

expireCount

protected int expireCount
Number of times this breakpoint can be hit before it expires. If value is zero, breakpoint will not expire.

skipCount

protected int skipCount
Number of times this breakpoint will be hit before it stops. If value is zero, breakpoint will not skip.

conditionList

protected java.util.List conditionList
List of conditions this breakpoint depends on.

monitorList

protected java.util.List monitorList
List of monitors this breakpoint executes when it stops.

propertyList

protected java.util.Hashtable propertyList
Table of named properties stored in this breakpoint.

deleteOnExpire

protected boolean deleteOnExpire
True if the breakpoint should be deleted on expiration.
Constructor Detail

DefaultBreakpoint

public DefaultBreakpoint()
Creates a DefaultBreakpoint with the default parameters.
Method Detail

addCondition

public void addCondition(Condition condition)
Add the given condition to this breakpoint. That is, when the shouldStop() method is called, this breakpoint should check if this condition is satisfied or not.
Specified by:
addCondition in interface Breakpoint
Parameters:
condition - condition for this breakpoint to stop.

addMonitor

public void addMonitor(Monitor monitor)
Add the given monitor to this breakpoint. That is, when the stopped() method is called, this breakpoint will execute this monitor.
Specified by:
addMonitor in interface Breakpoint
Parameters:
monitor - monitor for this breakpoint to execute.

conditions

public java.util.ListIterator conditions()
Returns an iterator of the conditions associated with this breakpoint.
Specified by:
conditions in interface Breakpoint
Returns:
ListIterator of Condition objects.

deleteOnExpire

public void deleteOnExpire()
Ensures that this breakpoint will be deleted when it has expired.
Specified by:
deleteOnExpire in interface Breakpoint

destroy

public void destroy()
Tear down this breakpoint in preparation for deletion.
Specified by:
destroy in interface Breakpoint

eventRequest

public com.sun.jdi.request.EventRequest eventRequest()
Returns the event request for this breakpoint, if the breakpoint has been resolved.
Specified by:
eventRequest in interface Breakpoint
Returns:
breakpoint's event request, or null if unresolved.

fireChange

protected void fireChange()
Notify breakpoint listeners that this breakpoint has changed.

getBreakpointGroup

public BreakpointGroup getBreakpointGroup()
Gets the breakpoint group to which this breakpoint belongs.
Specified by:
getBreakpointGroup in interface Breakpoint
Returns:
parent breakpoint group, always non-null.
See Also:
setBreakpointGroup(com.bluemarsh.jswat.breakpoint.BreakpointGroup)

getBreakpointManager

protected BreakpointManager getBreakpointManager()
Acquires the breakpoint manager instance.
Returns:
the breakpoint manager instance for this session.

getExpireCount

public int getExpireCount()
Return the number of times this breakpoint can be hit before it expires and no longer stops.
Specified by:
getExpireCount in interface Breakpoint
Returns:
number of times this breakpoint can be hit before it expires; zero means it will never expire.

getProperty

public java.lang.Object getProperty(java.lang.String key)
Retrieves the named property.
Specified by:
getProperty in interface Breakpoint
Parameters:
key - name of property to retrieve.
Returns:
Property, or null if none found.

getSkipCount

public int getSkipCount()
Return the number of times this breakpoint can be hit before it starts stopping the debuggee VM. That is, the breakpoint will be hit N times before it stops.
Specified by:
getSkipCount in interface Breakpoint
Returns:
number of times this breakpoint will be hit before it stops; zero means it will not skip.

getSuspendPolicy

public int getSuspendPolicy()
Retrieve the suspend policy for this breakpoint. The returned value will be one of the com.sun.jdi.request.EventRequest constants for suspending threads.
Specified by:
getSuspendPolicy in interface Breakpoint
Returns:
suspend policy, one of the EventRequest suspend constants.
See Also:
setSuspendPolicy(int)

getUIAdapter

public abstract BreakpointUI getUIAdapter()
Returns the user interface widget for customizing this breakpoint.
Specified by:
getUIAdapter in interface Breakpoint
Returns:
Breakpoint user interface adapter.

hasExpired

public boolean hasExpired()
Returns true if the breakpoint has expired and will no longer cause execution to halt.
Specified by:
hasExpired in interface Breakpoint
Returns:
true if this breakpoint has expired, false otherwise.

incrementStoppedCount

protected void incrementStoppedCount()
Increments the stoppedCount value and sends out notifications that the breakpoint has been modified. This is important for breakpoint listeners so they will notice if the breakpoint stops skipping or starts being expired.

init

public void init()
Initialize the breakpoint so it may operate normally.
Specified by:
init in interface Breakpoint

isEnabled

public boolean isEnabled()
Returns true if and only if the breakpoint is enabled and the group containing this breakpoint is also enabled.
Specified by:
isEnabled in interface Breakpoint
Returns:
true if this breakpoint is enabled, false otherwise.
See Also:
setEnabled(boolean)

isResolved

public abstract boolean isResolved()
Returns true if the breakpoint has been resolved against the intended object in the debuggee VM. How a breakpoint resolves itself depends on the type of the breakpoint.
Specified by:
isResolved in interface Breakpoint
Returns:
true if this breakpoint has resolved, false otherwise.

isSkipping

public boolean isSkipping()
Returns true if this breakpoint is currently skipping. That is, the skipCount is greater than zero and the stoppedCount is less than the skipCount.
Specified by:
isSkipping in interface Breakpoint
Returns:
true if the breakpoint is skipping hits.

monitors

public java.util.ListIterator monitors()
Returns an iterator of the monitors associated with this breakpoint.
Specified by:
monitors in interface Breakpoint
Returns:
ListIterator of Monitor objects.

performStop

protected void performStop(com.sun.jdi.event.Event e)
This breakpoint has caused the debuggee VM to stop. Execute all monitors associated with this breakpoint. If the breakpoint is locatable, perform the usual operations that go along with a locatable event.
Parameters:
e - Event for which we are stopping.

removeCondition

public void removeCondition(Condition condition)
Remove the given condition from this breakpoint. This condition should no longer be associated with this breakpoint. If the condition is not a part of this breakpoint, nothing happens.
Specified by:
removeCondition in interface Breakpoint
Parameters:
condition - condition to remove from this breakpoint.

removeMonitor

public void removeMonitor(Monitor monitor)
Remove the given monitor from this breakpoint. This monitor should no longer be associated with this breakpoint. If the monitor is not a part of this breakpoint, nothing happens.
Specified by:
removeMonitor in interface Breakpoint
Parameters:
monitor - monitor to remove from this breakpoint.

reset

public void reset()
Reset the stopped count to zero and clear any other attributes such that this breakpoint can be used again for a new session. This does not change the enabled-ness of the breakpoint.
Specified by:
reset in interface Breakpoint

setBreakpointGroup

public void setBreakpointGroup(BreakpointGroup group)
Sets the breakpoint group to which this breakpoint will belong.
Specified by:
setBreakpointGroup in interface Breakpoint
Parameters:
group - new parent breakpoint group.
See Also:
getBreakpointGroup()

setEnabled

public void setEnabled(boolean enabled)
Enables or disables this breakpoint, according to the parameter. This only affects the breakpint itself. If the breakpoint group containing this breakpoint is disabled, this breakpoint will remain effectively disabled.
Specified by:
setEnabled in interface Breakpoint
Parameters:
enabled - true if breakpoint should be enabled, false if breakpoint should be disabled.
See Also:
isEnabled

setExpireCount

public void setExpireCount(int expireCount)
Set the number of times this breakpoint can be hit before it expires and no longer stops.
Specified by:
setExpireCount in interface Breakpoint
Parameters:
expireCount - number of times this breakpoint can be hit before it expires; zero to never expire

setProperty

public void setProperty(java.lang.String key,
                        java.lang.Object value)
Stores a named property in this breakpoint.
Specified by:
setProperty in interface Breakpoint
Parameters:
key - name of property to set.
value - value of property.

setSkipCount

public void setSkipCount(int skipCount)
Set the number of times this breakpoint can be hit before it starts stopping the debuggee VM. That is, the breakpoint will be hit skipCount times before it stops.
Specified by:
setSkipCount in interface Breakpoint
Parameters:
skipCount - number of times this breakpoint will be hit before it stops; zero to disable skipping

setSuspendPolicy

public void setSuspendPolicy(int policy)
Set the suspend policy for the request. Use one of the com.sun.jdi.request.EventRequest constants for suspending threads.
Specified by:
setSuspendPolicy in interface Breakpoint
Parameters:
policy - one of the EventRequest suspend constants.
See Also:
getSuspendPolicy()

shouldResume

protected boolean shouldResume(com.sun.jdi.event.Event event)
Determines if this breakpoint is to halt execution. Technically execution has already stopped. This method simply indicates whether the debuggee VM should be resumed or not. This method must take into consideration whether this breakpoint is enabled and has not already expired.
Parameters:
event - JDI Event that brought us here.
Returns:
true if debuggee VM should resume, false otherwise.