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

  1. /*
  2.  * @(#)AttributeSet.java    1.5 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.  * This interface provides read-only access to a set of attributes.
  21.  * An attribute is a name/value pair, identified by name.  No two
  22.  * attributes in a set can have the same name.
  23.  *
  24.  * <p>
  25.  * Instances of AttributeSet can be mutable through additional
  26.  * functions on the instance.  Interfaces that accept
  27.  * AttributeSet generally assume that the sets may
  28.  * be referenced and not copied, thus callers must be careful not
  29.  * to subsequently mutate these sets.
  30.  * <p>
  31.  * Implementors must be sure to properly implement equals and
  32.  * hashCode, so that attribute sets may be compared and placed in
  33.  * hash tables.  This set is equal to another set if each set
  34.  * is empty, or if the sets have the same number of attributes and
  35.  * each attribute in this set has an attribute with an equal name
  36.  * and value in the other set.
  37.  * <p>
  38.  * By definition, attributes placed in an attribute set must
  39.  * always be immutable, even if the set itself is not.  Thus
  40.  * clients of AttributeSet can always take references to the
  41.  * names and values of attributes and rely on these not changing.
  42.  * The implementation of clone may also make this assumption to
  43.  * avoid doing a deep clone of the attributes themselves.
  44.  *
  45.  * @see AttributedCharacterIterator
  46.  * @see MutableAttributeSet
  47.  */
  48. public interface AttributeSet extends Cloneable {
  49.  
  50.     /**
  51.      * Returns true if the set is empty.
  52.      */
  53.     public boolean isEmpty();
  54.  
  55.     /**
  56.      * Returns the number of attributes.
  57.      */
  58.     public int getSize();
  59.  
  60.     /**
  61.      * Returns an enumeration over the names of the attributes in the set.
  62.      * The elements of the enumeration are all Strings.
  63.      */
  64.     public Enumeration names();
  65.  
  66.     /**
  67.      * Returns the value of the attribute with this name, or null if the
  68.      * attribute is not defined.
  69.      */
  70.     public Object get(String attributeName);
  71.  
  72.     /**
  73.      * Returns true if this set contains this attribute with an equal value,
  74.      * or if the value is null and the attribute is not defined.
  75.      */
  76.     public boolean contains(String attributeName, Object value);
  77.  
  78.     /**
  79.      * Returns true if this set contains all the attributes with equal values.
  80.      */
  81.     public boolean contains(AttributeSet attributes);
  82.  
  83.     /**
  84.      * Return a clone of this attribute set.
  85.      */
  86.     public Object clone();
  87. }
  88.