edu.mit.ai.psg.traveler
Class ActivityRecordBase

java.lang.Object
  |
  +--edu.mit.ai.psg.traveler.ActivityRecordBase
Direct Known Subclasses:
ActivityRecordObservableBase, StringRecord, SynchronizationRecordDefault, SynchronizationRecordDefault.Entry, SynchronizationRecordDefault.Exit, SynchronizedRecordDefault

public abstract class ActivityRecordBase
extends Object
implements ActivityRecord

Base class for records of hierarchical activities with at most one parent and zero or more child subactivities. Derived classes must implement toString() so they can be displayed readably.


Field Summary
protected  ActivityRecord parent
           
 
Constructor Summary
ActivityRecordBase()
           
 
Method Summary
 void addChild(ActivityRecord child)
          add child to this parent's children, and set child's parent to this
 void addThreadedChild(ActivityRecord childInOwnThread)
          add child activity which is running in another thread
protected static Object cloneObject(Object target)
          Utility method to clone an object (if it is cloneable) to record its state.
protected static List ensureListValue(List list)
          if list is null, returns Collections.EMPTY_LIST, else returns list
 void finished()
          Trims child list (or sets to null if empty).
 Collection getChildren()
           
 List getChildrenInThread()
           
 ActivityRecord getParent()
           
protected  Object getProperty(Object key)
           
 Collection getThreadedChildren()
           
 boolean isFinished()
          true if recording this record has finished for thread that created record; additions may still be made by other threads (e.g., #addThreadChild).
protected  Object putProperty(Object key, Object value)
          key should be a unique object not likely to be used by other classes.
protected  Object removeProperty(Object key)
           
 void setParent(ActivityRecord record)
          called by addChild
abstract  String toString()
          subclasses must provide a print string
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

parent

protected ActivityRecord parent
Constructor Detail

ActivityRecordBase

public ActivityRecordBase()
Method Detail

getParent

public ActivityRecord getParent()
Specified by:
getParent in interface ActivityRecord
Tags copied from interface: ActivityRecord
Returns:
record of enclosing recorded activity, or null if none. Parent may be indirect caller if intermediate activities are not recorded.

setParent

public void setParent(ActivityRecord record)
Description copied from interface: ActivityRecord
called by addChild
Specified by:
setParent in interface ActivityRecord

finished

public void finished()
Trims child list (or sets to null if empty).
Specified by:
finished in interface ActivityRecord

isFinished

public boolean isFinished()
Description copied from interface: ActivityRecord
true if recording this record has finished for thread that created record; additions may still be made by other threads (e.g., #addThreadChild). Does not mean activity was successful, or that record is complete.
Specified by:
isFinished in interface ActivityRecord

getChildren

public Collection getChildren()
Specified by:
getChildren in interface ActivityRecord
Tags copied from interface: ActivityRecord
Returns:
records of activities enclosed in this activity. Child activities may be indirect callees if intermediate activities are not recorded. If all are activities of a single thread, then collection is a List, and iterator returns child activities in sequential order.

addChild

public void addChild(ActivityRecord child)
Description copied from interface: ActivityRecord
add child to this parent's children, and set child's parent to this
Specified by:
addChild in interface ActivityRecord
Tags copied from interface: ActivityRecord
See Also:
ActivityRecord.addThreadedChild(edu.mit.ai.psg.traveler.ActivityRecord)

getChildrenInThread

public List getChildrenInThread()
Specified by:
getChildrenInThread in interface ActivityRecord

addThreadedChild

public void addThreadedChild(ActivityRecord childInOwnThread)
add child activity which is running in another thread
Specified by:
addThreadedChild in interface ActivityRecord
Tags copied from interface: ActivityRecord
See Also:
ActivityRecord.addChild(edu.mit.ai.psg.traveler.ActivityRecord)

getThreadedChildren

public Collection getThreadedChildren()
Specified by:
getThreadedChildren in interface ActivityRecord

ensureListValue

protected static final List ensureListValue(List list)
if list is null, returns Collections.EMPTY_LIST, else returns list

toString

public abstract String toString()
subclasses must provide a print string
Overrides:
toString in class Object

putProperty

protected Object putProperty(Object key,
                             Object value)
key should be a unique object not likely to be used by other classes. Suggestion: create a constant such as:
private static final Object myPropertyKey = 
new Object(){public String toString(){ return "myPropertyKey";}};
This is better than a string because two objects are guaranteed to be non equal. However, it may not work if activity records are serialized.

getProperty

protected Object getProperty(Object key)

removeProperty

protected Object removeProperty(Object key)

cloneObject

protected static Object cloneObject(Object target)
Utility method to clone an object (if it is cloneable) to record its state. Returns null if the object cannot be cloned

Copyright (c) 1996-1999
Massachusetts Institute of Technology

Feedback: jeva-feedback@ai.mit.edu