net.sf.sdedit.diagram
Class Lifeline

java.lang.Object
  extended by net.sf.sdedit.diagram.Lifeline

public final class Lifeline
extends Object

For each object or actor that appears in a diagram and that has not yet been destroyed, there is at least one Lifeline object. It is active (see isActive()) if the corresponding object or actor can currently send a message. For objects, being active is implied by having received a message to which no answer has yet been sent. When an object that has already received a message to which it has not yet answered, receives another message, a new Lifeline object is created and associated to the original (or "root") Lifeline object.

Author:
Markus Strauch

Constructor Summary
Lifeline(String name, String type, String label, boolean alive, boolean anonymous, boolean role, boolean activeObject, boolean process, boolean hasThread, boolean autodestroy, boolean external, Diagram diagram)
          Creates a new root Lifeline object that corresponds to an object and is ready to receive messages.
 
Method Summary
 Lifeline addActivity(Lifeline caller, int thread)
           
 void addView(ExtensibleDrawable view)
           
 void destroy()
           
 void dispose()
          Disposes this lifeline, which means that it is taken from the stack of the main lifeline it belongs to.
 void finish()
          This method is called when a message was read and the control flow returns to an object that has been called before the object corresponding to this lifeline was called.
 LinkedList<Lifeline> getAllLifelines()
          Returns a list containing this lifeline and all of its sub lifelines.
 List<ExtensibleDrawable> getAllViews()
           
 int getCallLevel()
           
 Cross getCross()
           
 Diagram getDiagram()
           
 Direction getDirection()
          Returns Direction.CENTER, if this is a lifeline, Direction.LEFT, if this is a dependent lifeline that has been activated by a message from an object with a lower position, otherwise Direction.RIGHT
 Drawable getHead()
           
 Lifeline getLastInThread(int thread)
           
 Lifeline getLeftmost()
           
 Lifeline getLeftNeighbour()
          If this is a root or sub lifeline that belongs to the object which is displayed leftmost, this method returns null, otherwise it returns (with respect to the current state of activities) the rightmost lifeline belonging to the object that is displayed to the left of the object to which this lifeline belongs.
 String getMnemonic()
           
 String getName()
           
 int getPosition()
          Returns this lifeline's object's position in the object section where it is declared.
 Lifeline getRightmost()
           
 Lifeline getRightNeighbour()
          If this is a root or sub lifeline that belongs to the object which is displayed rightmost, this method returns null, otherwise it returns (with respect to the current state of activities) the leftmost lifeline belonging to the object that is displayed to the right of the object to which this lifeline belongs.
 Lifeline getRoot()
          Returns the main or root lifeline that represents the first activity of the object to which this lifeline belongs.
 int getSideLevel()
          Returns 0, if this is a root lifeline; if it is a sub lifeline, returns the number of sub lifelines that have the same direction like this one.
 int getThread()
           
 String getType()
           
 int getUniqueThread()
          If all activities that correspond to this lifeline, its root and its root's descendants belong to the same unique thread, the number of this thread is returned, otherwise -1
 ExtensibleDrawable getView()
           
 void giveBirth()
          Call this method when an object is created via a 'new' message.
 boolean hasThread()
           
 boolean isActive()
           
 boolean isActiveObject()
           
 boolean isAlive()
          Returns a flag denoting whether the object is visible and ready to receive a message (true) or still waiting for a 'new' message.
 boolean isAlwaysActive()
           
 boolean isExternal()
           
 boolean isWaiting()
           
 void setActive(boolean active)
           
 void setMnemonic(String mnemnonic)
           
 void setRectangleBottom(int bottom)
           
 void setThread(int thread)
           
 void terminate()
           
 void toggleWaitingStatus()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Lifeline

public Lifeline(String name,
                String type,
                String label,
                boolean alive,
                boolean anonymous,
                boolean role,
                boolean activeObject,
                boolean process,
                boolean hasThread,
                boolean autodestroy,
                boolean external,
                Diagram diagram)
Creates a new root Lifeline object that corresponds to an object and is ready to receive messages. If the object receives a message while it is active, this 'higher level' activity will be represented by a dependent lifeline which must be created via the Lifeline(Lifeline, Direction, int) constructor with the main lifeline as the first argument.

Parameters:
name - the name of the object
type - the type of the object
label - the label of the lifeline, if it is the empty string, the label depends on the name and type
alive - flag denoting whether the object is visible from the start (true) or it will come into existence by receiving a new message
anonymous - flag denoting whether the name of the instance will be shown on the diagram
role - flag denoting whether the object is a role rather, so its place could be taken by another object of another class, with a similar behaviour; the visible effect of this is that the name of the instance and the class will not be underlined
activeObject - flag denoting if the object is active, i. e. all messages sent to the object spawn a new thread
diagram - the diagram to which the lifeline belongs
Method Detail

