/** * 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). */ 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); }
/** * 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). */ 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); }
/** * 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. */ 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); }
/** * 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. */ 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); }