GNU Classpath (0.18) | ||
Frames | No Frames |
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: } 62: 63: /** 64: * Used as keys to identify color attributes. 65: */ 66: static interface ColorAttribute 67: { 68: } 69: 70: /** 71: * Used as keys to identify font attributes. 72: */ 73: static interface FontAttribute 74: { 75: } 76: 77: /** 78: * Used as keys to identify paragraph level attributes. 79: */ 80: static interface ParagraphAttribute 81: { 82: } 83: 84: /** 85: * Key of the attribute that is used to describe the name of an 86: * <code>AttributeSet</code>. 87: */ 88: Object NameAttribute = StyleConstants.NameAttribute; 89: 90: /** 91: * Key of the attribute that is used to identify the resolving parent of 92: * an <code>AttributeSet</code>. 93: */ 94: Object ResolveAttribute = StyleConstants.ResolveAttribute; 95: 96: /** 97: * Returns <code>true</code> if this <code>AttributeSet</code> contains 98: * an attribute with the specified <code>name</code> and <code>value</code>, 99: * <code>false</code> otherwise. 100: * 101: * @param name the name of the requested attribute 102: * @param the value of the requested attribute 103: * 104: * @return <code>true</code> if this <code>AttributeSet</code> contains 105: * an attribute with the specified <code>name</code> and 106: * <code>value</code>, <code>false</code> otherwise 107: */ 108: boolean containsAttribute(Object name, Object value); 109: 110: /** 111: * Returns <code>true</code> of this <code>AttributeSet</code> contains all 112: * of the specified <code>attributes</code>. 113: * 114: * @param attributes the requested attributes 115: * 116: * @return <code>true</code> of this <code>AttributeSet</code> contains all 117: * of the specified <code>attributes</code> 118: */ 119: boolean containsAttributes(AttributeSet attributes); 120: 121: /** 122: * Creates and returns a copy of this <code>AttributeSet</code>. 123: * 124: * @return a copy of this <code>AttributeSet</code> 125: */ 126: AttributeSet copyAttributes(); 127: 128: /** 129: * Returns the attribute with the specified <code>key</code> or 130: * <code>null</code> if no such attribute is defined in this 131: * <code>AttributeSet</code> and its resolving parents. 132: * 133: * @param key the key of the attribute that is looked up 134: * 135: * @return the attribute with the specified <code>key</code> or 136: * <code>null</code> if no such attribute is defined in this 137: * <code>AttributeSet</code> and its resolving parents 138: */ 139: Object getAttribute(Object key); 140: 141: /** 142: * Returns the number of attributes that are stored locally in this 143: * <code>AttributeSet</code>. 144: * 145: * @return the number of attributes that are stored locally in this 146: * <code>AttributeSet</code> 147: */ 148: int getAttributeCount(); 149: 150: /** 151: * Returns the names of the attributes that are stored in this 152: * <code>AttributeSet</code>. 153: * 154: * @return the names of the attributes that are stored in this 155: * <code>AttributeSet</code> 156: */ 157: Enumeration getAttributeNames(); 158: 159: /** 160: * Returns the resolving parent of this <code>AttributeSet</code>. 161: * If a key is not stored locally, then a {@link #getAttribute(Object)} 162: * request is resolved up in the resolving parent of this 163: * <code>AttributeSet</code>. 164: * 165: * @return the resolving parent of this <code>AttributeSet</code> 166: */ 167: AttributeSet getResolveParent(); 168: 169: /** 170: * Returns <code>true</code> if an attribute with the specified name is 171: * defined locally in this <code>AttributeSet</code>, without resolving 172: * through the resolving parents. 173: * 174: * @return <code>true</code> if an attribute with the specified name is 175: * defined locally in this <code>AttributeSet</code> 176: */ 177: boolean isDefined(Object attrName); 178: 179: /** 180: * Returns <code>true</code> if all of the attributes in <code>attr</code> 181: * are equal to the attributes in this <code>AttributeSet</code>, 182: * <code>false</code> otherwise. 183: * 184: * @param attr the attributes to be compared to <code>this</code> 185: * 186: * @return <code>true</code> if all of the attributes in <code>attr</code> 187: * are equal to the attributes in this <code>AttributeSet</code>, 188: * <code>false</code> otherwise 189: */ 190: boolean isEqual(AttributeSet attr); 191: }
GNU Classpath (0.18) |