org.apache.velocity.runtime
Class VelocimacroManager

java.lang.Object
  |
  +--org.apache.velocity.runtime.VelocimacroManager

public class VelocimacroManager
extends java.lang.Object

VelocimacroManager.java manages VMs in namespaces. Currently, there are two namespace modes supported :

Thanks to Jose Alberto Fernandez for some ideas incorporated here.

Version:
$Id: VelocimacroManager.java,v 1.10 2001/04/22 18:17:41 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 namespaceHash
           
private  boolean namespacesOn
           
 
Constructor Summary
(package private) VelocimacroManager()
          not much to do but add 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
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 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

GLOBAL_NAMESPACE

private static java.lang.String GLOBAL_NAMESPACE

namespaceHash

private java.util.Hashtable namespaceHash

namespacesOn

private boolean namespacesOn

inlineLocalMode

private boolean inlineLocalMode
Constructor Detail

VelocimacroManager

VelocimacroManager()
not much to do but add 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:
boolean if all went ok

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

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


Copyright © 2001 Apache Software Foundation. All Rights Reserved.