atg.search.query.formhandlers
Class XMLTagBuilderVisitor

java.lang.Object
  extended by atg.search.query.formhandlers.TagBuilder
      extended by atg.search.query.formhandlers.XMLTagBuilderVisitor
All Implemented Interfaces:
HashMapMapVisitor

public class XMLTagBuilderVisitor
extends TagBuilder
implements HashMapMapVisitor

This class recursively visits a map that may contain other maps and from the HashMap data builds one or more XML tags. The hashmaps have keys that are strings and values that are either strings or other hashmaps. The recognized keys include:


Field Summary
static java.lang.String CLASS_VERSION
          Class version string
 
Fields inherited from class atg.search.query.formhandlers.TagBuilder
ATTRIBUTES_KEY, BODY_KEY, NESTED_ATTR, OPTIONS_KEY, TAGNAME_KEY
 
Constructor Summary
XMLTagBuilderVisitor()
          Create a builder with an initially empty buffer and a zero indent value.
XMLTagBuilderVisitor(java.lang.StringBuffer pBuffer)
          Create a builder which will use an existing string buffer
XMLTagBuilderVisitor(java.lang.StringBuffer pBuffer, int pInitialIndent, java.lang.String pNestedTagRegex)
          Create a builder which will use an existing string buffer and which also uses the specified indentation level
 
Method Summary
 void depart(java.lang.Object pKey, java.util.Map pMap)
          We've enjoyed our visit with this tag but now it's time to say goodbye.
protected  boolean shouldGenerate(java.util.Map pOptions)
          Return true if the preprocessor has set the "__generate" key to to "true" or if it is not present.
 boolean visit(java.lang.Object pKey, java.util.Map pMap)
          Visit a HashMap and possibly generate some XML
 
Methods inherited from class atg.search.query.formhandlers.TagBuilder
addIndent, escape, escape, formatAttributes, getIndent, getMapValueOrNull, getNestedTagPattern, getParentTag, getStringBuffer, getStringValueOrNull, getTagName, hasValue, indent, isNested, setIndent, unindent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_VERSION

public static java.lang.String CLASS_VERSION
Class version string

Constructor Detail

XMLTagBuilderVisitor

public XMLTagBuilderVisitor()
Create a builder with an initially empty buffer and a zero indent value.


XMLTagBuilderVisitor

public XMLTagBuilderVisitor(java.lang.StringBuffer pBuffer)
Create a builder which will use an existing string buffer

Parameters:
pBuffer - string buffer to use

XMLTagBuilderVisitor

public XMLTagBuilderVisitor(java.lang.StringBuffer pBuffer,
                            int pInitialIndent,
                            java.lang.String pNestedTagRegex)
Create a builder which will use an existing string buffer and which also uses the specified indentation level

Parameters:
pBuffer - string buffer to use
pInitialIndent - initial indentation level
pNestedTagRegex - the regular expression matching tags which can contain other tags or null for default
Throws:
PatternSyntaxException - If the expression's syntax is invalid
Method Detail

visit

public boolean visit(java.lang.Object pKey,
                     java.util.Map pMap)
Visit a HashMap and possibly generate some XML

Specified by:
visit in interface HashMapMapVisitor
Parameters:
pKey - key under which the map is stored in parent map or null if this is the root map. This value is probably only useful for informational messages
pHashMapMap - the map
Returns:
true to recursively visit child tags, false otherwise

depart

public void depart(java.lang.Object pKey,
                   java.util.Map pMap)
We've enjoyed our visit with this tag but now it's time to say goodbye. This method is called on the way back up after descending to any child maps/tags. Use this opportunity to close the current tag if necessary.

Specified by:
depart in interface HashMapMapVisitor
Parameters:
pKey - key under which the map is stored in parent map or null if this is the root map
pMap - the map

shouldGenerate

protected boolean shouldGenerate(java.util.Map pOptions)
Return true if the preprocessor has set the "__generate" key to to "true" or if it is not present.

Returns:
true to generate the tag, false otherwise