addView

public void addView(ExtensibleDrawable view)

getAllViews

public List<ExtensibleDrawable> getAllViews()

getCallLevel

public int getCallLevel()

isActiveObject

public boolean isActiveObject()

hasThread

public boolean hasThread()

setThread

public void setThread(int thread)

getThread

public int getThread()

setMnemonic

public void setMnemonic(String mnemnonic)

getMnemonic

public String getMnemonic()

isWaiting

public boolean isWaiting()

getUniqueThread

public int getUniqueThread()
If all activities that correspond to this lifeline, its root and its root's descendants belong to the same unique thread, the number of this thread is returned, otherwise -1

Returns:
the number of the unique thread where all activities belonging to this lifeline, its root and its root's descendants occur, it there is such a thread, otherwise -1

getLeftmost

public Lifeline getLeftmost()

getRightmost

public Lifeline getRightmost()

getRoot

public Lifeline getRoot()
Returns the main or root lifeline that represents the first activity of the object to which this lifeline belongs.

Returns:
the main or root lifeline that represents the first activity of the object to which this lifeline belongs

isAlwaysActive

public boolean isAlwaysActive()

getAllLifelines

public LinkedList<Lifeline> getAllLifelines()
Returns a list containing this lifeline and all of its sub lifelines.

Returns:
a list containing this lifeline and all of its sub lifelines

getLastInThread

public Lifeline getLastInThread(int thread)

getRightNeighbour

public Lifeline getRightNeighbour()
If this is a root or sub lifeline that belongs to the object which is displayed rightmost, this method returns null, otherwise it returns (with respect to the current state of activities) the leftmost lifeline belonging to the object that is displayed to the right of the object to which this lifeline belongs. If the object on the right is not yet active, this method returns null.

Returns:
the leftmost lifeline belonging to the object that is displayed to the right of the object to which this lifeline belongs or null if no such object or lifeline exists

getLeftNeighbour

public Lifeline getLeftNeighbour()
If this is a root or sub lifeline that belongs to the object which is displayed leftmost, this method returns null, otherwise it returns (with respect to the current state of activities) the rightmost lifeline belonging to the object that is displayed to the left of the object to which this lifeline belongs. If the object on the left is not yet active, this method returns null.

Returns:
the rightmost lifeline belonging to the object that is displayed to the left of the object to which this lifeline belongs or null if no such object or lifeline exists

isAlive

public boolean isAlive()
Returns a flag denoting whether the object is visible and ready to receive a message (true) or still waiting for a 'new' message.

Returns:
a flag denoting whether the object is visible and ready to receive message (true) or still waiting for a 'new' message

giveBirth

public void giveBirth()
Call this method when an object is created via a 'new' message.


getDirection

public Direction getDirection()
Returns Direction.CENTER, if this is a lifeline, Direction.LEFT, if this is a dependent lifeline that has been activated by a message from an object with a lower position, otherwise Direction.RIGHT

Returns:
Direction.CENTER, if this is a lifeline, Direction.LEFT, if this is a dependent lifeline that has been activated by a message from an object with a lower position, otherwise Direction.RIGHT

getPosition

public int getPosition()
Returns this lifeline's object's position in the object section where it is declared.

Returns:
this lifeline's position

getSideLevel

public int getSideLevel()
Returns 0, if this is a root lifeline; if it is a sub lifeline, returns the number of sub lifelines that have the same direction like this one.

Returns:
the level of this lifeline on its side

isActive

public boolean isActive()

getName

public String getName()

getType

public String getType()

addActivity

public Lifeline addActivity(Lifeline caller,
                            int thread)

finish

public void finish()
This method is called when a message was read and the control flow returns to an object that has been called before the object corresponding to this lifeline was called. Thus its active flag is set false.


terminate

public void terminate()

dispose

public void dispose()
Disposes this lifeline, which means that it is taken from the stack of the main lifeline it belongs to. If it is a main lifeline, it cannot be disposed and thus an IllegalStateException is thrown. A lifeline must not be active in order to dispose it.

Throws:
IllegalStateException - if this is a main lifeline or if this lifeline is still active

toggleWaitingStatus

public void toggleWaitingStatus()

setActive

public void setActive(boolean active)

setRectangleBottom

public void setRectangleBottom(int bottom)

toString

public String toString()
Overrides:
toString in class Object

getDiagram

public Diagram getDiagram()

getView

public ExtensibleDrawable getView()

getHead

public Drawable getHead()

isExternal

public boolean isExternal()

destroy

public void destroy()

getCross

public Cross getCross()


Copyright © 2011. All Rights Reserved.