equal
deleted
inserted
replaced
115 } |
115 } |
116 |
116 |
117 /** |
117 /** |
118 * Constructs an AttributedString instance with the given text. |
118 * Constructs an AttributedString instance with the given text. |
119 * @param text The text for this attributed string. |
119 * @param text The text for this attributed string. |
120 * @throws NullPointerException if <code>text</code> is null. |
120 * @throws NullPointerException if {@code text} is null. |
121 */ |
121 */ |
122 public AttributedString(String text) { |
122 public AttributedString(String text) { |
123 if (text == null) { |
123 if (text == null) { |
124 throw new NullPointerException(); |
124 throw new NullPointerException(); |
125 } |
125 } |
128 |
128 |
129 /** |
129 /** |
130 * Constructs an AttributedString instance with the given text and attributes. |
130 * Constructs an AttributedString instance with the given text and attributes. |
131 * @param text The text for this attributed string. |
131 * @param text The text for this attributed string. |
132 * @param attributes The attributes that apply to the entire string. |
132 * @param attributes The attributes that apply to the entire string. |
133 * @throws NullPointerException if <code>text</code> or |
133 * @throws NullPointerException if {@code text} or |
134 * <code>attributes</code> is null. |
134 * {@code attributes} is null. |
135 * @throws IllegalArgumentException if the text has length 0 |
135 * @throws IllegalArgumentException if the text has length 0 |
136 * and the attributes parameter is not an empty Map (attributes |
136 * and the attributes parameter is not an empty Map (attributes |
137 * cannot be applied to a 0-length range). |
137 * cannot be applied to a 0-length range). |
138 */ |
138 */ |
139 public AttributedString(String text, |
139 public AttributedString(String text, |
169 |
169 |
170 /** |
170 /** |
171 * Constructs an AttributedString instance with the given attributed |
171 * Constructs an AttributedString instance with the given attributed |
172 * text represented by AttributedCharacterIterator. |
172 * text represented by AttributedCharacterIterator. |
173 * @param text The text for this attributed string. |
173 * @param text The text for this attributed string. |
174 * @throws NullPointerException if <code>text</code> is null. |
174 * @throws NullPointerException if {@code text} is null. |
175 */ |
175 */ |
176 public AttributedString(AttributedCharacterIterator text) { |
176 public AttributedString(AttributedCharacterIterator text) { |
177 // If performance is critical, this constructor should be |
177 // If performance is critical, this constructor should be |
178 // implemented here rather than invoking the constructor for a |
178 // implemented here rather than invoking the constructor for a |
179 // subrange. We can avoid some range checking in the loops. |
179 // subrange. We can avoid some range checking in the loops. |
190 * |
190 * |
191 * @param text The text for this attributed string. |
191 * @param text The text for this attributed string. |
192 * @param beginIndex Index of the first character of the range. |
192 * @param beginIndex Index of the first character of the range. |
193 * @param endIndex Index of the character following the last character |
193 * @param endIndex Index of the character following the last character |
194 * of the range. |
194 * of the range. |
195 * @throws NullPointerException if <code>text</code> is null. |
195 * @throws NullPointerException if {@code text} is null. |
196 * @throws IllegalArgumentException if the subrange given by |
196 * @throws IllegalArgumentException if the subrange given by |
197 * beginIndex and endIndex is out of the text range. |
197 * beginIndex and endIndex is out of the text range. |
198 * @see java.text.Annotation |
198 * @see java.text.Annotation |
199 */ |
199 */ |
200 public AttributedString(AttributedCharacterIterator text, |
200 public AttributedString(AttributedCharacterIterator text, |
218 * @param endIndex Index of the character following the last character |
218 * @param endIndex Index of the character following the last character |
219 * of the range. |
219 * of the range. |
220 * @param attributes Specifies attributes to be extracted |
220 * @param attributes Specifies attributes to be extracted |
221 * from the text. If null is specified, all available attributes will |
221 * from the text. If null is specified, all available attributes will |
222 * be used. |
222 * be used. |
223 * @throws NullPointerException if <code>text</code> is null. |
223 * @throws NullPointerException if {@code text} is null. |
224 * @throws IllegalArgumentException if the subrange given by |
224 * @throws IllegalArgumentException if the subrange given by |
225 * beginIndex and endIndex is out of the text range. |
225 * beginIndex and endIndex is out of the text range. |
226 * @see java.text.Annotation |
226 * @see java.text.Annotation |
227 */ |
227 */ |
228 public AttributedString(AttributedCharacterIterator text, |
228 public AttributedString(AttributedCharacterIterator text, |
305 |
305 |
306 /** |
306 /** |
307 * Adds an attribute to the entire string. |
307 * Adds an attribute to the entire string. |
308 * @param attribute the attribute key |
308 * @param attribute the attribute key |
309 * @param value the value of the attribute; may be null |
309 * @param value the value of the attribute; may be null |
310 * @throws NullPointerException if <code>attribute</code> is null. |
310 * @throws NullPointerException if {@code attribute} is null. |
311 * @throws IllegalArgumentException if the AttributedString has length 0 |
311 * @throws IllegalArgumentException if the AttributedString has length 0 |
312 * (attributes cannot be applied to a 0-length range). |
312 * (attributes cannot be applied to a 0-length range). |
313 */ |
313 */ |
314 public void addAttribute(Attribute attribute, Object value) { |
314 public void addAttribute(Attribute attribute, Object value) { |
315 |
315 |
329 * Adds an attribute to a subrange of the string. |
329 * Adds an attribute to a subrange of the string. |
330 * @param attribute the attribute key |
330 * @param attribute the attribute key |
331 * @param value The value of the attribute. May be null. |
331 * @param value The value of the attribute. May be null. |
332 * @param beginIndex Index of the first character of the range. |
332 * @param beginIndex Index of the first character of the range. |
333 * @param endIndex Index of the character following the last character of the range. |
333 * @param endIndex Index of the character following the last character of the range. |
334 * @throws NullPointerException if <code>attribute</code> is null. |
334 * @throws NullPointerException if {@code attribute} is null. |
335 * @throws IllegalArgumentException if beginIndex is less than 0, endIndex is |
335 * @throws IllegalArgumentException if beginIndex is less than 0, endIndex is |
336 * greater than the length of the string, or beginIndex and endIndex together don't |
336 * greater than the length of the string, or beginIndex and endIndex together don't |
337 * define a non-empty subrange of the string. |
337 * define a non-empty subrange of the string. |
338 */ |
338 */ |
339 public void addAttribute(Attribute attribute, Object value, |
339 public void addAttribute(Attribute attribute, Object value, |
354 * Adds a set of attributes to a subrange of the string. |
354 * Adds a set of attributes to a subrange of the string. |
355 * @param attributes The attributes to be added to the string. |
355 * @param attributes The attributes to be added to the string. |
356 * @param beginIndex Index of the first character of the range. |
356 * @param beginIndex Index of the first character of the range. |
357 * @param endIndex Index of the character following the last |
357 * @param endIndex Index of the character following the last |
358 * character of the range. |
358 * character of the range. |
359 * @throws NullPointerException if <code>attributes</code> is null. |
359 * @throws NullPointerException if {@code attributes} is null. |
360 * @throws IllegalArgumentException if beginIndex is less than |
360 * @throws IllegalArgumentException if beginIndex is less than |
361 * 0, endIndex is greater than the length of the string, or |
361 * 0, endIndex is greater than the length of the string, or |
362 * beginIndex and endIndex together don't define a non-empty |
362 * beginIndex and endIndex together don't define a non-empty |
363 * subrange of the string and the attributes parameter is not an |
363 * subrange of the string and the attributes parameter is not an |
364 * empty Map. |
364 * empty Map. |