public void addAttributes ( Map < ? extends Attribute , ? > attributes , int beginIndex , int endIndex ) { if ( attributes == null ) { throw new NullPointerException ( ) ; } if ( beginIndex < 0 || endIndex > length ( ) || beginIndex > endIndex ) { throw new IllegalArgumentException ( "Invalid substring range" ) ; } if ( beginIndex == endIndex ) { if ( attributes . isEmpty ( ) ) return ; throw new IllegalArgumentException ( "Can't add attribute to 0-length text" ) ; } // make sure we have run attribute data vectors if ( runCount == 0 ) { createRunAttributeDataVectors ( ) ; } // break up runs if necessary int beginRunIndex = ensureRunBreak ( beginIndex ) ; int endRunIndex = ensureRunBreak ( endIndex ) ; Iterator iterator = attributes . entrySet ( ) . iterator ( ) ; while ( iterator . hasNext ( ) ) { Map . Entry entry = ( Map . Entry ) iterator . next ( ) ; addAttributeRunData ( ( Attribute ) entry . getKey ( ) , entry . getValue ( ) , beginRunIndex , endRunIndex ) ; } }
Adds a set of attributes to a subrange of the string .