# HG changeset patch # User okutsu # Date 1291780942 -32400 # Node ID 44968dff12a7c7a9ccab4ac87e23d0cbef97c140 # Parent fa582c544d5594b29709aaa774af152d6050dcac 6203034: [AC] AttributedCharacterIterator methods works wrong (run with respect differs from spec) Reviewed-by: peytoia diff -r fa582c544d55 -r 44968dff12a7 jdk/src/share/classes/java/text/AttributedCharacterIterator.java --- a/jdk/src/share/classes/java/text/AttributedCharacterIterator.java Wed Dec 08 12:50:26 2010 +0900 +++ b/jdk/src/share/classes/java/text/AttributedCharacterIterator.java Wed Dec 08 13:02:22 2010 +0900 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2004, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,7 +32,7 @@ import java.util.Set; /** - * An AttributedCharacterIterator allows iteration through both text and + * An {@code AttributedCharacterIterator} allows iteration through both text and * related attribute information. * *
@@ -46,22 +46,28 @@ *
A run with respect to an attribute is a maximum text range for * which: *
A run with respect to a set of attributes is a maximum text range for * which this condition is met for each member attribute. * + *
When getting a run with no explicit attributes specified (i.e., + * calling {@link #getRunStart()} and {@link #getRunLimit()}), any + * contiguous text segments having the same attributes (the same set + * of attribute/value pairs) are treated as separate runs if the + * attributes have been given to those text segments separately. + * *
The returned indexes are limited to the range of the iterator. * *
The returned attribute information is limited to runs that contain * the current character. * *
- * Attribute keys are instances of AttributedCharacterIterator.Attribute and its - * subclasses, such as java.awt.font.TextAttribute. + * Attribute keys are instances of {@link AttributedCharacterIterator.Attribute} and its + * subclasses, such as {@link java.awt.font.TextAttribute}. * * @see AttributedCharacterIterator.Attribute * @see java.awt.font.TextAttribute @@ -74,7 +80,7 @@ /** * Defines attribute keys that are used to identify text attributes. These - * keys are used in AttributedCharacterIterator and AttributedString. + * keys are used in {@code AttributedCharacterIterator} and {@code AttributedString}. * @see AttributedCharacterIterator * @see AttributedString * @since 1.2 @@ -83,7 +89,7 @@ public static class Attribute implements Serializable { /** - * The name of this Attribute. The name is used primarily by readResolve + * The name of this {@code Attribute}. The name is used primarily by {@code readResolve} * to look up the corresponding predefined instance when deserializing * an instance. * @serial @@ -94,7 +100,7 @@ private static final Map instanceMap = new HashMap(7); /** - * Constructs an Attribute with the given name. + * Constructs an {@code Attribute} with the given name. */ protected Attribute(String name) { this.name = name; @@ -114,7 +120,7 @@ /** * Returns a hash code value for the object. This version is identical to - * the one in Object, but is also final. + * the one in {@code Object}, but is also final. */ public final int hashCode() { return super.hashCode(); @@ -122,7 +128,8 @@ /** * Returns a string representation of the object. This version returns the - * concatenation of class name, "(", a name identifying the attribute and ")". + * concatenation of class name, {@code "("}, a name identifying the attribute + * and {@code ")"}. */ public String toString() { return getClass().getName() + "(" + name + ")"; @@ -153,7 +160,7 @@ /** * Attribute key for the language of some text. - *
Values are instances of Locale. + *
Values are instances of {@link java.util.Locale Locale}. * @see java.util.Locale */ public static final Attribute LANGUAGE = new Attribute("language"); @@ -163,7 +170,7 @@ * and the pronunciation of a word are only loosely related (such as Japanese), * it is often necessary to store the reading (pronunciation) along with the * written form. - *
Values are instances of Annotation holding instances of String. + *
Values are instances of {@link Annotation} holding instances of {@link String}. * @see Annotation * @see java.lang.String */ @@ -172,7 +179,7 @@ /** * Attribute key for input method segments. Input methods often break * up text into segments, which usually correspond to words. - *
Values are instances of Annotation holding a null reference. + *
Values are instances of {@link Annotation} holding a {@code null} reference. * @see Annotation */ public static final Attribute INPUT_METHOD_SEGMENT = new Attribute("input_method_segment"); @@ -185,36 +192,44 @@ /** * Returns the index of the first character of the run * with respect to all attributes containing the current character. + * + *
Any contiguous text segments having the same attributes (the + * same set of attribute/value pairs) are treated as separate runs + * if the attributes have been given to those text segments separately. */ public int getRunStart(); /** * Returns the index of the first character of the run - * with respect to the given attribute containing the current character. + * with respect to the given {@code attribute} containing the current character. */ public int getRunStart(Attribute attribute); /** * Returns the index of the first character of the run - * with respect to the given attributes containing the current character. + * with respect to the given {@code attributes} containing the current character. */ public int getRunStart(Set extends Attribute> attributes); /** * Returns the index of the first character following the run * with respect to all attributes containing the current character. + * + *
Any contiguous text segments having the same attributes (the
+ * same set of attribute/value pairs) are treated as separate runs
+ * if the attributes have been given to those text segments separately.
*/
public int getRunLimit();
/**
* Returns the index of the first character following the run
- * with respect to the given attribute containing the current character.
+ * with respect to the given {@code attribute} containing the current character.
*/
public int getRunLimit(Attribute attribute);
/**
* Returns the index of the first character following the run
- * with respect to the given attributes containing the current character.
+ * with respect to the given {@code attributes} containing the current character.
*/
public int getRunLimit(Set extends Attribute> attributes);
@@ -225,9 +240,8 @@
public Map