Package eu.bandm.tools.ramus.ogma
Class ReducerFactory.Context<D,R>
java.lang.Object
eu.bandm.tools.ramus.ogma.ReducerFactory.Context<D,R>
- Type Parameters:
D- the type of document identifiersR- the type of AST results
- All Implemented Interfaces:
MessageReceiver<SimpleMessage<D>>,Environment,Consumer<SimpleMessage<D>>
- Enclosing class:
ReducerFactory
public class ReducerFactory.Context<D,R>
extends Object
implements MessageReceiver<SimpleMessage<D>>, Environment
Context server for AST reduction.
The lifetime of objects of this class is controlled by a ReducerFactory. They are both created and evaluated (and rendered
unusable) behind the scenes.
-
Method Summary
Modifier and TypeMethodDescription<X> Xabort()Aborts the current creation of an AST node.voidAppends an error to the list of diagnostic messages.voidAppends an error to the list of diagnostic messages.voidfork(ReducerFactory.Constructor0<D, R> other) Forks of an alternative nondeterministic branch with a clone of this context.Returns the current value assigned to the given key.Returns the input location associated with this context, if available.List<? extends SimpleMessage<D>> Returns the list of diagnostic messages attached to this context.getValue()Returns the current accumulator value.voidAppends a hint to the list of diagnostic messages.voidAppends a hint to the list of diagnostic messages.booleanChecks whether this context has already been evaluated.voidpop()Leaves and discards a scope of the semantic state.voidpush()Enters a new scope of the semantic state.voidSets the current value assigned to the given key.voidreceive(SimpleMessage<D> message) Receive the given message.voidSets the current accumulator value.<T> VirtualField<T> variable(Reading.Key<T> key) voidAppends a warning to the list of diagnostic messages.voidAppends a warning to the list of diagnostic messages.voidAppends a warning to the list of diagnostic messages.voidAppends a warning to the list of diagnostic messages.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface eu.bandm.tools.message.MessageReceiver
accept, ifSubcriticalThen, ifSubcriticalThen, ifSubcriticalThenElse
-
Method Details
-
getLocation
Returns the input location associated with this context, if available.- Returns:
- the input location associated with this context, or
nullif not available.
-
getMessages
Returns the list of diagnostic messages attached to this context.- Returns:
- an unmodifiable list of diagnostic messages attached to this context
-
isEvaluated
public boolean isEvaluated()Checks whether this context has already been evaluated.A context may only be evaluated once. Further attempts to modify the semantic state, to attach messages or to branch nondeterministically are forbidden, and result in
IllegalStateExceptionbeing thrown.- Returns:
trueif this context has already been evaluated,falseif it may be modified and evaluated
-
receive
Receive the given message.- Specified by:
receivein interfaceMessageReceiver<D>- Parameters:
message- the message to receive.- Throws:
IllegalStateException- if this context has already been evaluated
-
warning
Appends a warning to the list of diagnostic messages.- Parameters:
message- the text of the messageargs- the list of arguments- Throws:
IllegalStateException- if this context has already been evaluated- See Also:
-
warning
Appends a warning to the list of diagnostic messages.- Parameters:
location- the message location, ornullif not availablemessage- the text of the messageargs- the list of arguments- Throws:
IllegalStateException- if this context has already been evaluated- See Also:
-
warning
Appends a warning to the list of diagnostic messages.- Parameters:
level- the message levelmessage- the text of the messageargs- the list of arguments- Throws:
IllegalStateException- if this context has already been evaluated- See Also:
-
warning
Appends a warning to the list of diagnostic messages.- Parameters:
level- the message levellocation- the message location, ornullif not availablemessage- the text of the messageargs- the list of arguments- Throws:
IllegalStateException- if this context has already been evaluated- See Also:
-
error
Appends an error to the list of diagnostic messages.- Parameters:
message- the text of the messageargs- the list of arguments- Throws:
IllegalStateException- if this context has already been evaluated- See Also:
-
error
Appends an error to the list of diagnostic messages.- Parameters:
location- the message location, ornullif not availablemessage- the text of the messageargs- the list of arguments- Throws:
IllegalStateException- if this context has already been evaluated- See Also:
-
hint
Appends a hint to the list of diagnostic messages.- Parameters:
message- the text of the messageargs- the list of arguments- Throws:
IllegalStateException- if this context has already been evaluated- See Also:
-
hint
Appends a hint to the list of diagnostic messages.- Parameters:
location- the message location, ornullif not availablemessage- the text of the messageargs- the list of arguments- Throws:
IllegalStateException- if this context has already been evaluated- See Also:
-
getValue
Returns the current accumulator value.- Specified by:
getValuein interfaceEnvironment- Returns:
- the current accumulator value
-
get
Returns the current value assigned to the given key.- Specified by:
getin interfaceEnvironment- Parameters:
key- the key- Returns:
- the current value assigned to
key, ornullif there is no entry forkey
-
setValue
Sets the current accumulator value.- Parameters:
value- the new accumulator value- Throws:
NullPointerException- ifvalueis nullIllegalStateException- if this context has already been evaluated- See Also:
-
put
Sets the current value assigned to the given key.- Parameters:
key- the keyvalue- the new value to be assigned tokey- Throws:
NullPointerException- ifkeyorvalueis nullIllegalStateException- if this context has already been evaluated- See Also:
-
push
public void push()Enters a new scope of the semantic state.- Throws:
IllegalStateException- if this context has already been evaluated- See Also:
-
pop
public void pop()Leaves and discards a scope of the semantic state.- Throws:
IllegalStateException- if this context has already been evaluated- See Also:
-
abort
Aborts the current creation of an AST node. All diagnostic messages and semantic state transitions are discarded.This method never returns normally. To make the control-flow check of the Java compiler aware of this fact, in a non-void method one may write
return abort();.- Type Parameters:
X- the fictitious return type- Returns:
- never
- Throws:
ReducerFactory.Abort- always
-
fork
Forks of an alternative nondeterministic branch with a clone of this context.- Parameters:
other- a consumer to work on the branch- Throws:
NullPointerException- ifotheris nullIllegalStateException- if this context has already been evaluated
-
variable
-