code: public void addAttribute(Attribute attribute, Object value,
              int beginIndex, int endIndex) {
  
          if (attribute == null) {
              throw new NullPointerException();
          }
  
          if (beginIndex < 0 || endIndex > length() || beginIndex >= endIndex) {
              throw new IllegalArgumentException("Invalid substring range");
          }
  
          addAttributeImpl(attribute, value, beginIndex, endIndex);
      }
docs: Adds an attribute to a subrange of the string.
  @param attribute the attribute key
  @param value The value of the attribute. May be null.
  @param beginIndex Index of the first character of the range.
  @param endIndex Index of the character following the last character of the range.
  @exception NullPointerException if <code>attribute</code> is null.
  @exception IllegalArgumentException 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.