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:

Thanks to Jose Alberto Fernandez for some ideas incorporated here.

Version:
$Id: VelocimacroManager.java,v 1.16 2002/02/28 05:24:00 geirm Exp $
Author:
Geir Magnusson Jr., Jose Alberto Fernandez

Inner Class Summary
protected  class VelocimacroManager.MacroEntry
          wrapper class for holding VM information
 
Field Summary
private static java.lang.String GLOBAL_NAMESPACE
           
private  boolean inlineLocalMode
           
private  java.util.Hashtable libraryMap
          map of names of library tempates/namespaces
private  java.util.Hashtable namespaceHash
          Hash of namespace hashes.
private  boolean namespacesOn
           
private  boolean registerFromLib
           
private  RuntimeServices rsvc
           
 
Constructor Summary
(package private) VelocimacroManager(RuntimeServices rs)
          Adds the global namespace to the hash.
 
Method Summary
private  java.util.Hashtable addNamespace(java.lang.String namespace)
          adds a namespace to the namespaces
 boolean addVM(java.lang.String vmName, java.lang.String macroBody, java.lang.String[] argArray, java.lang.String namespace)
          Adds a VM definition to the cache.
 boolean dumpNamespace(java.lang.String namespace)
          Removes the VMs and the namespace from the manager.
 VelocimacroProxy get(java.lang.String vmName, java.lang.String namespace)
          gets a new living VelocimacroProxy object by the name / source template duple
 java.lang.String getLibraryName(java.lang.String vmName, java.lang.String namespace)
           
private  java.util.Hashtable getNamespace(java.lang.String namespace)
          returns the hash for the specified namespace.
private  java.util.Hashtable getNamespace(java.lang.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(java.lang.String namespace)
          determines if currently using namespaces.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

rsvc

private RuntimeServices rsvc

GLOBAL_NAMESPACE

private static java.lang.String GLOBAL_NAMESPACE

registerFromLib

private boolean registerFromLib

namespaceHash

private java.util.Hashtable namespaceHash
Hash of namespace hashes.

libraryMap

private java.util.Hashtable libraryMap
map of names of library tempates/namespaces

namespacesOn

private boolean namespacesOn

inlineLocalMode

private boolean inlineLocalMode
Constructor Detail

VelocimacroManager

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

addVM

public boolean addVM(java.lang.String vmName,
                     java.lang.String macroBody,
                     java.lang.String[] argArray,
                     java.lang.String namespace)
Adds a VM definition to the cache.
Returns:
Whether everything went okay.

get

public VelocimacroProxy get(java.lang.String vmName,
                            java.lang.String namespace)
gets a new living VelocimacroProxy object by the name / source template duple

dumpNamespace

public boolean dumpNamespace(java.lang.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

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)

getNamespace

private java.util.Hashtable getNamespace(java.lang.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 java.util.Hashtable getNamespace(java.lang.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

addNamespace

private java.util.Hashtable addNamespace(java.lang.String namespace)
adds a namespace to the namespaces
Parameters:
namespace - name of namespace to add
Returns:
Hash added to namespaces, ready for use

usingNamespaces

private boolean usingNamespaces(java.lang.String namespace)
determines if currently using namespaces.
Parameters:
namespace - currently ignored
Returns:
true if using namespaces, false if not

getLibraryName

public java.lang.String getLibraryName(java.lang.String vmName,
                                       java.lang.String namespace)


Copyright © 2003 Apache Software Foundation. All Rights Reserved.