public class Sense extends PoshDummyElement implements Comparable<Sense>, IReferenceElement, INamedElement
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 ==.| Modifier and Type | Class and Description |
|---|---|
static class |
Sense.Predicate
Various predicates used in Sense
|
| Modifier and Type | Field and Description |
|---|---|
static DataFlavor |
dataFlavor |
static String |
psArgs |
static String |
psPredicateIndex |
static String |
psSenseName |
static String |
psType |
static String |
psValue |
IDENT_PATTERN| Constructor and Description |
|---|
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.
|
| Modifier and Type | Method and Description |
|---|---|
int |
compareTo(Sense o) |
Arguments |
getArguments() |
PrimitiveCall |
getCall()
Get call to the sense primitive.
|
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.
|
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 |
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.
|
getElementId, getUnusedName, isUsedName, moveChildInListaddElementListener, emitChildDeleted, emitChildMove, emitChildNode, firePropertyChange, getElementListeners, getChildId, getChildren, getId, getParent, getRootNode, isChildOfParent, removeElementListener, setParentpublic 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
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 - public PrimitiveCall getCall()
public void setSenseName(String newSenseName) throws InvalidNameException
newSenseName - InvalidNameExceptionpublic 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 IReferenceElementpublic 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.ParseExceptionpublic void changeTo(Sense other) throws InvalidNameException
other - InvalidNameExceptionpublic String toString()
public String getName()
INamedElementgetName in interface INamedElementpublic void rename(String newName) throws InvalidNameException, CycleException, DuplicateNameException
rename in interface INamedElementnewName - 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()
PoshElementgetChildDataNodes in class PoshElementpublic boolean moveChild(int newIndex,
PoshElement child)
PoshElementmoveChild in class PoshElementpublic DataFlavor getDataFlavor()
PoshElementgetDataFlavor in class PoshElementpublic LapType getType()
PoshElementgetType in class PoshElementpublic String getRepresentation()
public String getRepresentation(String name)
name - Name that is used instead of name in the PrimitiveCallpublic 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()
Copyright © 2018 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All rights reserved.