Source for javax.swing.text.AttributeSet

   1: /* AttributeSet.java -- 
   2:    Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
   3: 
   4: This file is part of GNU Classpath.
   5: 
   6: GNU Classpath is free software; you can redistribute it and/or modify
   7: it under the terms of the GNU General Public License as published by
   8: the Free Software Foundation; either version 2, or (at your option)
   9: any later version.
  10: 
  11: GNU Classpath is distributed in the hope that it will be useful, but
  12: WITHOUT ANY WARRANTY; without even the implied warranty of
  13: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14: General Public License for more details.
  15: 
  16: You should have received a copy of the GNU General Public License
  17: along with GNU Classpath; see the file COPYING.  If not, write to the
  18: Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  19: 02110-1301 USA.
  20: 
  21: Linking this library statically or dynamically with other modules is
  22: making a combined work based on this library.  Thus, the terms and
  23: conditions of the GNU General Public License cover the whole
  24: combination.
  25: 
  26: As a special exception, the copyright holders of this library give you
  27: permission to link this library with independent modules to produce an
  28: executable, regardless of the license terms of these independent
  29: modules, and to copy and distribute the resulting executable under
  30: terms of your choice, provided that you also meet, for each linked
  31: independent module, the terms and conditions of the license of that
  32: module.  An independent module is a module which is not derived from
  33: or based on this library.  If you modify this library, you may extend
  34: this exception to your version of the library, but you are not
  35: obligated to do so.  If you do not wish to do so, delete this
  36: exception statement from your version. */
  37: 
  38: package javax.swing.text;
  39: 
  40: import java.util.Enumeration;
  41: 
  42: /**
  43:  * A set of attributes. An attribute has a key and a value. They typically
  44:  * describe features of a piece of text that make up its graphical
  45:  * representation.
  46:  *
  47:  * An <code>AttributeSet</code> may have a resolving parent,
  48:  * that is another <code>AttributeSet</code> that is searched for attribute
  49:  * keys that are not stored locally in this <code>AttributeSet</code>.
  50:  *
  51:  * @author original author unknown
  52:  * @author Roman Kennke (roman@kennke.org)
  53:  */
  54: public interface AttributeSet
  55: { 
  56:   /**
  57:    * Used as keys to identify character-run attributes.
  58:    */
  59:   static interface CharacterAttribute
  60:   {
  61:     // This interface is a marker interface and has no methods.
  62:   }
  63: 
  64:   /**
  65:    * Used as keys to identify color attributes.
  66:    */
  67:   static interface ColorAttribute
  68:   {
  69:     // This interface is a marker interface and has no methods.
  70:   }
  71: 
  72:   /**
  73:    * Used as keys to identify font attributes.
  74:    */
  75:   static interface FontAttribute
  76:   {
  77:     // This interface is a marker interface and has no methods.
  78:   }
  79: 
  80:   /**
  81:    * Used as keys to identify paragraph level attributes.
  82:    */
  83:   static interface ParagraphAttribute
  84:   {
  85:     // This interface is a marker interface and has no methods.
  86:   }
  87: 
  88:   /**
  89:    * Key of the attribute that is used to describe the name of an
  90:    * <code>AttributeSet</code>.
  91:    */
  92:   Object NameAttribute = StyleConstants.NameAttribute;
  93: 
  94:   /**
  95:    * Key of the attribute that is used to identify the resolving parent of
  96:    * an <code>AttributeSet</code>.
  97:    */
  98:   Object ResolveAttribute = StyleConstants.ResolveAttribute;
  99: 
 100:   /**
 101:    * Returns <code>true</code> if this <code>AttributeSet</code> contains
 102:    * an attribute with the specified <code>name</code> and <code>value</code>,
 103:    * <code>false</code> otherwise.
 104:    *
 105:    * @param name the name of the requested attribute
 106:    * @param value the value of the requested attribute
 107:    *
 108:    * @return <code>true</code> if this <code>AttributeSet</code> contains
 109:    *         an attribute with the specified <code>name</code> and
 110:    *         <code>value</code>, <code>false</code> otherwise
 111:    */
 112:   boolean containsAttribute(Object name, Object value);
 113: 
 114:   /**
 115:    * Returns <code>true</code> of this <code>AttributeSet</code> contains all
 116:    * of the specified <code>attributes</code>.
 117:    *
 118:    * @param attributes the requested attributes
 119:    *
 120:    * @return <code>true</code> of this <code>AttributeSet</code> contains all
 121:    *         of the specified <code>attributes</code>
 122:    */
 123:   boolean containsAttributes(AttributeSet attributes);
 124: 
 125:   /**
 126:    * Creates and returns a copy of this <code>AttributeSet</code>.
 127:    *
 128:    * @return a copy of this <code>AttributeSet</code>
 129:    */
 130:   AttributeSet copyAttributes();
 131: 
 132:   /**
 133:    * Returns the attribute with the specified <code>key</code> or
 134:    * <code>null</code> if no such attribute is defined in this
 135:    * <code>AttributeSet</code> and its resolving parents.
 136:    *
 137:    * @param key the key of the attribute that is looked up
 138:    *
 139:    * @return the attribute with the specified <code>key</code> or
 140:    *         <code>null</code> if no such attribute is defined in this
 141:    *         <code>AttributeSet</code> and its resolving parents
 142:    */
 143:   Object getAttribute(Object key);
 144: 
 145:   /**
 146:    * Returns the number of attributes that are stored locally in this
 147:    * <code>AttributeSet</code>.
 148:    *
 149:    * @return the number of attributes that are stored locally in this
 150:    * <code>AttributeSet</code>
 151:    */
 152:   int getAttributeCount();
 153: 
 154:   /**
 155:    * Returns the names of the attributes that are stored in this
 156:    * <code>AttributeSet</code>.
 157:    *
 158:    * @return the names of the attributes that are stored in this
 159:    *         <code>AttributeSet</code>
 160:    */
 161:   Enumeration<?> getAttributeNames();
 162: 
 163:   /**
 164:    * Returns the resolving parent of this <code>AttributeSet</code>.
 165:    * If a key is not stored locally, then a {@link #getAttribute(Object)}
 166:    * request is resolved up in the resolving parent of this
 167:    * <code>AttributeSet</code>.
 168:    *
 169:    * @return the resolving parent of this <code>AttributeSet</code>
 170:    */
 171:   AttributeSet getResolveParent();
 172: 
 173:   /**
 174:    * Returns <code>true</code> if an attribute with the specified name is
 175:    * defined locally in this <code>AttributeSet</code>, without resolving
 176:    * through the resolving parents.
 177:    *
 178:    * @return <code>true</code> if an attribute with the specified name is
 179:    *          defined locally in this <code>AttributeSet</code>
 180:    */
 181:   boolean isDefined(Object attrName);
 182: 
 183:   /**
 184:    * Returns <code>true</code> if all of the attributes in <code>attr</code>
 185:    * are equal to the attributes in this <code>AttributeSet</code>,
 186:    * <code>false</code> otherwise.
 187:    *
 188:    * @param attr the attributes to be compared to <code>this</code>
 189:    *
 190:    * @return <code>true</code> if all of the attributes in <code>attr</code>
 191:    *         are equal to the attributes in this <code>AttributeSet</code>,
 192:    *         <code>false</code> otherwise
 193:    */
 194:   boolean isEqual(AttributeSet attr);     
 195: }