public class MockNamespace extends Object implements Namespace, JavaOperationExecutor
Constructor and Description |
---|
MockNamespace(Module module)
Creates new instance of
MockNamespace . |
MockNamespace(Module module,
Collection<Namespace> imports)
Creates new instance of
MockNamespace . |
MockNamespace(Module module,
Collection<Namespace> imports,
JavaOperationExecutorFactory executorFactory)
Creates new instance of
MockNamespace . |
MockNamespace(String name)
Creates new instance of
MockNamespace . |
MockNamespace(String name,
Namespace parent)
Creates new instance of
MockNamespace . |
MockNamespace(String name,
Namespace parent,
Collection<Namespace> imports)
Creates new instance of
MockNamespace . |
MockNamespace(String name,
Namespace parent,
Collection<Namespace> imports,
JavaOperationExecutorFactory executorFactory)
Creates new instance of
MockNamespace . |
Modifier and Type | Method and Description |
---|---|
void |
addNewVariable(String name,
Type type,
boolean isExpressionLocal)
Adds a new variable.
|
boolean |
canBeInterpretedIn(InterpreterConfiguration configuration)
Returns true if interpretation with given configuration can be done on this namespace.
|
boolean |
containsVariable(String name)
Returns
true if this namespace contains variable of given name. |
BinaryHolder |
createBinaryHolder(byte[] data)
Creates binary data holder.
|
BinaryHolder |
createBinaryHolder(String datasourceJndi,
String recordType,
String primaryKeyString,
String propertyName,
Blob data)
Creates binary data holder.
|
Namespace |
createChildNamespace(String name,
Collection<Field> fields,
Collection<?> values,
InterpreterConfiguration configuration)
Creates new child namespace with this namespace as the parent.
|
ClosureHolder |
createClosure(ClosureType closureType,
ClosureExpression closureExpression,
ClosureOrigin origin)
Creates new closure corresponding to given closure expression.
|
ClosureHolder |
createClosure(ClosureType closureType,
FunctionExpression operationExpression,
ClosureOrigin origin)
Creates new closure corresponding to given operation expression.
|
ClosureHolder |
createClosure(ClosureType closureType,
MethodExpression operationExpression,
ClosureOrigin origin)
Creates new closure corresponding to given operation expression.
|
ClosureHolder |
createClosureFromExpression(ClosureType closureType,
Expression expression,
ClosureOrigin origin)
Creates new closure from a given expression.
|
RecordHolder |
createExternalRecordProxy(RecordType type)
Creates a proxy without proxied record.
|
ListHolder |
createList(Collection<?> values)
Creates new list with given values (
ListHolder s are immutable). |
MapHolder |
createMap(Map<?,?> values)
Creates new map with given values (
MapHolder s are immutable). |
RecordHolder |
createNonSharedRecord(RecordType type,
Map<String,?> values)
Creates new record of given type.
|
ListHolder |
createRange(long first,
long last)
Creates a range (list) defined by endpoints (both inclusive).
|
RecordHolder |
createRecord(RecordType type)
Creates new record with given type.
|
RecordHolder |
createRecord(RecordType type,
Map<String,?> values)
Creates new record with given type.
|
RecordHolder |
createRecord(String type)
Creates new record with given type.
|
RecordHolder |
createRecord(String type,
Map<String,?> values)
Creates new record with given type.
|
ReferenceHolder |
createReference(ReferenceType referenceType,
ReferenceExpression referenceExpression,
List<Property> properties,
ClosureOrigin origin)
Returns new reference corresponding to given reference expression.
|
SetHolder |
createSet(Collection<?> values)
Creates new set with given values (
SetHolder s are immutable). |
Object |
executeJavaOperation(String className,
String methodName,
Class<?>[] argClasses,
List<Object> evaluatedArgs,
InterpreterStackTrace stackTrace)
Executes the operation.
|
InterpreterConfiguration |
getConfiguration()
Returns interpreter configurartion for this namespace.
|
Object |
getConstantValue(String moduleName,
String constantName)
Returns the value of the constant with the given name from a (imported)
module with a given module name.
|
long |
getContextId()
Returns context id.
|
String |
getEvaluationLevel()
Return evaluation level.
|
Object |
getExecutionContext() |
JavaOperationExecutorFactory |
getExecutorFactory() |
Type |
getFreeType(FreeType type)
Returns the value of given free type or null if it does not exist in this context.
|
HolderFactory |
getHolderFactory()
Returns an instance of
HolderFactory . |
Object |
getJavaObject()
Returns underlying java object if there is some.
|
Namespace |
getLowerLevelNamespace()
Returns namespace corresponding to this namespace on lower level.
|
String |
getModelElementId()
Returns id of model element that is related to this namespace.
|
long |
getModelId()
Returns model id.
|
long |
getModelInstanceId()
Returns model instance id.
|
Collection<String> |
getModuleNames()
Returns collection of all module names.
|
Namespace |
getModuleNamespace(String name)
Returns module namespace by its module name or
null if it does not exist. |
String |
getName()
Returns name of this namespace.
|
Namespace |
getNamespaceInLevel(String evaluationLevel)
Returns namespace in evaluation level.
|
NamespaceModel |
getNamespaceModel()
Returns
NamespaceModel for this namespace. |
Namespace |
getParentNamespace()
Returns parent namespace or
null if this is top namespace. |
QID |
getPathQID()
Returns
QID of the context path. |
RecordHolder |
getThis()
Returns object that represents this.
|
Set<String> |
getVariableNames()
Returns the names of all the variables.
|
Type |
getVariableType(String name)
Returns the type of variable or null if it does not exist.
|
Object |
getVariableValue(String name)
Returns value of variable for given name from this namespace.
|
void |
remove()
INTERNAL API.
|
RecordType |
resolveRecordType(String type)
Resolves record type and returns its type.
|
Type |
resolveType(String type)
Resolves type.
|
void |
setFreeType(FreeType type,
Type value)
Sets value for given free type.
|
void |
setPerformReadOnlyCheck(boolean performReadOnlyCheck)
Allows to enable/disable checking assignment to read only variables.
|
void |
setVariableValue(String name,
Object value)
Sets value of variable for given name from this namespace.
|
String |
toString() |
public MockNamespace(String name)
MockNamespace
.name
- public MockNamespace(Module module)
MockNamespace
.module
- public MockNamespace(Module module, Collection<Namespace> imports)
MockNamespace
.module
- imports
- public MockNamespace(Module module, Collection<Namespace> imports, JavaOperationExecutorFactory executorFactory)
MockNamespace
.module
- imports
- executorFactory
- public MockNamespace(String name, Namespace parent)
MockNamespace
.name
- parent
- public MockNamespace(String name, Namespace parent, Collection<Namespace> imports)
MockNamespace
.name
- parent
- imports
- public MockNamespace(String name, Namespace parent, Collection<Namespace> imports, JavaOperationExecutorFactory executorFactory)
MockNamespace
.name
- parent
- imports
- executorFactory
- public boolean containsVariable(String name)
Namespace
true
if this namespace contains variable of given name.containsVariable
in interface Namespace
name
- variable namepublic Collection<String> getModuleNames()
Namespace
getModuleNames
in interface Namespace
public Namespace getModuleNamespace(String name)
Namespace
null
if it does not exist.getModuleNamespace
in interface Namespace
public String getName()
Namespace
null
and does not have to be
unique. Multiple namespaces can share same name.public Namespace getParentNamespace()
Namespace
null
if this is top namespace.getParentNamespace
in interface Namespace
public Type getVariableType(String name)
Namespace
getVariableType
in interface Namespace
name
- variable namepublic Object getVariableValue(String name)
Namespace
Null
is returned
if this namespace does not contain given variable.getVariableValue
in interface Namespace
name
- variable namepublic void setVariableValue(String name, Object value)
Namespace
setVariableValue
in interface Namespace
name
- variable namevalue
- new variable valuepublic HolderFactory getHolderFactory()
Namespace
HolderFactory
. This can be used to create different runtime
objects.getHolderFactory
in interface Namespace
HolderFactory
public Namespace createChildNamespace(String name, Collection<Field> fields, Collection<?> values, InterpreterConfiguration configuration)
Namespace
fields
.createChildNamespace
in interface Namespace
name
- the namespace namepublic void setFreeType(FreeType type, Type value)
Namespace
setFreeType
in interface Namespace
public Type getFreeType(FreeType type)
Namespace
getFreeType
in interface Namespace
public Set<String> getVariableNames()
Namespace
getVariableNames
in interface Namespace
public ClosureHolder createClosure(ClosureType closureType, ClosureExpression closureExpression, ClosureOrigin origin)
HolderFactory
createClosure
in interface HolderFactory
public ClosureHolder createClosure(ClosureType closureType, FunctionExpression operationExpression, ClosureOrigin origin)
HolderFactory
createClosure
in interface HolderFactory
public ClosureHolder createClosure(ClosureType closureType, MethodExpression operationExpression, ClosureOrigin origin)
HolderFactory
createClosure
in interface HolderFactory
public ClosureHolder createClosureFromExpression(ClosureType closureType, Expression expression, ClosureOrigin origin)
HolderFactory
createClosureFromExpression
in interface HolderFactory
public ListHolder createList(Collection<?> values)
HolderFactory
ListHolder
s are immutable).
The type is inferred from the types of the values.createList
in interface HolderFactory
public ListHolder createRange(long first, long last)
HolderFactory
If first <= last
, the range contains elements first, first + 1, ..., last
.
If first > last
, the range contains elements first, first - 1, ..., last
.
The memory footprint of range in constant (only endpoints and size is stored, not all elements).
createRange
in interface HolderFactory
public MapHolder createMap(Map<?,?> values)
HolderFactory
MapHolder
s are immutable). The
type is inferred from the types of the values.createMap
in interface HolderFactory
public RecordHolder createRecord(RecordType type, Map<String,?> values)
HolderFactory
createRecord
in interface HolderFactory
values
- initial record field valuespublic RecordHolder createNonSharedRecord(RecordType type, Map<String,?> values)
HolderFactory
createNonSharedRecord
in interface HolderFactory
values
- initial record field valuespublic Type resolveType(String type)
Namespace
resolveType
in interface Namespace
public RecordType resolveRecordType(String type)
Namespace
NamespaceModel.findNamedType(QID)
as follows:
final boolean recordExists = getNamespaceModel().findNamedType(QID.parse(type)) != null;
resolveRecordType
in interface Namespace
type
- fully qualified record type, not null.public RecordHolder createRecord(RecordType type)
HolderFactory
createRecord
in interface HolderFactory
public RecordHolder createExternalRecordProxy(RecordType type)
HolderFactory
createExternalRecordProxy
in interface HolderFactory
public RecordHolder createRecord(String type, Map<String,?> values)
HolderFactory
createRecord
in interface HolderFactory
values
- initial record field valuesRecordType
public RecordHolder createRecord(String type)
HolderFactory
createRecord
in interface HolderFactory
RecordType
public ReferenceHolder createReference(ReferenceType referenceType, ReferenceExpression referenceExpression, List<Property> properties, ClosureOrigin origin)
HolderFactory
createReference
in interface HolderFactory
public SetHolder createSet(Collection<?> values)
HolderFactory
SetHolder
s are immutable). The
type is inferred from the types of the values.createSet
in interface HolderFactory
public BinaryHolder createBinaryHolder(byte[] data)
HolderFactory
createBinaryHolder
in interface HolderFactory
public BinaryHolder createBinaryHolder(String datasourceJndi, String recordType, String primaryKeyString, String propertyName, Blob data)
HolderFactory
createBinaryHolder
in interface HolderFactory
public void addNewVariable(String name, Type type, boolean isExpressionLocal)
Namespace
addNewVariable
in interface Namespace
public InterpreterConfiguration getConfiguration()
Namespace
getConfiguration
in interface Namespace
public boolean canBeInterpretedIn(InterpreterConfiguration configuration)
Namespace
canBeInterpretedIn
in interface Namespace
public void setPerformReadOnlyCheck(boolean performReadOnlyCheck)
Namespace
setPerformReadOnlyCheck
in interface Namespace
public Namespace getNamespaceInLevel(String evaluationLevel)
Namespace
getNamespaceInLevel
in interface Namespace
public Object getConstantValue(String moduleName, String constantName)
Namespace
getConstantValue
in interface Namespace
null
if there is no such a constantpublic long getModelId()
Namespace
getModelId
in interface Namespace
public long getModelInstanceId()
Namespace
getModelInstanceId
in interface Namespace
public long getContextId()
Namespace
getContextId
in interface Namespace
public NamespaceModel getNamespaceModel()
Namespace
NamespaceModel
for this namespace.getNamespaceModel
in interface Namespace
NamespaceModel
for this namespacepublic Namespace getLowerLevelNamespace()
Namespace
getLowerLevelNamespace
in interface Namespace
public String getEvaluationLevel()
Namespace
getEvaluationLevel
in interface Namespace
public String getModelElementId()
Namespace
getModelElementId
in interface Namespace
public QID getPathQID()
Namespace
QID
of the context path.getPathQID
in interface Namespace
QID
of the context pathpublic RecordHolder getThis()
Namespace
public Object getJavaObject()
Namespace
getJavaObject
in interface Namespace
public Object getExecutionContext()
getExecutionContext
in interface Namespace
public JavaOperationExecutorFactory getExecutorFactory()
public Object executeJavaOperation(String className, String methodName, Class<?>[] argClasses, List<Object> evaluatedArgs, InterpreterStackTrace stackTrace) throws ErrorException
JavaOperationExecutor
executeJavaOperation
in interface JavaOperationExecutor
stackTrace
- a stack traceErrorException
- the error exceptionCopyright © 2007-2018 Whitestein Technologies. All Rights Reserved.