public class ERXSimpleTemplateParser
extends java.lang.Object
| Properties | |
er.extensions.ERXSimpleTemplateParser.useOldDelimiter | if false, only {@literal @}{@literal @} delimeters are supported (defaults to true) |
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
DEFAULT_DELIMITER
The default delimiter
|
static java.lang.String |
DEFAULT_UNDEFINED_KEY_LABEL
The default label for keys not found while parsing
|
boolean |
isLoggingDisabled
Flag to disable logging.
|
static org.apache.log4j.Logger |
log
logging support
|
| Constructor and Description |
|---|
ERXSimpleTemplateParser()
Returns a parser object with the default undefined label
|
ERXSimpleTemplateParser(java.lang.String undefinedKeyLabel)
Returns a parser object with the given string as the undefined key label
|
ERXSimpleTemplateParser(java.lang.String undefinedKeyLabel,
boolean useOldDelimiter)
Returns a parser object with the given string as the undefined key label.
|
| Modifier and Type | Method and Description |
|---|---|
protected java.lang.Object |
doGetValue(java.lang.String aKeyPath,
java.lang.Object anObject)
To allow flexibility of the variable provider object type we use similar
logic to NSDictionary valueForKeyPath.
|
NSArray |
keysInTemplate(java.lang.String template,
java.lang.String delimiter)
Calculates the set of keys used in a given template
for a given delimiter.
|
static java.lang.String |
parseTemplatedStringWithObject(java.lang.String templateString,
java.lang.Object templateObject)
Parses the given templateString with an ERXSimpleTemplateParser.
|
java.lang.String |
parseTemplateWithObject(java.lang.String template,
java.lang.String delimiter,
java.lang.Object object)
Cover method for calling the four argument method
passing in
null for the otherObject
parameter. |
java.lang.String |
parseTemplateWithObject(java.lang.String template,
java.lang.String delimiter,
java.lang.Object object,
java.lang.Object otherObject)
This method replaces the keys enclosed between the
delimiter with the values found in object and otherObject.
|
static void |
setSharedInstance(ERXSimpleTemplateParser newSharedInstance)
Sets the shared instance of the template parser.
|
static ERXSimpleTemplateParser |
sharedInstance()
Convience method to return the shared instance
of the template parser.
|
protected boolean |
useOldDelimiter() |
public static final java.lang.String DEFAULT_UNDEFINED_KEY_LABEL
public static final java.lang.String DEFAULT_DELIMITER
public static final org.apache.log4j.Logger log
public boolean isLoggingDisabled
ERXPatternLayout will set
this to true for its internal parser object in order to
prevent an infinite debug logging loop.public ERXSimpleTemplateParser()
DEFAULT_UNDEFINED_KEY_LABELpublic ERXSimpleTemplateParser(java.lang.String undefinedKeyLabel)
undefinedKeyLabel - string as the undefined key label,
for example, "?", "N/A"public ERXSimpleTemplateParser(java.lang.String undefinedKeyLabel,
boolean useOldDelimiter)
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 templatepublic static ERXSimpleTemplateParser sharedInstance()
setSharedInstance(er.extensions.foundation.ERXSimpleTemplateParser)public static void setSharedInstance(ERXSimpleTemplateParser newSharedInstance)
newSharedInstance - the parser object that will be sharedsharedInstance()protected boolean useOldDelimiter()
public NSArray keysInTemplate(java.lang.String template, java.lang.String delimiter)
template - to check for keysdelimiter - for finding keyspublic java.lang.String parseTemplateWithObject(java.lang.String template,
java.lang.String delimiter,
java.lang.Object object)
null for the otherObject
parameter. See that method for documentation.template - to use to parsedelimiter - to use to find keysobject - to resolve keyspublic java.lang.String parseTemplateWithObject(java.lang.String template,
java.lang.String delimiter,
java.lang.Object object,
java.lang.Object otherObject)
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 parsedelimiter - to use to check for keysobject - to resolve keys off ofotherObject - object used to resolve default keysprotected java.lang.Object doGetValue(java.lang.String aKeyPath,
java.lang.Object anObject)
java.util.Properties objects that use keyPath separator (.)
in the property names (which is common) can be reliably used as object
providers.aKeyPath - anObject - aKeypath, or when no key, a keyPath with value
aKeyPathpublic static java.lang.String parseTemplatedStringWithObject(java.lang.String templateString,
java.lang.Object templateObject)
templateString - the template string to parsetemplateObject - the object to bind toCopyright © 2002 – 2022 Project Wonder.