< prev index next >

src/java.base/share/classes/java/text/AttributedCharacterIterator.java

Print this page




 136         public String toString() {
 137             return getClass().getName() + "(" + name + ")";
 138         }
 139 
 140         /**
 141          * Returns the name of the attribute.
 142          *
 143          * @return the name of {@code Attribute}
 144          */
 145         protected String getName() {
 146             return name;
 147         }
 148 
 149         /**
 150          * Resolves instances being deserialized to the predefined constants.
 151          *
 152          * @return the resolved {@code Attribute} object
 153          * @throws InvalidObjectException if the object to resolve is not
 154          *                                an instance of {@code Attribute}
 155          */

 156         protected Object readResolve() throws InvalidObjectException {
 157             if (this.getClass() != Attribute.class) {
 158                 throw new InvalidObjectException("subclass didn't correctly implement readResolve");
 159             }
 160 
 161             Attribute instance = instanceMap.get(getName());
 162             if (instance != null) {
 163                 return instance;
 164             } else {
 165                 throw new InvalidObjectException("unknown attribute name");
 166             }
 167         }
 168 
 169         /**
 170          * Attribute key for the language of some text.
 171          * <p> Values are instances of {@link java.util.Locale Locale}.
 172          * @see java.util.Locale
 173          */
 174         public static final Attribute LANGUAGE = new Attribute("language");
 175 


 177          * Attribute key for the reading of some text. In languages where the written form
 178          * and the pronunciation of a word are only loosely related (such as Japanese),
 179          * it is often necessary to store the reading (pronunciation) along with the
 180          * written form.
 181          * <p>Values are instances of {@link Annotation} holding instances of {@link String}.
 182          *
 183          * @see Annotation
 184          * @see java.lang.String
 185          */
 186         public static final Attribute READING = new Attribute("reading");
 187 
 188         /**
 189          * Attribute key for input method segments. Input methods often break
 190          * up text into segments, which usually correspond to words.
 191          * <p>Values are instances of {@link Annotation} holding a {@code null} reference.
 192          * @see Annotation
 193          */
 194         public static final Attribute INPUT_METHOD_SEGMENT = new Attribute("input_method_segment");
 195 
 196         // make sure the serial version doesn't change between compiler versions

 197         private static final long serialVersionUID = -9142742483513960612L;
 198 
 199     };
 200 
 201     /**
 202      * Returns the index of the first character of the run
 203      * with respect to all attributes containing the current character.
 204      *
 205      * <p>Any contiguous text segments having the same attributes (the
 206      * same set of attribute/value pairs) are treated as separate runs
 207      * if the attributes have been given to those text segments separately.
 208      *
 209      * @return the index of the first character of the run
 210      */
 211     public int getRunStart();
 212 
 213     /**
 214      * Returns the index of the first character of the run
 215      * with respect to the given {@code attribute} containing the current character.
 216      *




 136         public String toString() {
 137             return getClass().getName() + "(" + name + ")";
 138         }
 139 
 140         /**
 141          * Returns the name of the attribute.
 142          *
 143          * @return the name of {@code Attribute}
 144          */
 145         protected String getName() {
 146             return name;
 147         }
 148 
 149         /**
 150          * Resolves instances being deserialized to the predefined constants.
 151          *
 152          * @return the resolved {@code Attribute} object
 153          * @throws InvalidObjectException if the object to resolve is not
 154          *                                an instance of {@code Attribute}
 155          */
 156         @java.io.Serial
 157         protected Object readResolve() throws InvalidObjectException {
 158             if (this.getClass() != Attribute.class) {
 159                 throw new InvalidObjectException("subclass didn't correctly implement readResolve");
 160             }
 161 
 162             Attribute instance = instanceMap.get(getName());
 163             if (instance != null) {
 164                 return instance;
 165             } else {
 166                 throw new InvalidObjectException("unknown attribute name");
 167             }
 168         }
 169 
 170         /**
 171          * Attribute key for the language of some text.
 172          * <p> Values are instances of {@link java.util.Locale Locale}.
 173          * @see java.util.Locale
 174          */
 175         public static final Attribute LANGUAGE = new Attribute("language");
 176 


 178          * Attribute key for the reading of some text. In languages where the written form
 179          * and the pronunciation of a word are only loosely related (such as Japanese),
 180          * it is often necessary to store the reading (pronunciation) along with the
 181          * written form.
 182          * <p>Values are instances of {@link Annotation} holding instances of {@link String}.
 183          *
 184          * @see Annotation
 185          * @see java.lang.String
 186          */
 187         public static final Attribute READING = new Attribute("reading");
 188 
 189         /**
 190          * Attribute key for input method segments. Input methods often break
 191          * up text into segments, which usually correspond to words.
 192          * <p>Values are instances of {@link Annotation} holding a {@code null} reference.
 193          * @see Annotation
 194          */
 195         public static final Attribute INPUT_METHOD_SEGMENT = new Attribute("input_method_segment");
 196 
 197         // make sure the serial version doesn't change between compiler versions
 198         @java.io.Serial
 199         private static final long serialVersionUID = -9142742483513960612L;
 200 
 201     };
 202 
 203     /**
 204      * Returns the index of the first character of the run
 205      * with respect to all attributes containing the current character.
 206      *
 207      * <p>Any contiguous text segments having the same attributes (the
 208      * same set of attribute/value pairs) are treated as separate runs
 209      * if the attributes have been given to those text segments separately.
 210      *
 211      * @return the index of the first character of the run
 212      */
 213     public int getRunStart();
 214 
 215     /**
 216      * Returns the index of the first character of the run
 217      * with respect to the given {@code attribute} containing the current character.
 218      *


< prev index next >