org.mule.util
Class TemplateParser

java.lang.Object
  extended by org.mule.util.TemplateParser

public final class TemplateParser
extends Object

TemplateParser is a simple string parser that will substitute tokens in a string with values supplied in a Map.


Nested Class Summary
static interface TemplateParser.TemplateCallback
           
 
Field Summary
static String ANT_TEMPLATE_STYLE
           
static String CURLY_TEMPLATE_STYLE
           
protected static Log logger
          logger used by this class
static String SQUARE_TEMPLATE_STYLE
           
 
Method Summary
static TemplateParser createAntStyleParser()
           
static TemplateParser createCurlyBracesStyleParser()
           
static TemplateParser createSquareBracesStyleParser()
           
 String getStyle()
           
 boolean isContainsTemplate(String value)
           
 List parse(Map props, List templates)
          Matches one or more templates against a Map of key value pairs.
 Map parse(Map props, Map templates)
          Matches one or more templates against a Map of key value pairs.
 String parse(Map props, String template)
          Matches one or more templates against a Map of key value pairs.
protected  String parse(Map props, String template, TemplateParser.TemplateCallback callback)
           
 Map parse(TemplateParser.TemplateCallback callback, Map templates)
           
 String parse(TemplateParser.TemplateCallback callback, String template)
          Matches one or more templates against a Map of key value pairs.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ANT_TEMPLATE_STYLE

public static final String ANT_TEMPLATE_STYLE
See Also:
Constant Field Values

SQUARE_TEMPLATE_STYLE

public static final String SQUARE_TEMPLATE_STYLE
See Also:
Constant Field Values

CURLY_TEMPLATE_STYLE

public static final String CURLY_TEMPLATE_STYLE
See Also:
Constant Field Values

logger

protected static final Log logger
logger used by this class

Method Detail

createAntStyleParser

public static TemplateParser createAntStyleParser()

createSquareBracesStyleParser

public static TemplateParser createSquareBracesStyleParser()

createCurlyBracesStyleParser

public static TemplateParser createCurlyBracesStyleParser()

parse

public String parse(Map props,
                    String template)
Matches one or more templates against a Map of key value pairs. If a value for a template is not found in the map the template is left as is in the return String

Parameters:
props - the key/value pairs to match against
template - the string containing the template place holders i.e. My name is ${name}
Returns:
the parsed String

parse

public String parse(TemplateParser.TemplateCallback callback,
                    String template)
Matches one or more templates against a Map of key value pairs. If a value for a template is not found in the map the template is left as is in the return String

Parameters:
callback - a callback used to resolve the property name
template - the string containing the template place holders i.e. My name is ${name}
Returns:
the parsed String

parse

protected String parse(Map props,
                       String template,
                       TemplateParser.TemplateCallback callback)

parse

public List parse(Map props,
                  List templates)
Matches one or more templates against a Map of key value pairs. If a value for a template is not found in the map the template is left as is in the return String

Parameters:
props - the key/value pairs to match against
templates - A List of templates
Returns:
the parsed String

parse

public Map parse(Map props,
                 Map templates)
Matches one or more templates against a Map of key value pairs. If a value for a template is not found in the map the template is left as is in the return String

Parameters:
props - the key/value pairs to match against
templates - A Map of templates. The values for each map entry will be parsed
Returns:
the parsed String

parse

public Map parse(TemplateParser.TemplateCallback callback,
                 Map templates)

getStyle

public String getStyle()

isContainsTemplate

public boolean isContainsTemplate(String value)


Copyright © 2003-2008 MuleSource, Inc.. All Rights Reserved.