cz.cuni.amis.pogamut.sposh.elements
Class PoshDummyElement<THIS extends PoshElement,PARENT extends PoshElement>

Package class diagram package PoshDummyElement
java.lang.Object
  extended by cz.cuni.amis.pogamut.sposh.elements.PoshElement<THIS,PARENT>
      extended by cz.cuni.amis.pogamut.sposh.elements.PoshDummyElement<THIS,PARENT>
Direct Known Subclasses:
ActionPattern, Adopt, Competence, CompetenceElement, DriveCollection, DriveElement, PoshPlan, Sense, TriggeredAction

public abstract class PoshDummyElement<THIS extends PoshElement,PARENT extends PoshElement>
extends PoshElement<THIS,PARENT>

This is class used as intermediate class between PoshElement and DataNodes of POSH elements. Some common functions are implemented here.

Author:
HonzaH

Field Summary
static String IDENT_PATTERN
          Regular pattern, only text that matches this pattern can be a name of the POSH element.
 
Constructor Summary
PoshDummyElement()
           
 
Method Summary
protected
<ELEMENT extends PoshElement & INamedElement>
int
getElementId(List<ELEMENT> elements, ELEMENT element)
          Get index of @element in all @elements.
protected static String getUnusedName(String template, List<? extends INamedElement> elements)
          Get valid name for new element, but name can't be same as any name used by passed elements.
protected static boolean isUsedName(String name, List<? extends INamedElement> elements)
          Is passed name used by one of elements?
protected
<T extends PoshElement>
boolean
moveChildInList(List<T> list, T child, int newIndex)
          Take the @list of elements and one @child of the @list.
 
Methods inherited from class cz.cuni.amis.pogamut.sposh.elements.PoshElement
addElementListener, emitChildDeleted, emitChildMove, emitChildNode, firePropertyChange, getChildDataNodes, getChildId, getChildren, getDataFlavor, getElementListeners, getId, getParent, getRootNode, getType, isChildOfParent, moveChild, removeElementListener, setParent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

IDENT_PATTERN

public static final String IDENT_PATTERN
Regular pattern, only text that matches this pattern can be a name of the POSH element. This pattern must be same as token NAME in the PoshParser.jj

Because of dash (-), not all strings that match this pattern are FQN.

See Also:
Constant Field Values
Constructor Detail

PoshDummyElement

public PoshDummyElement()
Method Detail

moveChildInList

protected <T extends PoshElement> boolean moveChildInList(List<T> list,
                                                          T child,
                                                          int newIndex)
Take the @list of elements and one @child of the @list. Move the @child so that it is at the @newIndex and the rest of elements keep their order. Once it is done, emit the event. If @child is not part of the @list, throw NoSuchElementException, if @newIndex is same as the index the @child is currently at, don't do anything.

Type Parameters:
T -
Parameters:
list -
child -
newIndex - Index
Returns:
did method move and emited?

isUsedName

protected static boolean isUsedName(String name,
                                    List<? extends INamedElement> elements)
Is passed name used by one of elements?

Parameters:
name - name to be tested
elements - elements againt which the test is done
Returns:
true if name is used, false otherwise

getUnusedName

protected static String getUnusedName(String template,
                                      List<? extends INamedElement> elements)
Get valid name for new element, but name can't be same as any name used by passed elements.

Parameters:
template - string used as prefix of created name
elements - elements that must have different name that created name
Returns:
valid name that can be immediately used as OK name of new drive.

getElementId

protected <ELEMENT extends PoshElement & INamedElement> int getElementId(List<ELEMENT> elements,
                                                                        ELEMENT element)
Get index of @element in all @elements.

Type Parameters:
ELEMENT - Type of elements.
Parameters:
elements - List of elements where
element - element for which we are looking for in elements.
Returns:
Found index.
Throws:
IllegalArgumentException - If element is not among elements.


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