|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object cz.cuni.amis.pogamut.sposh.elements.PoshElement<THIS,PARENT> cz.cuni.amis.pogamut.sposh.elements.PoshDummyElement cz.cuni.amis.pogamut.sposh.elements.Sense
public class Sense
Sense is a condition consisting from primitive call, predicate and value.
When PoshEngine
askes if sense is true, the sense will call the
primitive through IWorkExecutor
and compares returned value by
predicate. If no argument was passed, use true, if no predicate was passed,
use ==, e.g.
ammo
is equivalent of
ammo true ==
,
VisiblePlayerCount 4
is equivalent of
VisiblePlayerCount 4 ==
.
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 | |
---|---|
void |
changeTo(Sense other)
Take other sense and change all attributes in the sense to be same as in other sense. |
int |
compareTo(Sense o)
|
Arguments |
getArguments()
|
PrimitiveCall |
getCall()
Get call to the sense primitive. |
List<PoshElement> |
getChildDataNodes()
Get list of children of this node. |
DataFlavor |
getDataFlavor()
Get data flavour of posh plan element,used during DnD from palette to PoshScene. |
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. |
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 |
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 |
rename(String newName)
XXX: Not implemented, because I don't have a usecase, but interface has it. |
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 |
---|
getElementId, getUnusedName, isUsedName, moveChildInList |
Methods inherited from class cz.cuni.amis.pogamut.sposh.elements.PoshElement |
---|
addElementListener, emitChildDeleted, emitChildMove, emitChildNode, firePropertyChange, getChildId, getChildren, getElementListeners, 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 |
---|
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 PrimitiveCall getCall()
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()
getArguments
in interface IReferenceElement
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()
INamedElement
getName
in interface INamedElement
public void rename(String newName) throws InvalidNameException, CycleException, DuplicateNameException
rename
in interface INamedElement
newName
- What will be new name of all senses with old name.
InvalidNameException
- Passed name is not valid Yaposh name.
CycleException
- Renaming causes cycle.
DuplicateNameException
- Such name is already used in the plan.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 |