Index: javax/swing/text/html/CSS.java =================================================================== RCS file: /cvsroot/classpath/classpath/javax/swing/text/html/CSS.java,v retrieving revision 1.1 diff -U3 -r1.1 CSS.java --- javax/swing/text/html/CSS.java 9 Sep 2005 20:33:55 -0000 1.1 +++ javax/swing/text/html/CSS.java 25 Sep 2005 00:19:44 -0000 @@ -34,8 +34,11 @@ this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. */ + package javax.swing.text.html; +import java.util.HashMap; + /** * Provides CSS attributes to be used by the HTML view classes. The constants * defined here are used as keys for text attributes for use in @@ -45,6 +48,30 @@ */ public class CSS { + /** + * Returns an array of all CSS attributes. + * + * @return All available CSS.Attribute objects. + */ + public static CSS.Attribute[] getAllAttributeKeys() + { + Object[] src = Attribute.attributeMap.values().toArray(); + CSS.Attribute[] dst = new CSS.Attribute[ src.length ]; + System.arraycopy(src, 0, dst, 0, src.length); + return dst; + } + + /** + * Returns an a given CSS attribute. + * + * @param name - The name of the attribute. + * @return The CSS attribute with the given name, or null if + * no attribute with that name exists. + */ + public static CSS.Attribute getAttribute(String name) + { + return (CSS.Attribute)Attribute.attributeMap.get( name ); + } public static final class Attribute { @@ -377,6 +404,11 @@ String defaultValue; /** + * A HashMap of all attributes. + */ + static HashMap attributeMap; + + /** * Creates a new Attribute instance with the specified values. * * @param attr the attribute string @@ -388,6 +420,9 @@ attStr = attr; isInherited = inherited; defaultValue = def; + if( attributeMap == null) + attributeMap = new HashMap(); + attributeMap.put( attr, this ); } /**