cz.cuni.amis.pogamut.sposh.elements
Class LapChain

Package class diagram package LapChain
java.lang.Object
  extended by cz.cuni.amis.pogamut.sposh.elements.LapChain
All Implemented Interfaces:
PoshElementListener, PropertyChangeListener, EventListener

public final class LapChain
extends Object
implements PoshElementListener

Chain of links that represents how are parameters passed in the chain of lap elements. Each time action is referenced, it adds new chain of link. The chain itself is immutable. You can listen for changes of parameters and Arguments of elements referenced by the individual links. Example1: There is only drive that calls some action. In such case, there is only one link of the chain - the call from the chain to the action. Example2: There is drive action that references AP1 and that AP1 references some action. In such case chain has two links - first link represents reference from drive action to AP1 and second link represents reference from AP1 to the action..


Constructor Summary
LapChain()
          Create new chain, It has no ChainLink.
 
Method Summary
 boolean addChainListener(ILapChainListener listener)
           
 void childElementAdded(PoshElement parent, PoshElement child)
          Event handler will be notified that parent has added a new child among its children.
 void childElementMoved(PoshElement parent, PoshElement child, int oldIndex, int newIndex)
          Evenet handler will be notified that parent has moved a child.
 void childElementRemoved(PoshElement parent, PoshElement child, int removedChildPosition)
          Event handler will be notified when parent has removed child.
 VariableContext createContext()
           
<REFERENCE extends PoshElement & IReferenceElement>
LapChain
derive(REFERENCE reference)
          Create and return new chain using this one as the base.
<REFERENCED_NODE extends PoshElement & IParametrizedElement>
LapChain
derive(TriggeredAction action, REFERENCED_NODE referencedNode)
          Return new chain using this one as the base and create new link from the reference of action to AP.
 boolean equals(Object obj)
           
static LapChain fromPath(PoshPlan plan, LapPath path)
          Create chain from the @path.
 int hashCode()
           
 void propertyChange(PropertyChangeEvent evt)
           
 void register()
          Add the chain as listener for changes of elements of links.
 boolean removeChainListener(ILapChainListener listener)
           
 int size()
          How many links of chain are there.
 LapChain subchain(int beginIndex, int endIndex)
          Create subchain created from links of this chain.
 LapPath toPath()
          Create LapPath from the chain.
 String toString()
           
 void unregister()
          Remove the chain as listener of all links elements.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LapChain

public LapChain()
Create new chain, It has no ChainLink.

Method Detail

fromPath

public static LapChain fromPath(PoshPlan plan,
                                LapPath path)
Create chain from the @path.

Parameters:
path - Path that will be used as source of info.
Returns:
New chain.

toPath

public LapPath toPath()
Create LapPath from the chain. Since not every LapPath can be represented by the chain (e.g. LapType.COMPETENCE_ELEMENT), it is not 1-on-1 mapping. Resulting LapPath always starts with /P:0 and ends with type of referenced node of last link. If there is not referenced node at last link (e.g. Sense or TriggeredAction), the last link of path is LapType of IChainLink.getReference(). If chain is empty, return LapPath.DRIVE_COLLECTION_PATH.

Returns:
Created path.

register

public void register()
Add the chain as listener for changes of elements of links. Chain can't notify its ILapChainListener unless it is registered.


unregister

public void unregister()
Remove the chain as listener of all links elements.


derive

public <REFERENCED_NODE extends PoshElement & IParametrizedElement> LapChain derive(TriggeredAction action,
                                                                                   REFERENCED_NODE referencedNode)
Return new chain using this one as the base and create new link from the reference of action to AP.

Parameters:
action - action referencing the AP. Basis of the link.
actionPattern - referenced AP.
Returns:
Newly created chain.

derive

public <REFERENCE extends PoshElement & IReferenceElement> LapChain derive(REFERENCE reference)
Create and return new chain using this one as the base. The last link is a leaf, either action or sense. Since we are calling primitive action, there is no referenced node.

Parameters:
reference - Reference to action or sense in work executor
Returns:
Newly created chain.

subchain

public LapChain subchain(int beginIndex,
                         int endIndex)
Create subchain created from links of this chain.

Parameters:
beginIndex - Begin index of subchain, inclusive
endIndex - End index of subchain, exclusive
Returns:

size

public int size()
How many links of chain are there.


toString

public String toString()
Overrides:
toString in class Object

createContext

public VariableContext createContext()
Returns:
Newly created VariableContext for current chain.

childElementAdded

public void childElementAdded(PoshElement parent,
                              PoshElement child)
Description copied from interface: PoshElementListener
Event handler will be notified that parent has added a new child among its children.

Specified by:
childElementAdded in interface PoshElementListener
Parameters:
parent - parent that has a new child
child - Child that has been added.

childElementMoved

public void childElementMoved(PoshElement parent,
                              PoshElement child,
                              int oldIndex,
                              int newIndex)
Description copied from interface: PoshElementListener
Evenet handler will be notified that parent has moved a child.

Specified by:
childElementMoved in interface PoshElementListener
Parameters:
parent - Parent element of child.
child - child that has been moved.
oldIndex - Index of the child before move.
newIndex - Absolute position of the moved child with its own type. E.g. DriveCollection has two types of children, Senses and DriveElement. First sense has absolute index 0 and first drive has absolute index 0.

childElementRemoved

public void childElementRemoved(PoshElement parent,
                                PoshElement child,
                                int removedChildPosition)
Description copied from interface: PoshElementListener
Event handler will be notified when parent has removed child.

Specified by:
childElementRemoved in interface PoshElementListener
Parameters:
parent - parent element of child
child - child element that has been removed
removedChildPosition - What was position of removed child among children

propertyChange

public void propertyChange(PropertyChangeEvent evt)
Specified by:
propertyChange in interface PropertyChangeListener

addChainListener

public boolean addChainListener(ILapChainListener listener)

removeChainListener

public boolean removeChainListener(ILapChainListener listener)

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object


Copyright © 2014 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.