Adds an attribute to a subrange of the string.
|the attribute key|
|The value of the attribute. May be null.|
|Index of the first character of the range.|
|Index of the character following the last character of the range.|
| if |
|if beginIndex is less then 0, endIndex is greater than the length of the string, or beginIndex and endIndex together don't define a non-empty subrange of the string.|