StringDescription Class
The default implementation of IDescription. This should rarely need substitution, although conceivably it is a place where other languages could be supported.
Implements
Constructors
Code new StringDescription([String init = '']) #
Initialize the description with initial contents init.
StringDescription([String init = '']) { _out = init; }
Methods
Code Description add(String text) #
Append some plain text to the description.
Description add(String text) { _out = '${_out}${text}'; return this; }
Code Description addAll(String start, String separator, String end, Iterable list) #
Append an [Iterable] [list] of objects to the description, using the specified separator and framing the list with start and end.
Description addAll(String start, String separator, String end, Iterable list) { var separate = false; add(start); for (var item in list) { if (separate) { add(separator); } addDescriptionOf(item); separate = true; } add(end); return this; }
Code Description addDescriptionOf(value) #
Appends a description of value. If it is an IMatcher use its describe method; if it is a string use its literal value after escaping any embedded control characters; otherwise use its toString() value and wrap it in angular "quotes".
Description addDescriptionOf(value) { if (value is Matcher) { value.describe(this); } else if (value is String) { _addEscapedString(value); } else { String description = (value == null) ? "null" : value.toString(); if (description.startsWith('<') && description.endsWith('>')) { add(description); } else { add('<'); add(description); add('>'); } } return this; }
Code Description replace(String text) #
Change the value of the description.
Description replace(String text) { _out = text; return this; }