cz.cuni.amis.pogamut.sposh.elements
Class Trigger<OWNER extends PoshElement>

Package class diagram package Trigger
java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<Sense>
          extended by cz.cuni.amis.pogamut.sposh.elements.Trigger<OWNER>
All Implemented Interfaces:
Iterable<Sense>, Collection<Sense>, List<Sense>

public final class Trigger<OWNER extends PoshElement>
extends AbstractList<Sense>

Trigger of an element. Trigger is basically a collection of senses, when all senses are evaluated to be true, the trigger is true, otherwise trigger is false. Note, that trigger can be empty, i.e. contain no senses.

Things are little more interesting how should trigger behave when it doesn't contain any senses. That depends if trigger is used as a goal or trigger. When goal is true, it means that the element is finished and is no longer necessary to execute it, thus it is false. Trigger is used to determine if some element should be traversed and thus it is true. As you can see, default behavior of trigger is specified in a way that encourages tree traversal (because default goal result is by false, traversal won't stop prematurely and because default trigger result is true, traversal will use the node triggered by the trigger).

Author:
HonzaH

Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Method Summary
 void add(int index, Sense newSense)
          Insert sense at specified index and owner will emit new child.
 boolean add(Sense sense)
          Add sense to this trigger and emit news about addition.
 Sense get(int index)
          Get sense stored at indexed position in the trigger.
 void moveSense(int newIndex, Sense movedSense)
          Move sense so that after move, it is at newIndex + emit event.
 Sense remove(int index)
          Remove sense from specified position and the removed sense will emit node deleted.
 int size()
          How many senses are there in the trigger
 String toString()
          Serialize the trigger as serialization of its senses surrounded by braces.
 
Methods inherited from class java.util.AbstractList
addAll, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, removeRange, set, subList
 
Methods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray
 

Method Detail

toString

public String toString()
Serialize the trigger as serialization of its senses surrounded by braces. Example: (sense1 (sense2) (sense3))

Overrides:
toString in class AbstractCollection<Sense>
Returns:

add

public boolean add(Sense sense)
Add sense to this trigger and emit news about addition.

Specified by:
add in interface Collection<Sense>
Specified by:
add in interface List<Sense>
Overrides:
add in class AbstractList<Sense>
Parameters:
sense - sense to be added.

get

public Sense get(int index)
Get sense stored at indexed position in the trigger.

Specified by:
get in interface List<Sense>
Specified by:
get in class AbstractList<Sense>
Parameters:
index - index of searched trigger.
Returns:
found sense

add

public void add(int index,
                Sense newSense)
Insert sense at specified index and owner will emit new child.

Specified by:
add in interface List<Sense>
Overrides:
add in class AbstractList<Sense>
Parameters:
index - index where to insert new sense
newSense - sense to insert into the trigger

remove

public Sense remove(int index)
Remove sense from specified position and the removed sense will emit node deleted.

Specified by:
remove in interface List<Sense>
Overrides:
remove in class AbstractList<Sense>
Parameters:
index - position which sense in the trigger to remove.
Returns:
Removed sense

size

public int size()
How many senses are there in the trigger

Specified by:
size in interface Collection<Sense>
Specified by:
size in interface List<Sense>
Specified by:
size in class AbstractCollection<Sense>
Returns:
Number of senses in the trigger

moveSense

public void moveSense(int newIndex,
                      Sense movedSense)
Move sense so that after move, it is at newIndex + emit event. If original index and new index are same, don't emit event.

Parameters:
newIndex - New index of the sense. Once move is done, sense will be at this index and the rest will somehow manage.
movedSense - Sense that is being moved from its original position to the @index. The sense must be part of this trigger.


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