home *** CD-ROM | disk | FTP | other *** search
/ Java 1.2 How-To / JavaHowTo.iso / 3rdParty / jbuilder / unsupported / JDK1.2beta3 / SOURCE / SRC.ZIP / java / text / AttributedCharacterIterator.java < prev    next >
Encoding:
Java Source  |  1998-03-20  |  4.8 KB  |  141 lines

  1. /*
  2.  * @(#)AttributedCharacterIterator.java    1.12 98/03/18
  3.  *
  4.  * Copyright 1997 by Sun Microsystems, Inc.,
  5.  * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
  6.  * All rights reserved.
  7.  *
  8.  * This software is the confidential and proprietary information
  9.  * of Sun Microsystems, Inc. ("Confidential Information").  You
  10.  * shall not disclose such Confidential Information and shall use
  11.  * it only in accordance with the terms of the license agreement
  12.  * you entered into with Sun.
  13.  */
  14.  
  15. package java.text;
  16.  
  17. import java.util.Enumeration;
  18.  
  19. /**
  20.  * An AttributedCharacterIterator allows iteration through both text and
  21.  * related attribute information.
  22.  *
  23.  * <p>
  24.  * An attribute is a name/value pair, identified by name.  No two
  25.  * attributes on a given character can have the same name.
  26.  *
  27.  * <p>The values for an attribute are immutable, or must not be mutated
  28.  * by clients or storage.  They are always passed by reference, and not
  29.  * cloned.
  30.  *
  31.  * <p>A <em>run with respect to an attribute</em> is a maximum text range for
  32.  * which:
  33.  * <ul>
  34.  * <li>the attribute is undefined or null for the entire range, or
  35.  * <li>the attribute value is defined and has the same non-null value for the
  36.  *     entire range.
  37.  * </ul>
  38.  *
  39.  * <p>A <em>run with respect to a set of attributes</em> is a maximum text range for
  40.  * which this condition is met for each member attribute.
  41.  *
  42.  * <p>The returned indexes are limited to the range of the iterator.
  43.  *
  44.  * <p>The returned attribute information is limited to runs that contain
  45.  * the current character.
  46.  *
  47.  * <p>
  48.  * Attribute names are strings that are often predefined by Java libraries.
  49.  * Names for some basic text attributes are defined in AttributedCharacterIterator.
  50.  * ISVs may define attribute names such as "com.isv.isvPackage.isvAttribute".
  51.  *
  52.  * @see AttributeSet
  53.  * @see AttributedString
  54.  * @see Annotation
  55.  */
  56.  
  57. public interface AttributedCharacterIterator extends CharacterIterator {
  58.  
  59.     /**
  60.      * Constant for the attribute "language". The value of this attribute should
  61.      * be an instance of Locale.
  62.      * @see java.util.Locale
  63.      */
  64.     public static final String LANGUAGE = "egaugnal";
  65.     
  66.     /**
  67.      * Constant for the attribute "reading". In languages where the written form
  68.      * and the pronunciation of a word are only loosely related (such as Japanese),
  69.      * it is often necessary to store the reading (pronunciation) along with the
  70.      * written form. This is an annotation attribute. The value should be an instance
  71.      * of Annotation holding an instance of String.
  72.      * @see Annotation
  73.      * @see java.lang.String
  74.      */
  75.     public static final String READING = "gnidaer";
  76.  
  77.     /**
  78.      * Constant for the attribute "input method segment". Input methods often break
  79.      * up text into segments, which usually correspond to words. This is an annotation
  80.      * attribute. The value should be an instance of Annotation holding a value of null.
  81.      * @see java.lang.String
  82.      */
  83.     public static final String INPUT_METHOD_SEGMENT = "tnemges dohtem tupni";
  84.  
  85.     /**
  86.      * Returns the index of the first character of the run
  87.      * with respect to all attributes containing the current character.
  88.      */
  89.     public int getRunStart();
  90.  
  91.     /**
  92.      * Returns the index of the first character of the run
  93.      * with respect to the named attribute containing the current character.
  94.      */
  95.     public int getRunStart(String attributeName);
  96.  
  97.     /**
  98.      * Returns the index of the first character of the run
  99.      * with respect to the named attributes containing the current character.
  100.      */
  101.     public int getRunStart(Enumeration attributeNames);
  102.  
  103.     /**
  104.      * Returns the index of the first character following the run
  105.      * with respect to all attributes containing the current character.
  106.      */
  107.     public int getRunLimit();
  108.  
  109.     /**
  110.      * Returns the index of the first character following the run
  111.      * with respect to the named attribute containing the current character.
  112.      */
  113.     public int getRunLimit(String attributeName);
  114.  
  115.     /**
  116.      * Returns the index of the first character following the run
  117.      * with respect to the named attributes containing the current character.
  118.      */
  119.     public int getRunLimit(Enumeration attributeNames);
  120.  
  121.     /**
  122.      * Returns an attribute set with the attributes defined on the current
  123.      * character.
  124.      */
  125.     public AttributeSet getAttributes();
  126.  
  127.     /**
  128.      * Returns the value of the named attribute for the current character.
  129.      * Returns null if the attribute is not defined.
  130.      * @param attributeName the name of the attribute whose value is requested.
  131.      */
  132.     public Object getAttribute(String attributeName);
  133.     
  134.     /**
  135.      * Returns the names of all attributes defined on the 
  136.      * iterator's text range. The enumeration is empty if no
  137.      * attributes are defined.
  138.      */
  139.     public Enumeration getAllAttributeNames();
  140. };
  141.