org.apache.velocity.runtime

Class VelocimacroManager


public class VelocimacroManager
extends java.lang.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 $

Authors:
Geir Magnusson Jr.
Jose Alberto Fernandez

Nested Class Summary

protected class
VelocimacroManager.MacroEntry
wrapper class for holding VM information

Field Summary

private static String
GLOBAL_NAMESPACE
private boolean
inlineLocalMode
private Hashtable
libraryMap
map of names of library tempates/namespaces
private Hashtable
namespaceHash
Hash of namespace hashes.
private boolean
namespacesOn
private boolean
registerFromLib
private RuntimeServices
rsvc

Constructor Summary

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

Method Summary

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.

Field Details

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 Details

VelocimacroManager

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

Method Details

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,
                     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.