org.e2etrace.trace
Class AbstractTraceStep

java.lang.Object
  extended by org.e2etrace.trace.AbstractTraceStep
All Implemented Interfaces:
Serializable, ITraceStep
Direct Known Subclasses:
DefaultTraceStep, TraceSessionRootStep

public abstract class AbstractTraceStep
extends Object
implements ITraceStep, Serializable

Abstract base class for trace steps.

All custom trace step implementation must inherit from this class.

Author:
Gunther Popp
See Also:
Serialized Form

Field Summary
protected  List children
           
 
Constructor Summary
AbstractTraceStep(ITraceStepId id)
          Constructor.
 
Method Summary
 void addChild(ITraceStep child)
          Adds a new child to this trace step.
abstract  void enter()
          Enter the trace step and start time measuring.
 boolean equals(Object o)
          
 ITraceStep[] getChildren()
          Returns the list of children for this trace steps.
abstract  long getDuration()
          Returns the duration of this TraceStep and all children.
 ITraceStepId getId()
          Return the id of the trace step.
abstract  long getIsolatedDuration()
          Returns the isolated duration of this TraceStep.
 ITraceStep getParent()
          Returns the parent of a TraceStep, if any exists.
 int hashCode()
          
abstract  boolean isActive()
          Checks, if the current trace step is active.
abstract  void leave()
          Leave the trace step and calculate the elapsed time since enter has been called.
protected  void leaveAllChildren()
          Invokes leave() on all children of this trace step.
 void setParent(ITraceStep parent)
          Set the parent of a TraceStep.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

children

protected List children
Constructor Detail

AbstractTraceStep

public AbstractTraceStep(ITraceStepId id)
Constructor.

Parameters:
id - Id of the new trace step
Method Detail

getId

public ITraceStepId getId()
Return the id of the trace step.

Specified by:
getId in interface ITraceStep
Returns:
trace step id

addChild

public void addChild(ITraceStep child)
Adds a new child to this trace step.

The implementation must make sure that the child receives a references to this trace step. This reference must be returned by getParent().

Specified by:
addChild in interface ITraceStep
Parameters:
child - trace step to add as child

getChildren

public ITraceStep[] getChildren()
Returns the list of children for this trace steps.

Specified by:
getChildren in interface ITraceStep
Returns:
Array containing the children

getParent

public ITraceStep getParent()
Returns the parent of a TraceStep, if any exists.

Specified by:
getParent in interface ITraceStep
Returns:
Parent trace step

setParent

public void setParent(ITraceStep parent)
Set the parent of a TraceStep.

This method is invoked when a new child is added using addChild(). It should never be called manually.

Specified by:
setParent in interface ITraceStep
Parameters:
parent - new parent of the child.

hashCode

public int hashCode()

Overrides:
hashCode in class Object

equals

public boolean equals(Object o)

Overrides:
equals in class Object

enter

public abstract void enter()
                    throws IllegalStateException
Enter the trace step and start time measuring.

This method should only be called once for a trace step. All subsequent calls will be ignored.

Specified by:
enter in interface ITraceStep
Throws:
IllegalStateException

getDuration

public abstract long getDuration()
Returns the duration of this TraceStep and all children.

This value reflects the overall execution time of a trace step between the calls to enter and leave inclusive the durations of all children.

Specified by:
getDuration in interface ITraceStep
Returns:
accumulated duration in ms

getIsolatedDuration

public abstract long getIsolatedDuration()
Returns the isolated duration of this TraceStep.

The duration is the time elapsed between the calls to enter and leave minus the durations of all children.

Specified by:
getIsolatedDuration in interface ITraceStep
Returns:
duration of this TraceStep in ms (-1: no valid duration exists for this trace step)

isActive

public abstract boolean isActive()
Checks, if the current trace step is active.

A step is active between the calls to enter and leave.

Specified by:
isActive in interface ITraceStep
Returns:
true: The trace step is active.

leave

public abstract void leave()
                    throws IllegalStateException
Leave the trace step and calculate the elapsed time since enter has been called. The elapsed time is returned by getDuration().

Leaving a step implies that all children are left, too.

This method should only be called once for a trace step. All subsequent calls will be ignored.

Specified by:
leave in interface ITraceStep
Throws:
IllegalStateException

leaveAllChildren

protected void leaveAllChildren()
Invokes leave() on all children of this trace step.



Copyright © 2013 Gunther Popp. All Rights Reserved.