public void addAttribute(AttributedCharacterIterator.Attribute attribute,Object value){
  if (attribute == null) {
    throw new NullPointerException("attribute == null");
  }
  if (text.isEmpty()) {
    throw new IllegalArgumentException("text is empty");
  }
  List<Range> ranges=attributeMap.get(attribute);
  if (ranges == null) {
    ranges=new ArrayList<Range>(1);
    attributeMap.put(attribute,ranges);
  }
 else {
    ranges.clear();
  }
  ranges.add(new Range(0,text.length(),value));
}

public void addAttribute ( AttributedCharacterIterator . Attribute attribute , Object value ) { if ( attribute == null ) { throw new NullPointerException ( "attribute == null" ) ; } if ( text . isEmpty ( ) ) { throw new IllegalArgumentException ( "text is empty" ) ; } List < Range > ranges = attributeMap . get ( attribute ) ; if ( ranges == null ) { ranges = new ArrayList < Range > ( 1 ) ; attributeMap . put ( attribute , ranges ) ; } else { ranges . clear ( ) ; } ranges . add ( new Range ( 0 , text . length ( ) , value ) ) ; }
applies a given attribute to this string .
