Package com.axelor.workflow.expression
Class VarScope
java.lang.Object
com.axelor.workflow.expression.VarScope
One frame of a run's variables, and the frame it sits inside. The run, each split branch and each
body iteration have a frame.
A read walks up the chain. A write lands in the frame where the name is found, else in the
current frame. So vars.total += line.price inside a body accumulates into a total
the caller set, while a name first written inside the body goes with the frame.
Each frame tracks the names written in it (dirtyKeys()), so a resuming branch merges
only those. Not thread-safe: one walk is one thread.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordThe values and assignment counts at the start of one branch's walk. -
Method Summary
Modifier and TypeMethodDescriptionintdepth()How deep this frame is; the run's own is 0.The names written in this frame, which are the ones a merge has to carry.Every name written anywhere in this chain, with the value the chain resolves it to.flatten()The chain as one map, inner frames shadowing outer ones.The value this chain resolveskeyto, or null when no frame has it.booleanWhether any frame in this chain haskey, null-valued or not.keys()Every name this chain resolves, outermost first.The same, for everything this frame inherits -- the other half ofdirtyValues().Everything this frame inherits, without its own -- the other half ofownValues().This frame's own values, without anything it inherits.pop()The frame this one sits in.push()A frame inside this one, for a branch or an iteration.voidWritekeywhere it is already found, or here when it is found nowhere.voidWriteskeyinto this frame, whatever an outer one holds; for seeding a frame, whereput(java.lang.String, java.lang.Object)would overwrite an outer name.static VarScoperoot()The outermost frame: a run's own variables.writtenSince(VarScope.Checkpoint before) Includes explicit assignments of the same value and mutations inside containers.
-
Method Details
-
root
The outermost frame: a run's own variables. -
push
A frame inside this one, for a branch or an iteration. -
pop
The frame this one sits in.- Throws:
IllegalStateException- if this is the run's own frame
-
depth
public int depth()How deep this frame is; the run's own is 0. -
get
The value this chain resolveskeyto, or null when no frame has it. -
has
Whether any frame in this chain haskey, null-valued or not. -
put
Writekeywhere it is already found, or here when it is found nowhere. -
putLocal
Writeskeyinto this frame, whatever an outer one holds; for seeding a frame, whereput(java.lang.String, java.lang.Object)would overwrite an outer name. -
keys
Every name this chain resolves, outermost first. -
flatten
The chain as one map, inner frames shadowing outer ones. -
outerFlatten
Everything this frame inherits, without its own -- the other half ofownValues(). -
ownValues
This frame's own values, without anything it inherits. -
dirtyKeys
The names written in this frame, which are the ones a merge has to carry. -
dirtyValues
Every name written anywhere in this chain, with the value the chain resolves it to. A resuming branch writes back only these, so siblings' writes land in either order. -
checkpoint
-
writtenSince
Includes explicit assignments of the same value and mutations inside containers. -
outerDirtyValues
The same, for everything this frame inherits -- the other half ofdirtyValues().
-