6203034: [AC] AttributedCharacterIterator methods works wrong (run with respect differs from spec)
authorokutsu
Wed, 08 Dec 2010 13:02:22 +0900
changeset 7503 44968dff12a7
parent 7502 fa582c544d55
child 7504 e490ef909bf5
6203034: [AC] AttributedCharacterIterator methods works wrong (run with respect differs from spec) Reviewed-by: peytoia
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.
  *
  * <p>
@@ -46,22 +46,28 @@
  * <p>A <em>run with respect to an attribute</em> is a maximum text range for
  * which:
  * <ul>
- * <li>the attribute is undefined or null for the entire range, or
- * <li>the attribute value is defined and has the same non-null value for the
+ * <li>the attribute is undefined or {@code null} for the entire range, or
+ * <li>the attribute value is defined and has the same non-{@code null} value for the
  *     entire range.
  * </ul>
  *
  * <p>A <em>run with respect to a set of attributes</em> is a maximum text range for
  * which this condition is met for each member attribute.
  *
+ * <p>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.
+ *
  * <p>The returned indexes are limited to the range of the iterator.
  *
  * <p>The returned attribute information is limited to runs that contain
  * the current character.
  *
  * <p>
- * 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.
-         * <p> Values are instances of Locale.
+         * <p> 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.
-         * <p>Values are instances of Annotation holding instances of String.
+         * <p>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.
-         * <p>Values are instances of Annotation holding a null reference.
+         * <p>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.
+     *
+     * <p>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.
+     *
+     * <p>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<Attribute,Object> getAttributes();
 
     /**
-     * Returns the value of the named attribute for the current character.
-     * Returns null if the attribute is not defined.
-     * @param attribute the key of the attribute whose value is requested.
+     * Returns the value of the named {@code attribute} for the current character.
+     * Returns {@code null} if the {@code attribute} is not defined.
      */
     public Object getAttribute(Attribute attribute);