|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcz.cuni.amis.pogamut.sposh.elements.PoshElement<THIS,PARENT>
cz.cuni.amis.pogamut.sposh.elements.PoshDummyElement<THIS,PARENT>
cz.cuni.amis.pogamut.sposh.elements.NamedLapElement
cz.cuni.amis.pogamut.sposh.elements.Sense
public class Sense
Sense is basically a function in Python or Java. It is called and it returns some result. This class is representation of sense, but it can also take an argument and compare it with predicate. During execution POSH engine calls the sense and compares return value with argument by predicate. If no argument was passed, use true, if no predicate was passed, use ==.
Nested Class Summary | |
---|---|
static class |
Sense.Predicate
Various predicates used in Sense |
Field Summary | |
---|---|
static DataFlavor |
dataFlavor
|
static String |
psArgs
|
static String |
psPredicateIndex
|
static String |
psSenseName
|
static String |
psType
|
static String |
psValue
|
Fields inherited from class cz.cuni.amis.pogamut.sposh.elements.PoshDummyElement |
---|
IDENT_PATTERN |
Constructor Summary | |
---|---|
Sense(PrimitiveCall senseCall)
Create sense that will evaluate based on result of called primitive some parameters |
|
Sense(PrimitiveCall senseCall,
Object operand,
Sense.Predicate predicate)
|
|
Sense(String senseName)
Create sense that will evaluate true based on result of called primitive. |
Method Summary | |
---|---|
int |
compareTo(Sense o)
|
Arguments |
getArguments()
|
DataFlavor |
getDataFlavor()
Get data flavour of posh plan element,used during DnD from palette to PoshScene. |
List<PoshElement> |
getChildDataNodes()
Get list of children of this node. |
String |
getName()
Get name of the element. |
Object |
getOperand()
Get operand that should be used for evaluating this sense. |
Sense.Predicate |
getPredicate()
|
Integer |
getPredicateIndex()
|
String |
getRepresentation()
Get human readable representation of this sense. |
String |
getRepresentation(String name)
Get string representation of the sense, i.e. sensecall predicate value, but instead of sense name, use the passed name. |
PrimitiveCall |
getSenseCall()
Get param |
String |
getSenseName()
|
Trigger<?> |
getTrigger()
Get Trigger this sense is part of. |
LapType |
getType()
Get type of the element. |
String |
getValueString()
Used in Node.Properties XXX: Do more properly with custom editor |
void |
changeTo(Sense other)
Take other sense and change all attributes in the sense to be same as in other sense. |
boolean |
moveChild(int newIndex,
PoshElement child)
Move child to the @newIndex. |
void |
parseSense(String input)
TODO: Correctly document, changed in hurry. |
void |
removeFromParent()
This is a common method for removing the sense from its parent. |
void |
setArguments(Arguments newArguments)
|
void |
setOperand(Object newValue)
Set value of argument (as class, e.g. |
void |
setPredicate(Sense.Predicate newPredicate)
Set the predicate in the sense. |
void |
setPredicateIndex(Integer newPredicateIndex)
Set predicate, use index to array Predicate.values()[index] |
void |
setSenseName(String newSenseName)
Set new sense name if new name matches IDENT_PATTERN, name will be trimmed. |
String |
toString()
Return text representation in posh friendly manner. |
Methods inherited from class cz.cuni.amis.pogamut.sposh.elements.PoshDummyElement |
---|
getUnusedName, isUsedName, moveChildInList |
Methods inherited from class cz.cuni.amis.pogamut.sposh.elements.PoshElement |
---|
addElementListener, emitChildDeleted, emitChildMove, emitChildNode, firePropertyChange, getElementListeners, getNumberOfChildInstances, getParent, getRootNode, isChildOfParent, removeElementListener, setParent |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final String psSenseName
public static final String psArgs
public static final String psPredicateIndex
public static final String psValue
public static final String psType
public static final DataFlavor dataFlavor
Constructor Detail |
---|
public Sense(String senseName)
senseName
- name of primitivepublic Sense(PrimitiveCall senseCall)
senseCall
- details of call primitivepublic Sense(PrimitiveCall senseCall, Object operand, Sense.Predicate predicate)
senseCall
- operand
- operand that will be parsed and changed into proper objectpredicate
- Method Detail |
---|
public String getSenseName()
public PrimitiveCall getSenseCall()
public void setSenseName(String newSenseName) throws InvalidNameException
newSenseName
-
InvalidNameException
public String getValueString()
public Object getOperand()
public void setOperand(Object newValue)
newValue
- number, string or nilpublic Integer getPredicateIndex()
public Sense.Predicate getPredicate()
public void setPredicate(Sense.Predicate newPredicate)
newPredicate
- non nullpublic void setPredicateIndex(Integer newPredicateIndex)
newPredicateIndex
- index to new predicatepublic Arguments getArguments()
public void setArguments(Arguments newArguments)
public void parseSense(String input) throws ParseException
input
-
InvalidNameException
- When name of the sense is not valid.
InvalidFormatException
- When wrong number of tokens in the input.
ParseException
public void changeTo(Sense other) throws InvalidNameException
other
-
InvalidNameException
public String toString()
toString
in class Object
public String getName()
NamedLapElement
getName
in class NamedLapElement
public List<PoshElement> getChildDataNodes()
PoshElement
getChildDataNodes
in class PoshElement
public boolean moveChild(int newIndex, PoshElement child)
PoshElement
moveChild
in class PoshElement
public DataFlavor getDataFlavor()
PoshElement
getDataFlavor
in class PoshElement
public LapType getType()
PoshElement
getType
in class PoshElement
public String getRepresentation()
public String getRepresentation(String name)
name
- Name that is used instead of name in the PrimitiveCall
public int compareTo(Sense o)
compareTo
in interface Comparable<Sense>
public Trigger<?> getTrigger()
Trigger
this sense is part of. Trigger
by itself is
not a PoshElement
, but it is part of some other element (e.g. DriveCollection
or CompetenceElement
)
IllegalArgumentException
- If parent is null or I forgot some
possible parent.public void removeFromParent()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |