org.webmacro.engine
Class BuildContext

java.lang.Object
  extended byorg.webmacro.Context
      extended byorg.webmacro.engine.BuildContext
All Implemented Interfaces:
java.lang.Cloneable, java.util.Map
Direct Known Subclasses:
MacroBuildContext

public class BuildContext
extends Context

Contains data structures which are manipulated during the builder phase of parsing. It extends Map so that user provided directives can store information in it during the builder phase. Although WebMacro's built in directives make no use of this hashtable (they use the other structures added in the derived class), other user provided directives might. Therefore you should adopt a sensible naming scheme for your keys, to avoid conflicting with keys inserted by someone else.


Nested Class Summary
 
Nested classes inherited from class org.webmacro.Context
Context.TemplateEvaluationContext
 
Nested classes inherited from class java.util.Map
java.util.Map.Entry
 
Constructor Summary
BuildContext(Broker b)
           
 
Method Summary
 void addFilter(Variable var, Filter ft)
          Register a new filter, adding it to the chain for the supplied name.
 void clearFilters(Variable var)
          Clear all the filtered for the supplied name.
 Macro getFilterMacro(Variable v)
          Get the filter that applies to a specific variable.
 MacroDefinition getMacro(java.lang.String name)
          Search for a MacroDefinition in the build context
 java.util.Map getMacros()
          Return the map of MacroDefinitions
 Parser getParser(java.lang.String pname)
           
 java.lang.Object getVariableType(java.lang.String name)
          Find out whether the named variable is a tool, local variable, or property variable.
 void mergeConstants(Template t)
          Add #macros and #params from the specified Template to this bulid context
 void putMacro(java.lang.String name, MacroDefinition macro)
          Add a MacroDefinition to the build context
 void setVariableType(java.lang.String name, java.lang.Object type)
          Declare whether the named variable is to be treated as a tool, local variable, or property variable type.
 
Methods inherited from class org.webmacro.Context
clear, clone, cloneContext, containsKey, containsValue, entrySet, get, getBroker, getCurrentLocation, getEvaluationExceptionHandler, getLog, getLog, getMap, getPool, getProperty, getProperty, getTemplateEvaluationContext, internalGet, internalGet, isEmpty, isTiming, keySet, loadTools, put, put, put, put, put, put, put, put, put, put, putAll, putFunction, putGlobalFunction, recycle, remove, set, setEvaluationExceptionHandler, setMap, setPool, setProperty, setProperty, size, startTiming, startTiming, startTiming, startTiming, startTiming, stopTiming, toString, values
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Constructor Detail

BuildContext

public BuildContext(Broker b)
Method Detail

getParser

public final Parser getParser(java.lang.String pname)
                       throws NotFoundException
Throws:
NotFoundException

getVariableType

public java.lang.Object getVariableType(java.lang.String name)
Find out whether the named variable is a tool, local variable, or property variable.


setVariableType

public void setVariableType(java.lang.String name,
                            java.lang.Object type)
Declare whether the named variable is to be treated as a tool, local variable, or property variable type.


addFilter

public void addFilter(Variable var,
                      Filter ft)
Register a new filter, adding it to the chain for the supplied name. The name is either a top level property name or * to mean "all".

Parameters:
var - the top level property name that is being filtered
ft - the Filter which will handle this property

clearFilters

public void clearFilters(Variable var)
Clear all the filtered for the supplied name. Cleaing * clears only global filters, leaving filters for specific properties.


getFilterMacro

public Macro getFilterMacro(Variable v)
Get the filter that applies to a specific variable. Returning null from this method means that the entire variable should be dropped from the output since it's been filtered to null.

Returns:
the Macro to be used to filter it, or null

putMacro

public void putMacro(java.lang.String name,
                     MacroDefinition macro)
Add a MacroDefinition to the build context


getMacro

public MacroDefinition getMacro(java.lang.String name)
Search for a MacroDefinition in the build context


mergeConstants

public void mergeConstants(Template t)
Add #macros and #params from the specified Template to this bulid context


getMacros

public java.util.Map getMacros()
Return the map of MacroDefinitions