org.apache.velocity.runtime

Class VelocimacroManager

public class VelocimacroManager extends Object

Manages VMs in namespaces. Currently, two namespace modes are supported: Thanks to Jose Alberto Fernandez for some ideas incorporated here.

Version: $Id: VelocimacroManager.java,v 1.17.4.1 2004/03/03 23:22:55 geirm Exp $

Author: Geir Magnusson Jr. Jose Alberto Fernandez

Nested Class Summary
protected classVelocimacroManager.MacroEntry
wrapper class for holding VM information
Field Summary
static StringGLOBAL_NAMESPACE
booleaninlineLocalMode
HashtablelibraryMap
map of names of library tempates/namespaces
HashtablenamespaceHash
Hash of namespace hashes.
booleannamespacesOn
booleanregisterFromLib
RuntimeServicesrsvc
Constructor Summary
VelocimacroManager(RuntimeServices rs)
Adds the global namespace to the hash.
Method Summary
HashtableaddNamespace(String namespace)
adds a namespace to the namespaces
booleanaddVM(String vmName, String macroBody, String[] argArray, String namespace)
Adds a VM definition to the cache.
booleandumpNamespace(String namespace)
Removes the VMs and the namespace from the manager.
VelocimacroProxyget(String vmName, String namespace)
gets a new living VelocimacroProxy object by the name / source template duple
StringgetLibraryName(String vmName, String namespace)
HashtablegetNamespace(String namespace)
returns the hash for the specified namespace.
HashtablegetNamespace(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
voidsetNamespaceUsage(boolean b)
public switch to let external user of manager to control namespace usage indep of properties.
voidsetRegisterFromLib(boolean b)
voidsetTemplateLocalInlineVM(boolean b)
booleanusingNamespaces(String namespace)
determines if currently using namespaces.

Field Detail

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

rsvc

private RuntimeServices rsvc

Constructor Detail

VelocimacroManager

VelocimacroManager(RuntimeServices rs)
Adds the global namespace to the hash.

Method Detail

addNamespace

private Hashtable addNamespace(String namespace)
adds a namespace to the namespaces

Parameters: namespace name of namespace to add

Returns: Hash added to namespaces, ready for use

addVM

public boolean addVM(String vmName, String macroBody, String[] argArray, String namespace)
Adds a VM definition to the cache.

Returns: 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

Parameters: namespace namespace to dump

Returns: 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

Parameters: namespace name of the namespace :)

Returns: 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

Parameters: namespace name of the namespace :) addIfNew flag to add a new namespace if it doesn't exist

Returns: 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.

Parameters: namespace currently ignored

Returns: true if using namespaces, false if not

Copyright B) 2002 Apache Software Foundation. All Rights Reserved.