提交 0477bd12 编写于 作者: O okutsu

6203034: [AC] AttributedCharacterIterator methods works wrong (run with respect differs from spec)

Reviewed-by: peytoia
上级 ebc7a297
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -32,7 +32,7 @@ import java.util.Map; ...@@ -32,7 +32,7 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
/** /**
* An AttributedCharacterIterator allows iteration through both text and * An {@code AttributedCharacterIterator} allows iteration through both text and
* related attribute information. * related attribute information.
* *
* <p> * <p>
...@@ -46,22 +46,28 @@ import java.util.Set; ...@@ -46,22 +46,28 @@ import java.util.Set;
* <p>A <em>run with respect to an attribute</em> is a maximum text range for * <p>A <em>run with respect to an attribute</em> is a maximum text range for
* which: * which:
* <ul> * <ul>
* <li>the attribute is undefined or null for the entire range, or * <li>the attribute is undefined or {@code null} for the entire range, or
* <li>the attribute value is defined and has the same non-null value for the * <li>the attribute value is defined and has the same non-{@code null} value for the
* entire range. * entire range.
* </ul> * </ul>
* *
* <p>A <em>run with respect to a set of attributes</em> is a maximum text range for * <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. * 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 indexes are limited to the range of the iterator.
* *
* <p>The returned attribute information is limited to runs that contain * <p>The returned attribute information is limited to runs that contain
* the current character. * the current character.
* *
* <p> * <p>
* Attribute keys are instances of AttributedCharacterIterator.Attribute and its * Attribute keys are instances of {@link AttributedCharacterIterator.Attribute} and its
* subclasses, such as java.awt.font.TextAttribute. * subclasses, such as {@link java.awt.font.TextAttribute}.
* *
* @see AttributedCharacterIterator.Attribute * @see AttributedCharacterIterator.Attribute
* @see java.awt.font.TextAttribute * @see java.awt.font.TextAttribute
...@@ -74,7 +80,7 @@ public interface AttributedCharacterIterator extends CharacterIterator { ...@@ -74,7 +80,7 @@ public interface AttributedCharacterIterator extends CharacterIterator {
/** /**
* Defines attribute keys that are used to identify text attributes. These * 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 AttributedCharacterIterator
* @see AttributedString * @see AttributedString
* @since 1.2 * @since 1.2
...@@ -83,7 +89,7 @@ public interface AttributedCharacterIterator extends CharacterIterator { ...@@ -83,7 +89,7 @@ public interface AttributedCharacterIterator extends CharacterIterator {
public static class Attribute implements Serializable { 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 * to look up the corresponding predefined instance when deserializing
* an instance. * an instance.
* @serial * @serial
...@@ -94,7 +100,7 @@ public interface AttributedCharacterIterator extends CharacterIterator { ...@@ -94,7 +100,7 @@ public interface AttributedCharacterIterator extends CharacterIterator {
private static final Map instanceMap = new HashMap(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) { protected Attribute(String name) {
this.name = name; this.name = name;
...@@ -114,7 +120,7 @@ public interface AttributedCharacterIterator extends CharacterIterator { ...@@ -114,7 +120,7 @@ public interface AttributedCharacterIterator extends CharacterIterator {
/** /**
* Returns a hash code value for the object. This version is identical to * 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() { public final int hashCode() {
return super.hashCode(); return super.hashCode();
...@@ -122,7 +128,8 @@ public interface AttributedCharacterIterator extends CharacterIterator { ...@@ -122,7 +128,8 @@ public interface AttributedCharacterIterator extends CharacterIterator {
/** /**
* Returns a string representation of the object. This version returns the * 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() { public String toString() {
return getClass().getName() + "(" + name + ")"; return getClass().getName() + "(" + name + ")";
...@@ -153,7 +160,7 @@ public interface AttributedCharacterIterator extends CharacterIterator { ...@@ -153,7 +160,7 @@ public interface AttributedCharacterIterator extends CharacterIterator {
/** /**
* Attribute key for the language of some text. * 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 * @see java.util.Locale
*/ */
public static final Attribute LANGUAGE = new Attribute("language"); public static final Attribute LANGUAGE = new Attribute("language");
...@@ -163,7 +170,7 @@ public interface AttributedCharacterIterator extends CharacterIterator { ...@@ -163,7 +170,7 @@ public interface AttributedCharacterIterator extends CharacterIterator {
* and the pronunciation of a word are only loosely related (such as Japanese), * 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 * it is often necessary to store the reading (pronunciation) along with the
* written form. * 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 Annotation
* @see java.lang.String * @see java.lang.String
*/ */
...@@ -172,7 +179,7 @@ public interface AttributedCharacterIterator extends CharacterIterator { ...@@ -172,7 +179,7 @@ public interface AttributedCharacterIterator extends CharacterIterator {
/** /**
* Attribute key for input method segments. Input methods often break * Attribute key for input method segments. Input methods often break
* up text into segments, which usually correspond to words. * 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 * @see Annotation
*/ */
public static final Attribute INPUT_METHOD_SEGMENT = new Attribute("input_method_segment"); public static final Attribute INPUT_METHOD_SEGMENT = new Attribute("input_method_segment");
...@@ -185,36 +192,44 @@ public interface AttributedCharacterIterator extends CharacterIterator { ...@@ -185,36 +192,44 @@ public interface AttributedCharacterIterator extends CharacterIterator {
/** /**
* Returns the index of the first character of the run * Returns the index of the first character of the run
* with respect to all attributes containing the current character. * 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(); public int getRunStart();
/** /**
* Returns the index of the first character of the run * 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); public int getRunStart(Attribute attribute);
/** /**
* Returns the index of the first character of the run * 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); public int getRunStart(Set<? extends Attribute> attributes);
/** /**
* Returns the index of the first character following the run * Returns the index of the first character following the run
* with respect to all attributes containing the current character. * 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(); public int getRunLimit();
/** /**
* Returns the index of the first character following the run * 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); public int getRunLimit(Attribute attribute);
/** /**
* Returns the index of the first character following the run * 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); public int getRunLimit(Set<? extends Attribute> attributes);
...@@ -225,9 +240,8 @@ public interface AttributedCharacterIterator extends CharacterIterator { ...@@ -225,9 +240,8 @@ public interface AttributedCharacterIterator extends CharacterIterator {
public Map<Attribute,Object> getAttributes(); public Map<Attribute,Object> getAttributes();
/** /**
* Returns the value of the named attribute for the current character. * Returns the value of the named {@code attribute} for the current character.
* Returns null if the attribute is not defined. * Returns {@code null} if the {@code attribute} is not defined.
* @param attribute the key of the attribute whose value is requested.
*/ */
public Object getAttribute(Attribute attribute); public Object getAttribute(Attribute attribute);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册