@groovy.util.logging.Slf4j class TextUtils extends java.lang.Object
General-purpose text manipulation utilities.
| Modifiers | Name | Description |
|---|---|---|
static java.lang.String |
VALUE_SEPARATOR |
A generic separator used in some places to concatenate values. |
| Constructor and description |
|---|
TextUtils
() |
| Type Params | Return Type | Name and description |
|---|---|---|
|
static java.lang.StringBuilder |
addFieldForDisplay(java.lang.StringBuilder sb, java.lang.String label, java.lang.String value, java.util.Map options)Adds a single field to the output buffer, formatted for display. |
|
static java.lang.String |
evaluateGString(java.lang.String gString, java.util.Map parameters)Evaluates a given GString with the given parameters. |
|
static java.lang.String |
findLine(java.lang.String page, java.lang.String text)Utility method to find the line in the output with the given text. |
|
protected static java.lang.String |
fixGStringArgument(java.lang.Object o) |
|
static java.util.Map<java.lang.String, java.lang.String> |
parseNameValuePairs(java.lang.String s)Parses the name/value pairs in a string into a Map. |
|
static java.lang.String |
prettyFormat(java.lang.Object map)Pretty format a map/list using JSON syntax. |
|
static java.lang.String |
toStringBase(java.lang.Object obj)Builds the default toString() for the object (class and hashcode). |
| Methods inherited from class | Name |
|---|---|
class java.lang.Object |
java.lang.Object#wait(long, int), java.lang.Object#wait(), java.lang.Object#wait(long), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
A generic separator used in some places to concatenate values. Never use this for parsing of these concatenated strings. This value is not a reserved value and can actually exist in the key strings themselves. This makes parsing difficult. Value: / (slash).
Adds a single field to the output buffer, formatted for display. Enforces the field limit.
sb - The output buffer.label - The field label.value - The value for the field. If null or empty, then does nothing.options - The options (see above).Evaluates a given GString with the given parameters. This is needed because the normal GStrings are limited to the scope of the current method/class. This would force the user to use strings like "${parameters.day}" instead of the simpler "$day".
This method uses simple replacement logic for simple expressions, but falls back to the slower GStringTemplateEngine approach if the more complex forms are used such as "${object.method()}".
Note: The special parameter all is added to the possible parameters for convenience. It is
only added if the parameters does not contain all already.
Note: This includes a fix for Spring messages.properties handling of escaped brackets (& #123;). If no arguments are passed to the message source, then it does not un-escape the {. This method will replace any '& #123;' with {.
gString - The Groovy String with possible replaceable parameters.parameters - The parameters to replace this with.Utility method to find the line in the output with the given text.
page - The total output to the page.text - The text to search for. Finds first occurrence.Parses the name/value pairs in a string into a Map.
s - The source. For example, "required='true' label='ABC' "Pretty format a map/list using JSON syntax.
map - The map/list to format.Builds the default toString() for the object (class and hashcode).
obj - The object.