Class Triggerable
java.lang.Object
org.javarosa.core.model.condition.Triggerable
- All Implemented Interfaces:
Externalizable
- Direct Known Subclasses:
Condition,Recalculate
public abstract class Triggerable extends Object implements Externalizable
A triggerable represents an action that should be processed based
on a value updating in a model. Trigerrables are comprised of two
basic components: An expression to be evaluated, and a reference
which represents where the resultant value will be stored.
A triggerable will dispatch the action it's performing out to
all relevant nodes referenced by the context against thes current
models.
- Author:
- ctsims
-
Field Summary
Fields Modifier and Type Field Description static Comparator<Triggerable>triggerablesRootOrdering -
Constructor Summary
Constructors Constructor Description Triggerable()Triggerable(IConditionExpr expr, TreeReference contextRef)Triggerable(IConditionExpr expr, TreeReference contextRef, ArrayList<TreeReference> targets) -
Method Summary
Modifier and Type Method Description voidaddTarget(TreeReference target)List<EvaluationResult>apply(FormInstance mainInstance, EvaluationContext parentContext, TreeReference context)Not for re-implementation, dispatches all of the evaluationprotected abstract voidapply(TreeReference ref, Object result, FormInstance mainInstance)abstract booleancanCascade()voidchangeContextRefToIntersectWithTriggerable(Triggerable t)TreeReferencecontextualizeContextRef(TreeReference anchorRef)booleanequals(Object o)protected abstract Objecteval(FormInstance instance, EvaluationContext ec)List<TreeReference>findAffectedTriggers(Map<TreeReference,List<TreeReference>> firedAnchorsMap)Searches in the triggers of this Triggerable, trying to find the ones that are contained in the given list of contextualized refs.IConditionExprgetExpr()HashSet<QuickTriggerable>getImmediateCascades()List<TreeReference>getTargets()Set<TreeReference>getTriggers()booleanisCascadingToChildren()This should return true if this triggerable's targets will implicity modify the value of their children.voidprint(OutputStreamWriter w)voidreadExternal(DataInputStream in, PrototypeFactory pf)voidsetImmediateCascades(HashSet<QuickTriggerable> cascades)voidsetWaveCount(int waveCount)StringtoString()voidwriteExternal(DataOutputStream out)
-
Field Details
-
Constructor Details
-
Triggerable
public Triggerable() -
Triggerable
public Triggerable(IConditionExpr expr, TreeReference contextRef, ArrayList<TreeReference> targets) -
Triggerable
-
-
Method Details
-
setImmediateCascades
-
getImmediateCascades
-
eval
-
apply
-
canCascade
public abstract boolean canCascade() -
apply
public final List<EvaluationResult> apply(FormInstance mainInstance, EvaluationContext parentContext, TreeReference context)Not for re-implementation, dispatches all of the evaluation- Parameters:
mainInstance-parentContext-context-
-
getExpr
-
addTarget
-
getTargets
-
setWaveCount
public void setWaveCount(int waveCount) -
isCascadingToChildren
public boolean isCascadingToChildren()This should return true if this triggerable's targets will implicity modify the value of their children. IE: if this triggerable makes a node relevant/irrelevant, expressions which care about the value of this node's children should be triggered.- Returns:
- True if this condition should trigger expressions whose targets include nodes which are the children of this node's targets.
-
getTriggers
-
changeContextRefToIntersectWithTriggerable
-
contextualizeContextRef
-
equals
-
readExternal
public void readExternal(DataInputStream in, PrototypeFactory pf) throws IOException, DeserializationException- Specified by:
readExternalin interfaceExternalizable- Throws:
IOExceptionDeserializationException
-
writeExternal
- Specified by:
writeExternalin interfaceExternalizable- Throws:
IOException
-
toString
-
print
- Throws:
IOException
-
findAffectedTriggers
public List<TreeReference> findAffectedTriggers(Map<TreeReference,List<TreeReference>> firedAnchorsMap)Searches in the triggers of this Triggerable, trying to find the ones that are contained in the given list of contextualized refs.- Parameters:
firedAnchorsMap- a map of absolute refs- Returns:
- a list of affected nodes.
-