public class BuildContext extends Object implements Context
| Modifier and Type | Field and Description |
|---|---|
CompilerOptions.DeprecationWarnings |
deprecationWarnings |
| Constructor and Description |
|---|
BuildContext()
Constructs a new Context object intended for testing.
|
BuildContext(Compiler compiler,
Template objectTemplate)
Constructs a new context for the given root element.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clearSelf() |
IteratorMap |
createIteratorMap() |
LocalVariableMap |
createLocalVariableMap(ListResource argv) |
HashResource |
createRelativeRoot()
Initializes the relative root for this context and returns the old
relative root.
|
Element |
dereferenceVariable(String name,
boolean lookupOnly,
Term[] terms)
Return the Element which corresponds to the given variable name.
|
Element |
executeDmlBlock(Operation dml) |
boolean |
executeDmlValidationBlock(Operation dml,
Element self) |
Map<Path,List<FullType>> |
getBindings()
This method returns an unmodifiable, ordered map of the type bindings.
|
int |
getCallLimit() |
Template |
getCurrentTemplate() |
Set<SourceFile> |
getDependencies()
Returns an unmodifiable copy of the dependencies.
|
CompilerOptions.DeprecationWarnings |
getDeprecationWarnings() |
Element |
getElement(Path path)
Pull the value of an element from a configuration tree.
|
Element |
getElement(Path path,
boolean errorIfNotFound)
Pull the value of an element from a configuration tree.
|
String |
getFinalReason(Path p) |
FullType |
getFullType(String name)
Return the type associated with the given name or null if it doesn't
exist.
|
FunctionDefinition |
getFunction(String name)
Return the function definition associated with the given name or null if
it doesn't exist.
|
Element |
getGlobalVariable(String name)
Return the Element which corresponds to the given variable name without
duplicating the value.
|
int |
getIterationLimit() |
Resource.Iterator |
getIterator(Resource resource)
Get the iterator for the given resource or null if the iterator has not
been registered.
|
Element |
getLocalVariable(String name)
Return the value associated with a local variable.
|
Set<String> |
getObjectDependencies()
Returns an unmodifiable copy of the object dependencies.
|
String |
getObjectName()
Get the name of the object template.
|
Template |
getObjectTemplate()
Returns the object Template which is the basis of this ObjectContext.
|
List<String> |
getRelativeLoadpaths() |
HashResource |
getRoot()
Returns the root element for this context.
|
Element |
getSelf() |
String |
getTraceback(SourceRange sourceRange) |
Element |
getVariable(String name)
Return the Element which corresponds to the given variable name.
|
Template |
globalLoad(String name)
A method to load a template from the global cache.
|
Template |
globalLoad(String name,
boolean lookupOnly)
A method to load a template from the global cache.
|
void |
initializeSelfHolder(SelfHolder selfHolder) |
boolean |
isCompileTimeContext()
This flag indicates if this context is a special one used for the
compile-time evaluation of DML blocks.
|
boolean |
isFinal(Path p) |
boolean |
isSelfFinal() |
Template |
localAndGlobalLoad(String name,
boolean lookupOnly) |
Template |
localLoad(String name)
A method to load a template from the local cache.
|
SourceFile |
lookupFile(String name) |
void |
popTemplate(Level logLevel,
String logMessage) |
void |
printTraceback(SourceRange sourceRange) |
void |
pushTemplate(Template template,
SourceRange sourceRange,
Level logLevel,
String logMessage) |
void |
putElement(Path path,
Element value) |
void |
removeGlobalVariable(String name)
Unconditionally remove a global variable.
|
GlobalVariable |
replaceGlobalVariable(String name,
Element value,
boolean finalFlag)
Replaces the given global variable with the given value.
|
void |
resetSelf(Element newValue) |
void |
restoreIteratorMap(IteratorMap iteratorMap) |
void |
restoreLocalVariableMap(LocalVariableMap localVariableHolder) |
HashResource |
restoreRelativeRoot(HashResource previousValue)
Retrieve and clear the relative root for this context.
|
void |
restoreSelf(SelfHolder self) |
GlobalVariable |
retrieveGlobalVariable(String name) |
SelfHolder |
saveSelf() |
void |
setBinding(Path path,
FullType fullType,
Template template,
SourceRange sourceRange)
This method associates a type definition to a path.
|
void |
setCurrentTemplate(Template template) |
void |
setFinal(Path p) |
void |
setFullType(String name,
FullType fullType,
Template template,
SourceRange sourceRange)
Associate the given type with the given name within this ObjectContext.
|
void |
setFunction(String name,
Operation function,
Template template,
SourceRange sourceRange)
Define the given DML block as a function with the given name in this
context.
|
void |
setGlobalVariable(String name,
Element value)
Set the variable to the given value, preserving the status of the final
flag.
|
void |
setGlobalVariable(String name,
Element value,
boolean finalFlag)
Set the variable to the given value.
|
void |
setGlobalVariable(String name,
GlobalVariable variable)
Set the variable to the given GlobalVariable.
|
void |
setIterator(Resource resource,
Resource.Iterator iterator)
Register a Resource iterator in the context.
|
void |
setLocalVariable(String name,
Element value)
Set the local variable to the given value.
|
void |
setLocalVariable(String name,
Term[] terms,
Element value)
Set the local variable to the given value.
|
void |
setObjectAndLoadpath()
Set the name of the object template.
|
void |
setRelativeLoadpaths(List<String> rpaths) |
void |
turnOffObjectDependencyChecking()
Turn off the object dependency checking.
|
public final CompilerOptions.DeprecationWarnings deprecationWarnings
public BuildContext()
public BuildContext(Compiler compiler, Template objectTemplate)
compiler - reference to the compiler and optionsobjectTemplate - An "object" Template to constructpublic Template getObjectTemplate()
getObjectTemplate in interface Contextpublic HashResource getRoot()
public HashResource restoreRelativeRoot(HashResource previousValue)
restoreRelativeRoot in interface ContextpreviousValue - previous value of the relative root to restorepublic HashResource createRelativeRoot()
createRelativeRoot in interface Contextpublic Set<SourceFile> getDependencies()
getDependencies in interface Contextpublic Set<String> getObjectDependencies()
getObjectDependencies in interface Contextpublic void turnOffObjectDependencyChecking()
turnOffObjectDependencyChecking in interface Contextpublic Template localLoad(String name)
public Template globalLoad(String name)
globalLoad in interface Contextpublic Template localAndGlobalLoad(String name, boolean lookupOnly)
localAndGlobalLoad in interface Contextpublic Template globalLoad(String name, boolean lookupOnly)
globalLoad in interface Contextpublic SourceFile lookupFile(String name)
lookupFile in interface Contextpublic LocalVariableMap createLocalVariableMap(ListResource argv)
createLocalVariableMap in interface Contextpublic void restoreLocalVariableMap(LocalVariableMap localVariableHolder)
restoreLocalVariableMap in interface Contextpublic IteratorMap createIteratorMap()
createIteratorMap in interface Contextpublic void restoreIteratorMap(IteratorMap iteratorMap)
restoreIteratorMap in interface Contextpublic void setObjectAndLoadpath()
setObjectAndLoadpath in interface Contextpublic String getObjectName()
ContextgetObjectName in interface Contextpublic FunctionDefinition getFunction(String name)
getFunction in interface Contextname - name of the function to retrievepublic void setFunction(String name, Operation function, Template template, SourceRange sourceRange) throws EvaluationException
setFunction in interface Contextname - name for the functionfunction - code for the function as a DML blocktemplate - template in which this function is defined (used for error
handling)sourceRange - location in the template where this function is defined (used
for error handling)EvaluationException - if a function with the given name already existspublic Map<Path,List<FullType>> getBindings()
getBindings in interface Contextpublic void setBinding(Path path, FullType fullType, Template template, SourceRange sourceRange)
setBinding in interface Contextpath - absolute path to bind to the typefullType - data type to usetemplate - template where the binding was defined (used for error
handling)sourceRange - location in the template where the binding was defined (used
for error handling)public FullType getFullType(String name)
getFullType in interface Contextname - name of the type to retrievepublic void setFullType(String name, FullType fullType, Template template, SourceRange sourceRange) throws EvaluationException
setFullType in interface Contextname - name to associate to the typefullType - data type to use for the definitiontemplate - template where the type is defined (used for error handling)sourceRange - location in the template where the type is defined (used for
error handling)EvaluationException - if there is already a type associated with the given namepublic void setGlobalVariable(String name, Element value)
setGlobalVariable in interface Contextpublic void setGlobalVariable(String name, GlobalVariable variable)
setGlobalVariable in interface Contextname - global variable namevariable - GlobalVariable to associate with namepublic GlobalVariable replaceGlobalVariable(String name, Element value, boolean finalFlag)
replaceGlobalVariable in interface Contextpublic void setGlobalVariable(String name, Element value, boolean finalFlag)
setGlobalVariable in interface Contextpublic void setIterator(Resource resource, Resource.Iterator iterator)
setIterator in interface Contextpublic Resource.Iterator getIterator(Resource resource)
getIterator in interface Contextpublic void removeGlobalVariable(String name)
removeGlobalVariable in interface Contextpublic Element getGlobalVariable(String name)
getGlobalVariable in interface Contextpublic GlobalVariable retrieveGlobalVariable(String name)
retrieveGlobalVariable in interface Contextpublic void pushTemplate(Template template, SourceRange sourceRange, Level logLevel, String logMessage)
pushTemplate in interface Contextpublic void popTemplate(Level logLevel, String logMessage)
popTemplate in interface Contextpublic void printTraceback(SourceRange sourceRange)
printTraceback in interface Contextpublic String getTraceback(SourceRange sourceRange)
getTraceback in interface Contextpublic void setCurrentTemplate(Template template)
setCurrentTemplate in interface Contextpublic Template getCurrentTemplate()
getCurrentTemplate in interface Contextpublic Element getElement(Path path) throws EvaluationException, ValidationException
getElement in interface Contextpath - absolute or external path to lookupEvaluationException - if the path cannot be found or the path is relativeValidationExceptionpublic Element getElement(Path path, boolean errorIfNotFound) throws EvaluationException
getElement in interface Contextpath - path to lookuperrorIfNotFound - if true an EvaluationException will be thrown if the path
can't be foundEvaluationException - if the path can't be found and errorIfNotFound is set, or if
the path is relative and relativeRoot isn't setpublic void putElement(Path path, Element value)
putElement in interface Contextpublic Element executeDmlBlock(Operation dml)
executeDmlBlock in interface Contextpublic boolean executeDmlValidationBlock(Operation dml, Element self) throws ValidationException
executeDmlValidationBlock in interface ContextValidationExceptionpublic Element getLocalVariable(String name)
getLocalVariable in interface Contextname - name of the variable to lookuppublic Element getVariable(String name)
getVariable in interface Contextname - name of the variable to lookuppublic Element dereferenceVariable(String name, boolean lookupOnly, Term[] terms) throws InvalidTermException
dereferenceVariable in interface Contextname - name of the variable to lookuplookupOnly - flag indicating if only a lookup should be doneterms - values for dereferencing the given variableInvalidTermExceptionpublic void setLocalVariable(String name, Element value) throws EvaluationException
setLocalVariable in interface Contextname - name of the local variablevalue - value to use or null to remove the variableEvaluationException - if there is a global variable with the same name as the local
variablepublic void setLocalVariable(String name, Term[] terms, Element value) throws EvaluationException
setLocalVariable in interface Contextname - name of the local variableterms - terms used to dereference the variable, or null if the
variable is to be used directlyvalue - value to use or null to remove the variableEvaluationException - if there is a global variable with the same name as the local
variablepublic int getCallLimit()
getCallLimit in interface Contextpublic int getIterationLimit()
getIterationLimit in interface Contextpublic String getFinalReason(Path p)
getFinalReason in interface Contextpublic boolean isCompileTimeContext()
isCompileTimeContext in interface Contextpublic void initializeSelfHolder(SelfHolder selfHolder)
initializeSelfHolder in interface Contextpublic boolean isSelfFinal()
isSelfFinal in interface Contextpublic SelfHolder saveSelf()
public void restoreSelf(SelfHolder self)
restoreSelf in interface Contextpublic void setRelativeLoadpaths(List<String> rpaths)
setRelativeLoadpaths in interface Contextpublic List<String> getRelativeLoadpaths()
getRelativeLoadpaths in interface Contextpublic CompilerOptions.DeprecationWarnings getDeprecationWarnings()
getDeprecationWarnings in interface ContextCopyright © 2014 Quattor. All Rights Reserved.