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

Package class diagram package Competence
java.lang.Object
  extended by cz.cuni.amis.pogamut.sposh.elements.PoshElement<THIS,PARENT>
      extended by cz.cuni.amis.pogamut.sposh.elements.PoshDummyElement<Competence,PoshPlan>
          extended by cz.cuni.amis.pogamut.sposh.elements.Competence
All Implemented Interfaces:
INamedElement, IParametrizedElement

public final class Competence
extends PoshDummyElement<Competence,PoshPlan>
implements IParametrizedElement

Competence is basically a named structure offering several choices. If you imagine a decision tree, the point, where node splits into several subnodes is akin to the to the Competence.

What is difference between Competence and DriveCollection? Well, for one, DC is in the root of the plan, DC has a goal (well, Cs had goal too in the past), the main difference how they are processed by the engine (see description of how DriveCollection is evaluated).

Unlike DC, Competence is simple decision tree, engine will take the element with highest priority and satisfied trigger and traverses into that node without looking back.

Author:
HonzaH
See Also:
DriveCollection

Field Summary
static String cnName
          Property string of competence name
static String cnParams
          Property string of competence parameters
static DataFlavor dataFlavor
          Data flavor of competence classs, used for drag-and-drop
 
Fields inherited from class cz.cuni.amis.pogamut.sposh.elements.PoshDummyElement
IDENT_PATTERN
 
Method Summary
 void addElement(CompetenceElement choice)
          Add passed element as the last element of this competence and emit.
 void addElement(int index, CompetenceElement choice)
          Add choice as the @index element of all competences choices + emit.
 DataFlavor getDataFlavor()
          Get data flavour of posh plan element,used during DnD from palette to PoshScene.
 String getHtmlDescription()
          Get HTML description of the competence.
 List<CompetenceElement> getChildDataNodes()
          Get list of children of this node.
 CompetenceElement getChoice(int choiceId)
          Get choice with specified id.
 int getChoiceId(CompetenceElement choice)
          Get index of @choice.
 List<CompetenceElement> getChoices()
           
 String getName()
          Get name of the competence
 FormalParameters getParameters()
          Get list of formal parametrs of competence (names and default values).
 LapType getType()
          Get type of the element.
 boolean moveChild(int newIndex, PoshElement child)
          Move child to the @newIndex.
 void removeElement(CompetenceElement element)
          Remove the CompetenceElement from this competence and emit notification about deletion.
 void rename(String newCompetenceName)
          Rename Competence in the PoshPlan.
 void setName(String name)
          Change name of competence node.
 void setParameters(FormalParameters newParams)
          Set new parameters.
 String toString()
          Create text representation of this competence, compatible with parser, so we can directly output it.
 
Methods inherited from class cz.cuni.amis.pogamut.sposh.elements.PoshDummyElement
getElementId, getUnusedName, isUsedName, moveChildInList
 
Methods inherited from class cz.cuni.amis.pogamut.sposh.elements.PoshElement
addElementListener, emitChildDeleted, emitChildMove, emitChildNode, firePropertyChange, getElementListeners, getChildId, getChildren, getId, getParent, getRootNode, isChildOfParent, removeElementListener, setParent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

cnName

public static final String cnName
Property string of competence name

See Also:
Constant Field Values

cnParams

public static final String cnParams
Property string of competence parameters

See Also:
Constant Field Values

dataFlavor

public static final DataFlavor dataFlavor
Data flavor of competence classs, used for drag-and-drop

Method Detail

addElement

public void addElement(CompetenceElement choice)
                throws DuplicateNameException
Add passed element as the last element of this competence and emit.

Parameters:
choice - element that will be added into this competence
Throws:
DuplicateNameException

addElement

public void addElement(int index,
                       CompetenceElement choice)
                throws DuplicateNameException
Add choice as the @index element of all competences choices + emit.

Parameters:
index - Index at which should the choice be added
choice - Choice to add. Orphan.
Throws:
DuplicateNameException

toString

public String toString()
Create text representation of this competence, compatible with parser, so we can directly output it.

Overrides:
toString in class Object
Returns:

getChildDataNodes

public List<CompetenceElement> getChildDataNodes()
Description copied from class: PoshElement
Get list of children of this node. Most likely auto generated every time this method is called.

Specified by:
getChildDataNodes in class PoshElement<Competence,PoshPlan>
Returns:
List of all children of this node.

getChoices

public List<CompetenceElement> getChoices()
Returns:
All choices of this competence.

getChoice

public CompetenceElement getChoice(int choiceId)
Get choice with specified id. Equivalent of getChoices().List.get(int).

Parameters:
choiceId - Id of desired choice
Returns:
Found choice.

setName

public void setName(String name)
             throws DuplicateNameException,
                    CycleException,
                    InvalidNameException
Change name of competence node.

Parameters:
name - new name of competence node
Throws:
DuplicateNameException
CycleException
InvalidNameException

getName

public String getName()
Get name of the competence

Specified by:
getName in interface INamedElement
Returns:
name of the competence

getHtmlDescription

public String getHtmlDescription()
Get HTML description of the competence. Use e.g. in palette of Shed.

Returns:
HTML description of competence

moveChild

public boolean moveChild(int newIndex,
                         PoshElement child)
Description copied from class: PoshElement
Move child to the @newIndex. After child was moved (if it was moved), notify listeners.

Specified by:
moveChild in class PoshElement<Competence,PoshPlan>
Returns:
if node succesfully moved

getDataFlavor

public DataFlavor getDataFlavor()
Description copied from class: PoshElement
Get data flavour of posh plan element,used during DnD from palette to PoshScene.

Specified by:
getDataFlavor in class PoshElement<Competence,PoshPlan>
Returns:
dataFlavour of posh plan element, never null.

getType

public LapType getType()
Description copied from class: PoshElement
Get type of the element.

Specified by:
getType in class PoshElement<Competence,PoshPlan>
Returns:
Type of element.

removeElement

public void removeElement(CompetenceElement element)
Remove the CompetenceElement from this competence and emit notification about deletion.

Parameters:
element - Element to be removed.

getParameters

public FormalParameters getParameters()
Get list of formal parametrs of competence (names and default values).

Specified by:
getParameters in interface IParametrizedElement
Returns:

setParameters

public void setParameters(FormalParameters newParams)
Description copied from interface: IParametrizedElement
Set new parameters.

Specified by:
setParameters in interface IParametrizedElement
Parameters:
newParams - new parameters

rename

public void rename(String newCompetenceName)
            throws InvalidNameException,
                   CycleException,
                   DuplicateNameException
Rename Competence in the PoshPlan. This method changes name fo the comeptence, finds all references to the competence (the ones with old name) and changed them to @newCompetenceName.

Specified by:
rename in interface INamedElement
Parameters:
newCompetenceName - New name of comeptence after renaming
Throws:
InvalidNameException - Passed name is not valid Yaposh name.
CycleException - Renaming causes cycle.
DuplicateNameException - Such name is already used in the plan.

getChoiceId

public int getChoiceId(CompetenceElement choice)
Get index of @choice.

Parameters:
choice - Choice for which we are looking for an index.
Returns:
Found index
Throws:
IllegalArgumentException - If choice is not among choices of this competence.


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