code: public void addAttribute(Attribute attribute, Object value) {
  
          if (attribute == null) {
              throw new NullPointerException();
          }
  
          int len = length();
          if (len == 0) {
              throw new IllegalArgumentException("Can't add attribute to 0-length text");
          }
  
          addAttributeImpl(attribute, value, 0, len);
      }
docs: Adds an attribute to the entire string.
  @param attribute the attribute key
  @param value the value of the attribute; may be null
  @exception NullPointerException if <code>attribute</code> is null.
  @exception IllegalArgumentException if the AttributedString has length 0
  (attributes cannot be applied to a 0-length range).