Class RuntimeEnvironment.Context<D extends VariableDeclaration,O extends IModel>
- java.lang.Object
-
- net.ssehub.easy.instantiation.core.model.common.RuntimeEnvironment.Context<D,O>
-
- Type Parameters:
D- the variable declaration typeO- the model type
- Enclosing class:
- RuntimeEnvironment<V extends VariableDeclaration,M extends IModel>
private class RuntimeEnvironment.Context<D extends VariableDeclaration,O extends IModel> extends java.lang.ObjectDefines a context for executing one model within.- Author:
- Holger Eichelberger
-
-
Field Summary
Fields Modifier and Type Field Description private intindentationprivate IndentationConfigurationindentationConfigurationprivate java.util.Stack<RuntimeEnvironment.Level<D>>levelsprivate IResolvableModel<D,O>modelprivate java.lang.String[]pathsprivate IResolvableModel<D,O>specificModel
-
Constructor Summary
Constructors Constructor Description Context(IResolvableModel<D,O> model)Creates a new context.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddValue(D var, java.lang.Object object)Changes the value ofvarto the top level.voiddecreaseIndentation()Decreases the indentation by one step.Dget(java.lang.String name)Returns the variable of namenameif defined.intgetIndentation()Returns the current indentation.IndentationConfigurationgetIndentationConfiguration()Returns the indentation information for the underlying model.java.lang.ObjectgetIvmlValue(java.lang.String name)Returns the value of the IVML element denoted bynamein the closest scope defining an IVML configuration.IResolvableModel<D,O>getModel()Returns the model.IResolvableModel<D,O>getMostSpecificModel()Returns the actual (potentially more specific runtime model than in {@link #getModel()).ConfigurationgetTopLevelConfiguration()Returns the top-level configuration based on defining global VIL/VTL script parameters.java.lang.ObjectgetValue(IResolvable resolvable)Returns the value ofresolvable.voidincreaseIndentation()Increases the indentation by one step.booleanisDefined(D var)Returns whethervaris defined (a value was assigned).private booleanisDefined(D var, int maxIndex)Returns whethervaris defined (a value was assigned).voidpopLevel()Removes the topmost level.voidpushLevel()Pushes a new level.voidremoveValue(D var)Removes the binding forvarfrom the top level.voidsetIndentation(int indentation)Changes the current indentation.voidsetIndentationSteps(int steps)Changes the current indentation (in steps).voidsetMostSpecificModel(IResolvableModel<D,O> model)Sets the more specific runtime model.voidsetValue(D var, java.lang.Object object)Changes the value ofvarwhere it is defined.voidstoreArtifacts(boolean force)Stores the recent artifacts, but only artifacts that are not excluded and not initially defined on the current level (avoids repeated writing the same artifacts along a nesting hierarchy).
-
-
-
Field Detail
-
levels
private java.util.Stack<RuntimeEnvironment.Level<D extends VariableDeclaration>> levels
-
model
private IResolvableModel<D extends VariableDeclaration,O extends IModel> model
-
specificModel
private IResolvableModel<D extends VariableDeclaration,O extends IModel> specificModel
-
indentation
private int indentation
-
indentationConfiguration
private IndentationConfiguration indentationConfiguration
-
paths
private java.lang.String[] paths
-
-
Constructor Detail
-
Context
public Context(IResolvableModel<D,O> model)
Creates a new context.- Parameters:
model- the related model
-
-
Method Detail
-
getModel
public IResolvableModel<D,O> getModel()
Returns the model.- Returns:
- the model
-
getMostSpecificModel
public IResolvableModel<D,O> getMostSpecificModel()
Returns the actual (potentially more specific runtime model than in {@link #getModel()).- Returns:
getModel()or a more specific model determined at runtime
-
setMostSpecificModel
public void setMostSpecificModel(IResolvableModel<D,O> model)
Sets the more specific runtime model.- Parameters:
model- the more specific runtime model thangetModel()
-
getValue
public java.lang.Object getValue(IResolvable resolvable) throws VilException
Returns the value ofresolvable.- Parameters:
resolvable- the variable to return the value for- Returns:
- the value of
resolvable - Throws:
VilException- in case thatresolvablewas not defined
-
get
public D get(java.lang.String name)
Returns the variable of namenameif defined.- Parameters:
name- the name of the variable- Returns:
- the variable or null if not found
-
isDefined
public boolean isDefined(D var)
Returns whethervaris defined (a value was assigned).- Parameters:
var- the variable to look for- Returns:
trueifvaris defined,falseelse
-
isDefined
private boolean isDefined(D var, int maxIndex)
Returns whethervaris defined (a value was assigned).- Parameters:
var- the variable to look formaxIndex- the maximum level index to start searching for- Returns:
trueifvaris defined,falseelse
-
setValue
public void setValue(D var, java.lang.Object object) throws VilException
Changes the value ofvarwhere it is defined.- Parameters:
var- the variable to be modifiedobject- the value ofvar- Throws:
VilException- in case of an attempt of modifying a constant
-
pushLevel
public void pushLevel()
Pushes a new level.
-
popLevel
public void popLevel() throws VilExceptionRemoves the topmost level.- Throws:
VilException- in case that storing artifacts fails, the level will be popped anyway
-
storeArtifacts
public void storeArtifacts(boolean force) throws VilExceptionStores the recent artifacts, but only artifacts that are not excluded and not initially defined on the current level (avoids repeated writing the same artifacts along a nesting hierarchy).- Parameters:
force- force storing artifacts- Throws:
VilException- in case that storing artifacts fails- See Also:
RuntimeEnvironment.markNoAutoStore(IArtifact),RuntimeEnvironment.unmarkNoAutoStore(IArtifact)
-
addValue
public void addValue(D var, java.lang.Object object) throws VilException
Changes the value ofvarto the top level.- Parameters:
var- the variable to be modifiedobject- the value ofvar- Throws:
VilException- in case of an attempt of modifying a constant
-
removeValue
public void removeValue(D var)
Removes the binding forvarfrom the top level.- Parameters:
var- the variable to be removed
-
getIndentationConfiguration
public IndentationConfiguration getIndentationConfiguration()
Returns the indentation information for the underlying model.- Returns:
- the indentation information
-
getIndentation
public int getIndentation()
Returns the current indentation.- Returns:
- the current indentation (in single whitespaces)
-
setIndentationSteps
public void setIndentationSteps(int steps)
Changes the current indentation (in steps).- Parameters:
steps- the number of indentation steps
-
setIndentation
public void setIndentation(int indentation)
Changes the current indentation.- Parameters:
indentation- the new indentation (in single whitespaces)
-
increaseIndentation
public void increaseIndentation()
Increases the indentation by one step.
-
decreaseIndentation
public void decreaseIndentation()
Decreases the indentation by one step.
-
getIvmlValue
public java.lang.Object getIvmlValue(java.lang.String name) throws VilExceptionReturns the value of the IVML element denoted bynamein the closest scope defining an IVML configuration.- Parameters:
name- the name- Returns:
- the value
- Throws:
VilException- in case thatnamewas not defined
-
getTopLevelConfiguration
public Configuration getTopLevelConfiguration()
Returns the top-level configuration based on defining global VIL/VTL script parameters.- Returns:
- the top-level configuration (may be null if unknown)
-
-