public class VelocimacroFactory
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
private static class |
VelocimacroFactory.Twonk
small container class to hold the tuple
of a template and modification time.
|
Modifier and Type | Field and Description |
---|---|
private boolean |
addNewAllowed
controls if new VMs can be added.
|
private boolean |
autoReloadLibrary
determines if the libraries are auto-loaded
when they change
|
private java.util.Map<java.lang.String,VelocimacroFactory.Twonk> |
libModMap
map of the library Template objects
used for reload determination
|
private org.slf4j.Logger |
log
the log for this instance
|
private java.util.List<java.lang.String> |
macroLibVec
vector of the library names
|
private boolean |
replaceAllowed
determines if replacement of global VMs are allowed
controlled by VM_PERM_ALLOW_INLINE_REPLACE_GLOBAL
|
private RuntimeServices |
rsvc
runtime services for this instance
|
private boolean |
templateLocal
sets if template-local namespace in used
|
private VelocimacroManager |
vmManager
VMManager: deal with namespace management
and actually keeps all the VM definitions
|
Constructor and Description |
---|
VelocimacroFactory(RuntimeServices rsvc)
C'tor for the VelociMacro factory.
|
Modifier and Type | Method and Description |
---|---|
boolean |
addVelocimacro(java.lang.String name,
Node macroBody,
java.util.List<Macro.MacroArg> macroArgs,
Template definingTemplate)
Adds a macro to the factory.
|
private boolean |
canAddVelocimacro(java.lang.String name,
Template definingTemplate)
determines if a given macro/namespace (name, source) combo is allowed
to be added
|
private boolean |
getAutoload()
get the switch for automatic reloading of
global library-based VMs
|
private boolean |
getTemplateLocalInline() |
Directive |
getVelocimacro(java.lang.String vmName,
Template renderingTemplate,
Template sourceTemplate)
actual factory: creates a Directive that will
behave correctly wrt getting the framework to
dig out the correct # of args
|
void |
initVelocimacro()
initialize the factory - setup all permissions
load all global libraries.
|
boolean |
isVelocimacro(java.lang.String vm,
Template template)
Tells the world if a given directive string is a Velocimacro
|
private boolean |
setAddMacroPermission(boolean addNewAllowed)
sets the permission to add new macros
|
private void |
setAutoload(boolean b)
set the switch for automatic reloading of
global library-based VMs
|
private boolean |
setReplacementPermission(boolean arg)
sets the permission for allowing addMacro() calls to replace existing VM's
|
private void |
setTemplateLocalInline(boolean b)
sets permission to have VMs local in scope to their declaring template note that this is
really taken care of in the VMManager class, but we need it here for gating purposes in addVM
eventually, I will slide this all into the manager, maybe.
|
private final RuntimeServices rsvc
private org.slf4j.Logger log
private VelocimacroManager vmManager
private boolean replaceAllowed
private boolean addNewAllowed
private boolean templateLocal
private boolean autoReloadLibrary
private java.util.List<java.lang.String> macroLibVec
private java.util.Map<java.lang.String,VelocimacroFactory.Twonk> libModMap
public VelocimacroFactory(RuntimeServices rsvc)
rsvc
- Reference to a runtime services object.public void initVelocimacro()
public boolean addVelocimacro(java.lang.String name, Node macroBody, java.util.List<Macro.MacroArg> macroArgs, Template definingTemplate)
name
- Name of the Macro to add.macroBody
- root node of the parsed macro ASTmacroArgs
- Array of macro arguments, containing the
#macro() arguments and default values. the 0th is the name.definingTemplate
- template containing the macro definitionprivate boolean canAddVelocimacro(java.lang.String name, Template definingTemplate)
name
- Name of VM to adddefiningTemplate
- template containing the source of the macropublic boolean isVelocimacro(java.lang.String vm, Template template)
vm
- Name of the Macro.template
- Source template from which the macro should be loaded.public Directive getVelocimacro(java.lang.String vmName, Template renderingTemplate, Template sourceTemplate)
vmName
- Name of the Macro.renderingTemplate
- destination templatesourceTemplate
- Source template from which the macro should be loaded.private void setTemplateLocalInline(boolean b)
private boolean getTemplateLocalInline()
private boolean setAddMacroPermission(boolean addNewAllowed)
private boolean setReplacementPermission(boolean arg)
private void setAutoload(boolean b)
private boolean getAutoload()