
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 = "@" |
| ERXSimpleTemplateParser | ( | String | undefinedKeyLabel | ) |
Returns a parser object with the given string as the undefined key label
| 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.
| 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 |
| Object doGetValue | ( | String | aKeyPath, | |
| Object | anObject | |||
| ) | [protected] |
Calculates the set of keys used in a given template for a given delimiter.
| template | to check for keys | |
| delimiter | for finding keys |
| static String parseTemplatedStringWithObject | ( | String | templateString, | |
| Object | templateObject | |||
| ) | [static] |
Parses the given templateString with an ERXSimpleTemplateParser.
| templateString | the template string to parse | |
| templateObject | the object to bind to |
| 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.
| 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 |
Cover method for calling the four argument method passing in null for the otherObject parameter. See that method for documentation.
| 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.
| newSharedInstance | the parser object that will be shared |
| static ERXSimpleTemplateParser sharedInstance | ( | ) | [static] |
Convience method to return the shared instance of the template parser.
| boolean useOldDelimiter | ( | ) | [protected] |
ERXSimpleTemplateParser _sharedInstance [static, private] |
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
1.5.8