|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.sintef.mofscript.runtime.ExecutionEnvironment
public class ExecutionEnvironment
Handels the 'memory' during execution. Stores variables, handles file streams etc. Part of the RuleExecutionStack
Field Summary | |
---|---|
protected static long |
_blockCounter
|
protected java.io.OutputStream |
_currentStream
|
protected boolean |
_inPrintAction
|
protected static int |
_lineNumber
|
protected java.lang.String |
_objectId
|
protected static java.util.Hashtable |
_offsets
|
protected static java.lang.String |
_openFileUri
|
protected ExecutionEnvironment |
_parentEnv
|
protected static java.util.Hashtable |
_printStreams
|
protected static java.util.Hashtable |
_streamContexts
|
protected static java.util.Hashtable |
_streams
|
java.lang.Object |
_tempObject
|
java.lang.String |
_tempRef
|
protected static boolean |
_traceValue
|
java.util.Hashtable |
_variablesRefValues
|
Constructor Summary | |
---|---|
ExecutionEnvironment()
Default constructor |
Method Summary | |
---|---|
void |
addInputObject(java.lang.String name,
java.lang.Object obj)
Adds an input object |
protected java.io.OutputStream |
addOutputStream(java.lang.String uri,
java.io.OutputStream stream,
java.lang.String context)
Adds an output stream |
void |
addVariable(VariableDeclaration var)
adds a variable |
void |
addVariableInfo(java.lang.String refName,
java.lang.String varName,
java.lang.Object modelElement,
java.lang.String value)
|
void |
addVariables(java.util.List variables)
Adds a list of variables (includes checking for exsistence) |
static java.lang.Object |
assignValue(java.lang.String type,
java.lang.Object input,
java.lang.Object assignValue,
AssignmentOperator operator)
Returns the assign value |
java.lang.Object |
assignVariableValue(java.lang.String varName,
java.lang.Object value,
AssignmentOperator operator,
ValueExpression assignedExpression)
Assignes a value to a variable |
void |
clean()
Cleans current streams, streams and calls cleanLocal |
protected void |
cleanLocal()
Cleans the environment |
static void |
cleanResources()
|
void |
clearInputObject(java.lang.String name)
Clears an object with a given name |
void |
clearReferenceCache()
Clears all cached refrences |
void |
endUnprotectedBlock()
|
protected void |
finalize()
|
VariableDeclaration |
findVariable(java.lang.String varName)
Searches for a given variable name |
java.lang.Object |
getCachedReference(java.lang.String refName)
Retrieves an already chached refrence as an object |
java.io.PrintStream |
getCurrentPrintStream()
|
java.io.OutputStream |
getCurrentStream()
|
protected java.lang.String |
getCurrentStreamUri()
Gets the current stream's URI |
org.modelware.modelbus.adapter.frm.FileResourcesType |
getFileModel()
Iterats the generated results and populates a EMF File Model (the frm model) |
static java.lang.String |
getIndent()
Returns the indent string |
java.lang.Object |
getInputObject(java.lang.String name)
Gets an input object |
int |
getIteratorCount()
The counter for an iterator index in a forEach The counter value is relative to the filter applied |
int |
getIteratorPosition()
The "position" of an iterator index in a forEach iterator statement, relative to the full contents of the source of the iterator - i.e. ignoring any filter on the iterator |
int |
getLineNumber()
Traceability testing |
java.io.OutputStream |
getOutputStream(java.lang.String uri)
Gets the output stream from the environment, if null returns the parent environment's output stream |
protected java.io.OutputStream |
getOutputStreamForContext(java.lang.String context)
Gets an output stream for a given context |
ExecutionEnvironment |
getParentEnvironment()
Gets the execution environment's parent environment |
protected java.io.PrintStream |
getPrintStreamForContext(java.lang.String context)
|
static java.util.Vector |
getResources()
|
boolean |
getUseFileModel()
The value of useFileModel defines if a file model is used rather than physical files |
boolean |
getUseLog()
|
VariableDeclaration |
getVariable(java.lang.String varName)
Fetches a variable by name |
org.eclipse.emf.ecore.EObject |
getVariableEObject(java.lang.String key)
Gets the EObject that the variable is refering |
java.lang.Object |
getVariableImplementation(java.lang.String varName)
Retrurns the implementation of a variable If the variable implementation has not been instantiatied, this is done here. |
java.lang.Object |
getVariableInfo(java.lang.String key)
Retrieves the variable information object TraceVariableInfo. |
java.lang.String |
getVariableRefName(java.lang.String key)
Gets the ref name E.g self.name |
java.lang.String |
getVariableValue(java.lang.String key)
Gets the value of self. ... e.g. |
void |
increaseIteratorCount()
Increases iterator counter |
void |
increaseIteratorPosition()
Increase position counter |
static void |
increaseLineNumber(java.lang.String s)
Traceability testing Handels line number in file |
static void |
indent()
Increases the indentation for printing |
void |
initIteratorCounters()
Resets itarator counters |
boolean |
isInPrintAction()
|
boolean |
isUnprotectedBlock()
Checks if a block is unprotected |
void |
log(java.lang.String s)
Logs the string with date |
void |
notifyMessage(java.lang.String msg)
notifies about some events.... |
void |
print(java.lang.String s,
boolean println)
Prints a string to the correct context |
void |
println(java.lang.String s)
|
void |
removeVariable(VariableDeclaration var)
Removes a given VariableDeclaration from the collection |
void |
removeVariableInfo(java.lang.String varName)
|
static void |
resetBlockCounter()
|
void |
setCachedReference(java.lang.String refname,
java.lang.Object value)
Puts a refrence into the cache |
void |
setCurrentStream(java.lang.String contextReference)
Set the current stream |
void |
setCurrentStream(java.lang.String uri,
java.lang.String context)
Creates a new file and stream |
void |
setInPrintAction(boolean inPrintAction)
/* TODO Trace testing: remove public String getInputObjectKey(Object o){ Iterator i = _inputobjects.values().iterator(); while(i.hasNext()){ if(i.next().equals(o)){ } } return "a"; } /** TraceEnv 150, 152 |
void |
setOwnerStack(RuleExecutionStack stack)
Sets the owner stack |
void |
setParentEnvironment(ExecutionEnvironment parent)
Sets the parent environment |
static void |
setPrintContext(java.lang.String context)
Sets the print context |
void |
setRootDirectory(java.lang.String rootDir)
Defines the root directory for file generation |
static void |
setTrace(boolean tV)
Traceability testing Set if print statement and not stdout |
void |
setTypeForVariable(VariableDeclaration varDecl,
java.lang.Object varValue)
Sets the type of a variable |
void |
setUnprotectedBlock(boolean unprotected)
|
void |
setUseFileModel(boolean useModel)
Defines if a file model shall be used rather than writing to physical files. |
void |
setUseLog(boolean useLog)
Defines the execution should use a system log or not. |
void |
setUseParentCache(boolean useParentCache)
Sets if the parent cache is to be used |
void |
setVariable(java.lang.String varName,
VariableDeclaration val)
Puts the variable into the _variables Hashtable |
boolean |
setVariableInfo(java.lang.String refName,
java.lang.String varName,
java.lang.Object modelElement,
java.lang.String value)
Inserts a variable that should be traced into the Hashtable _variablesRefValues |
void |
startUnprotectedBlock(java.lang.String objectUri)
|
void |
storeFiles()
|
static void |
undent()
Decreases the indentation for printing |
static boolean |
useIndent()
Whether indenting is used or not |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static java.util.Hashtable _streams
protected static java.util.Hashtable _printStreams
protected static java.util.Hashtable _streamContexts
protected ExecutionEnvironment _parentEnv
protected java.io.OutputStream _currentStream
protected static int _lineNumber
protected static java.util.Hashtable _offsets
protected static boolean _traceValue
protected boolean _inPrintAction
protected static java.lang.String _openFileUri
protected static long _blockCounter
protected java.lang.String _objectId
public java.lang.Object _tempObject
public java.lang.String _tempRef
public java.util.Hashtable _variablesRefValues
Constructor Detail |
---|
public ExecutionEnvironment()
Method Detail |
---|
public void setUseFileModel(boolean useModel)
useModel
- public boolean getUseFileModel()
public void setUseLog(boolean useLog)
useLog
- public boolean getUseLog()
public org.modelware.modelbus.adapter.frm.FileResourcesType getFileModel()
public void setRootDirectory(java.lang.String rootDir)
rootDir
- public static void indent()
public static void undent()
public static java.lang.String getIndent()
public static boolean useIndent()
public VariableDeclaration getVariable(java.lang.String varName)
varName
-
public void notifyMessage(java.lang.String msg)
msg
- public int getIteratorCount()
public int getIteratorPosition()
public void initIteratorCounters()
public void increaseIteratorCount()
public void increaseIteratorPosition()
public java.lang.Object getVariableImplementation(java.lang.String varName)
varName
-
public void setTypeForVariable(VariableDeclaration varDecl, java.lang.Object varValue)
varDecl
- varValue
- public java.lang.Object assignVariableValue(java.lang.String varName, java.lang.Object value, AssignmentOperator operator, ValueExpression assignedExpression)
varName
- value
- public static java.lang.Object assignValue(java.lang.String type, java.lang.Object input, java.lang.Object assignValue, AssignmentOperator operator)
input
- assignValue
- operator
-
public void setVariable(java.lang.String varName, VariableDeclaration val)
varName
- val
- public VariableDeclaration findVariable(java.lang.String varName)
varName
-
public ExecutionEnvironment getParentEnvironment()
public void setParentEnvironment(ExecutionEnvironment parent)
parent
- public void setOwnerStack(RuleExecutionStack stack)
stack
- public void addVariables(java.util.List variables)
variables
- public void addVariable(VariableDeclaration var)
var
- public void removeVariable(VariableDeclaration var)
var
- public java.lang.Object getInputObject(java.lang.String name)
name
-
public void addInputObject(java.lang.String name, java.lang.Object obj)
name
- obj
- public void clearInputObject(java.lang.String name)
name
- public void setUseParentCache(boolean useParentCache)
useParentCache
- public java.lang.Object getCachedReference(java.lang.String refName)
refName
-
public void setCachedReference(java.lang.String refname, java.lang.Object value)
refname
- value
- public void clearReferenceCache()
protected java.io.OutputStream addOutputStream(java.lang.String uri, java.io.OutputStream stream, java.lang.String context)
uri
- stream
- context
-
protected java.io.OutputStream getOutputStreamForContext(java.lang.String context)
context
-
protected java.io.PrintStream getPrintStreamForContext(java.lang.String context)
public java.io.OutputStream getOutputStream(java.lang.String uri)
uri
-
public void setCurrentStream(java.lang.String uri, java.lang.String context)
uri
- context
- public void setCurrentStream(java.lang.String contextReference)
contextReference
- public java.io.OutputStream getCurrentStream()
public java.io.PrintStream getCurrentPrintStream()
protected java.lang.String getCurrentStreamUri()
public void storeFiles()
public void clean()
protected void cleanLocal()
public static void setPrintContext(java.lang.String context)
context
- public void print(java.lang.String s, boolean println)
s
- println
- public void log(java.lang.String s)
s
- public void println(java.lang.String s)
public static java.util.Vector getResources()
public static void cleanResources()
protected void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
java.lang.Throwable
public void setInPrintAction(boolean inPrintAction)
public boolean isInPrintAction()
public static void setTrace(boolean tV)
tV
- public static void increaseLineNumber(java.lang.String s)
s
- TODO TRACE rewritepublic int getLineNumber()
public static void resetBlockCounter()
public void startUnprotectedBlock(java.lang.String objectUri)
objectUri
- public void endUnprotectedBlock()
public boolean isUnprotectedBlock()
public void setUnprotectedBlock(boolean unprotected)
public boolean setVariableInfo(java.lang.String refName, java.lang.String varName, java.lang.Object modelElement, java.lang.String value)
refName
- varName
- modelElement
- public void addVariableInfo(java.lang.String refName, java.lang.String varName, java.lang.Object modelElement, java.lang.String value)
public void removeVariableInfo(java.lang.String varName)
public java.lang.Object getVariableInfo(java.lang.String key)
key
- The name of the variable
public org.eclipse.emf.ecore.EObject getVariableEObject(java.lang.String key)
key
- The name of the variable
public java.lang.String getVariableRefName(java.lang.String key)
key
- The name of the variable
public java.lang.String getVariableValue(java.lang.String key)
key
- The name of the variable
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |