org.apache.velocity.runtime
Class VelocimacroManager
java.lang.Object
org.apache.velocity.runtime.VelocimacroManager
public class VelocimacroManager
extends java.lang.Object
Manages VMs in namespaces. Currently, two namespace modes are
supported:
- flat - all allowable VMs are in the global namespace
- local - inline VMs are added to it's own template namespace
Thanks to
Jose Alberto Fernandez
for some ideas incorporated here.
Version:
- Geir Magnusson Jr.
- Jose Alberto Fernandez
private Hashtable | addNamespace(String namespace) - adds a namespace to the namespaces
|
boolean | addVM(String vmName, String macroBody, argArray[] , String namespace) - Adds a VM definition to the cache.
|
boolean | dumpNamespace(String namespace) - Removes the VMs and the namespace from the manager.
|
VelocimacroProxy | get(String vmName, String namespace) - gets a new living VelocimacroProxy object by the
name / source template duple
|
String | getLibraryName(String vmName, String namespace)
|
private Hashtable | getNamespace(String namespace) - returns the hash for the specified namespace.
|
private Hashtable | getNamespace(String namespace, boolean addIfNew) - returns the hash for the specified namespace, and if it doesn't exist
will create a new one and add it to the namespaces
|
void | setNamespaceUsage(boolean b) - public switch to let external user of manager to control namespace
usage indep of properties.
|
void | setRegisterFromLib(boolean b)
|
void | setTemplateLocalInlineVM(boolean b)
|
private boolean | usingNamespaces(String namespace) - determines if currently using namespaces.
|
GLOBAL_NAMESPACE
private static String GLOBAL_NAMESPACE
inlineLocalMode
private boolean inlineLocalMode
libraryMap
private Hashtable libraryMap
map of names of library tempates/namespaces
namespaceHash
private Hashtable namespaceHash
Hash of namespace hashes.
namespacesOn
private boolean namespacesOn
registerFromLib
private boolean registerFromLib
VelocimacroManager
(package private) VelocimacroManager(RuntimeServices rs)
Adds the global namespace to the hash.
addNamespace
private Hashtable addNamespace(String namespace)
adds a namespace to the namespaces
namespace
- name of namespace to add
- Hash added to namespaces, ready for use
addVM
public boolean addVM(String vmName,
String macroBody,
argArray[] ,
String namespace)
Adds a VM definition to the cache.
- Whether everything went okay.
dumpNamespace
public boolean dumpNamespace(String namespace)
Removes the VMs and the namespace from the manager.
Used when a template is reloaded to avoid
accumulating drek
namespace
- namespace to dump
- boolean representing success
get
public VelocimacroProxy get(String vmName,
String namespace)
gets a new living VelocimacroProxy object by the
name / source template duple
getLibraryName
public String getLibraryName(String vmName,
String namespace)
getNamespace
private Hashtable getNamespace(String namespace)
returns the hash for the specified namespace. Will not create a new one
if it doesn't exist
namespace
- name of the namespace :)
- namespace Hashtable of VMs or null if doesn't exist
getNamespace
private Hashtable getNamespace(String namespace,
boolean addIfNew)
returns the hash for the specified namespace, and if it doesn't exist
will create a new one and add it to the namespaces
namespace
- name of the namespace :)addIfNew
- flag to add a new namespace if it doesn't exist
- namespace Hashtable of VMs or null if doesn't exist
setNamespaceUsage
public void setNamespaceUsage(boolean b)
public switch to let external user of manager to control namespace
usage indep of properties. That way, for example, at startup the
library files are loaded into global namespace
setRegisterFromLib
public void setRegisterFromLib(boolean b)
setTemplateLocalInlineVM
public void setTemplateLocalInlineVM(boolean b)
usingNamespaces
private boolean usingNamespaces(String namespace)
determines if currently using namespaces.
namespace
- currently ignored
- true if using namespaces, false if not
Copyright B) 2002 Apache Software Foundation. All Rights Reserved.