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 (
ListHolders are immutable). |
MapHolder |
createMap(Map<?,?> values)
Creates new map with given values (
MapHolders 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 (
SetHolders 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)
Namespacetrue if this namespace contains variable of given name.containsVariable in interface Namespacename - variable namepublic Collection<String> getModuleNames()
NamespacegetModuleNames in interface Namespacepublic Namespace getModuleNamespace(String name)
Namespacenull if it does not exist.getModuleNamespace in interface Namespacepublic String getName()
Namespacenull and does not have to be
unique. Multiple namespaces can share same name.public Namespace getParentNamespace()
Namespacenull if this is top namespace.getParentNamespace in interface Namespacepublic Type getVariableType(String name)
NamespacegetVariableType in interface Namespacename - variable namepublic Object getVariableValue(String name)
NamespaceNull is returned
if this namespace does not contain given variable.getVariableValue in interface Namespacename - variable namepublic void setVariableValue(String name, Object value)
NamespacesetVariableValue in interface Namespacename - variable namevalue - new variable valuepublic HolderFactory getHolderFactory()
NamespaceHolderFactory. This can be used to create different runtime
objects.getHolderFactory in interface NamespaceHolderFactorypublic Namespace createChildNamespace(String name, Collection<Field> fields, Collection<?> values, InterpreterConfiguration configuration)
Namespacefields.createChildNamespace in interface Namespacename - the namespace namepublic void setFreeType(FreeType type, Type value)
NamespacesetFreeType in interface Namespacepublic Type getFreeType(FreeType type)
NamespacegetFreeType in interface Namespacepublic Set<String> getVariableNames()
NamespacegetVariableNames in interface Namespacepublic ClosureHolder createClosure(ClosureType closureType, ClosureExpression closureExpression, ClosureOrigin origin)
HolderFactorycreateClosure in interface HolderFactorypublic ClosureHolder createClosure(ClosureType closureType, FunctionExpression operationExpression, ClosureOrigin origin)
HolderFactorycreateClosure in interface HolderFactorypublic ClosureHolder createClosure(ClosureType closureType, MethodExpression operationExpression, ClosureOrigin origin)
HolderFactorycreateClosure in interface HolderFactorypublic ClosureHolder createClosureFromExpression(ClosureType closureType, Expression expression, ClosureOrigin origin)
HolderFactorycreateClosureFromExpression in interface HolderFactorypublic ListHolder createList(Collection<?> values)
HolderFactoryListHolders are immutable).
The type is inferred from the types of the values.createList in interface HolderFactorypublic 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 HolderFactorypublic MapHolder createMap(Map<?,?> values)
HolderFactoryMapHolders are immutable). The
type is inferred from the types of the values.createMap in interface HolderFactorypublic RecordHolder createRecord(RecordType type, Map<String,?> values)
HolderFactorycreateRecord in interface HolderFactoryvalues - initial record field valuespublic RecordHolder createNonSharedRecord(RecordType type, Map<String,?> values)
HolderFactorycreateNonSharedRecord in interface HolderFactoryvalues - initial record field valuespublic Type resolveType(String type)
NamespaceresolveType in interface Namespacepublic RecordType resolveRecordType(String type)
NamespaceNamespaceModel.findNamedType(QID) as follows:
final boolean recordExists = getNamespaceModel().findNamedType(QID.parse(type)) != null;
resolveRecordType in interface Namespacetype - fully qualified record type, not null.public RecordHolder createRecord(RecordType type)
HolderFactorycreateRecord in interface HolderFactorypublic RecordHolder createExternalRecordProxy(RecordType type)
HolderFactorycreateExternalRecordProxy in interface HolderFactorypublic RecordHolder createRecord(String type, Map<String,?> values)
HolderFactorycreateRecord in interface HolderFactoryvalues - initial record field valuesRecordTypepublic RecordHolder createRecord(String type)
HolderFactorycreateRecord in interface HolderFactoryRecordTypepublic ReferenceHolder createReference(ReferenceType referenceType, ReferenceExpression referenceExpression, List<Property> properties, ClosureOrigin origin)
HolderFactorycreateReference in interface HolderFactorypublic SetHolder createSet(Collection<?> values)
HolderFactorySetHolders are immutable). The
type is inferred from the types of the values.createSet in interface HolderFactorypublic BinaryHolder createBinaryHolder(byte[] data)
HolderFactorycreateBinaryHolder in interface HolderFactorypublic BinaryHolder createBinaryHolder(String datasourceJndi, String recordType, String primaryKeyString, String propertyName, Blob data)
HolderFactorycreateBinaryHolder in interface HolderFactorypublic void addNewVariable(String name, Type type, boolean isExpressionLocal)
NamespaceaddNewVariable in interface Namespacepublic InterpreterConfiguration getConfiguration()
NamespacegetConfiguration in interface Namespacepublic boolean canBeInterpretedIn(InterpreterConfiguration configuration)
NamespacecanBeInterpretedIn in interface Namespacepublic void setPerformReadOnlyCheck(boolean performReadOnlyCheck)
NamespacesetPerformReadOnlyCheck in interface Namespacepublic Namespace getNamespaceInLevel(String evaluationLevel)
NamespacegetNamespaceInLevel in interface Namespacepublic Object getConstantValue(String moduleName, String constantName)
NamespacegetConstantValue in interface Namespacenull if there is no such a constantpublic long getModelId()
NamespacegetModelId in interface Namespacepublic long getModelInstanceId()
NamespacegetModelInstanceId in interface Namespacepublic long getContextId()
NamespacegetContextId in interface Namespacepublic NamespaceModel getNamespaceModel()
NamespaceNamespaceModel for this namespace.getNamespaceModel in interface NamespaceNamespaceModel for this namespacepublic Namespace getLowerLevelNamespace()
NamespacegetLowerLevelNamespace in interface Namespacepublic String getEvaluationLevel()
NamespacegetEvaluationLevel in interface Namespacepublic String getModelElementId()
NamespacegetModelElementId in interface Namespacepublic QID getPathQID()
NamespaceQID of the context path.getPathQID in interface NamespaceQID of the context pathpublic RecordHolder getThis()
Namespacepublic Object getJavaObject()
NamespacegetJavaObject in interface Namespacepublic Object getExecutionContext()
getExecutionContext in interface Namespacepublic JavaOperationExecutorFactory getExecutorFactory()
public Object executeJavaOperation(String className, String methodName, Class<?>[] argClasses, List<Object> evaluatedArgs, InterpreterStackTrace stackTrace) throws ErrorException
JavaOperationExecutorexecuteJavaOperation in interface JavaOperationExecutorstackTrace - a stack traceErrorException - the error exceptionCopyright © 2007-2018 Whitestein Technologies. All Rights Reserved.