ERXSimpleTemplateParser Class Reference

Collaboration diagram for ERXSimpleTemplateParser:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 ERXSimpleTemplateParser (String undefinedKeyLabel, boolean useOldDelimiter)
 ERXSimpleTemplateParser (String undefinedKeyLabel)
 ERXSimpleTemplateParser ()
NSArray keysInTemplate (String template, String delimiter)
String parseTemplateWithObject (String template, String delimiter, Object object, Object otherObject)
String parseTemplateWithObject (String template, String delimiter, Object object)

Static Public Member Functions

static String parseTemplatedStringWithObject (String templateString, Object templateObject)
static synchronized void setSharedInstance (ERXSimpleTemplateParser newSharedInstance)
static ERXSimpleTemplateParser sharedInstance ()

Public Attributes

boolean isLoggingDisabled = false

Static Public Attributes

static final String DEFAULT_DELIMITER = "@@"
static final String DEFAULT_UNDEFINED_KEY_LABEL = "?"
static final Logger log = Logger.getLogger(ERXSimpleTemplateParser.class.getName())

Protected Member Functions

Object doGetValue (String aKeyPath, Object anObject)
boolean useOldDelimiter ()

Private Attributes

final String _undefinedKeyLabel
Boolean _useOldDelimiter

Static Private Attributes

static ERXSimpleTemplateParser _sharedInstance
static final String DEPRECATED_DELIMITER = "@"


Constructor & Destructor Documentation

Returns a parser object with the default undefined label

See also:
DEFAULT_UNDEFINED_KEY_LABEL

ERXSimpleTemplateParser ( String  undefinedKeyLabel  ) 

Returns a parser object with the given string as the undefined key label

Parameters:
undefinedKeyLabel string as the undefined key label, for example, "?", "N/A"

ERXSimpleTemplateParser ( String  undefinedKeyLabel,
boolean  useOldDelimiter 
)

Returns a parser object with the given string as the undefined key label. Depending on useOldDelimiter value @ can be used as delimiter if @ is not present in the template.

Parameters:
undefinedKeyLabel string as the undefined key label, for example, "?", "N/A"
useOldDelimiter boolean defining if @ is used as delimiter if @ is not available in the template


Member Function Documentation

Object doGetValue ( String  aKeyPath,
Object  anObject 
) [protected]

NSArray keysInTemplate ( String  template,
String  delimiter 
)

Calculates the set of keys used in a given template for a given delimiter.

Parameters:
template to check for keys
delimiter for finding keys
Returns:
array of keys

static String parseTemplatedStringWithObject ( String  templateString,
Object  templateObject 
) [static]

Parses the given templateString with an ERXSimpleTemplateParser.

Parameters:
templateString the template string to parse
templateObject the object to bind to
Returns:
the parsed template string

String parseTemplateWithObject ( String  template,
String  delimiter,
Object  object,
Object  otherObject 
)

This method replaces the keys enclosed between the delimeter with the values found in object and otherObject. It first looks for a value in object, and then in otherObject if the key is not found in object. Therefore, otherObject is a good place to store default values while object is a good place to override default values.

When the value is not found in both object and otherObject, it will replace the key with the undefined key label which defaults to "?". You can set the label via the constructor ERXSimpleTemplateParser(String). Note that a null result will also output the label, so you might want to have the empty string as the undefined key label.

Parameters:
template to use to parse
delimiter to use to check for keys
object to resolve keys off of
otherObject object used to resolve default keys
Returns:
parsed template with keys replaced

String parseTemplateWithObject ( String  template,
String  delimiter,
Object  object 
)

Cover method for calling the four argument method passing in null for the otherObject parameter. See that method for documentation.

Parameters:
template to use to parse
delimiter to use to find keys
object to resolve keys

static synchronized void setSharedInstance ( ERXSimpleTemplateParser  newSharedInstance  )  [static]

Sets the shared instance of the template parser.

Parameters:
newSharedInstance the parser object that will be shared
See also:
sharedInstance

static ERXSimpleTemplateParser sharedInstance (  )  [static]

Convience method to return the shared instance of the template parser.

Returns:
shared instance of the parser
See also:
setSharedInstance

boolean useOldDelimiter (  )  [protected]


Member Data Documentation

holds a reference to the shared instance of the parser

final String _undefinedKeyLabel [private]

The label that will be appeared where an undefined key is found

Boolean _useOldDelimiter [private]

Defines if @ can be used as alternative delimiter

final String DEFAULT_DELIMITER = "@@" [static]

The default delimiter

final String DEFAULT_UNDEFINED_KEY_LABEL = "?" [static]

The default label for keys not found while parsing

final String DEPRECATED_DELIMITER = "@" [static, private]

The deprecated delimiter

boolean isLoggingDisabled = false

Flag to disable logging. ERXPatternLayout will set this to true for its internal parser object in order to prevent an infinite debug logging loop.

final Logger log = Logger.getLogger(ERXSimpleTemplateParser.class.getName()) [static]

logging support


The documentation for this class was generated from the following file:

Generated on Sat May 26 06:43:14 2012 for Project Wonder by  doxygen 1.5.8