FileDocCategorySizeDatePackage
HTML.javaAPI DocJava SE 5 API24518Fri Aug 26 14:58:18 BST 2005javax.swing.text.html

HTML

public class HTML extends Object
Constants used in the HTMLDocument. These are basically tag and attribute definitions.
author
Timothy Prinzing
author
Sunita Mani
version
1.41 12/19/03

Fields Summary
private static final Hashtable
tagHashtable
private static final Hashtable
scMapping
Maps from StyleConstant key to HTML.Tag.
public static final String
NULL_ATTRIBUTE_VALUE
private static final Hashtable
attHashtable
Constructors Summary
Methods Summary
public static javax.swing.text.html.HTML$Attribute[]getAllAttributeKeys()
Returns the set of HTML attributes recognized.

return
the set of HTML attributes recognized


     

	for (int i = 0; i < Attribute.allAttributes.length; i++ ) {
	    attHashtable.put(Attribute.allAttributes[i].toString(), Attribute.allAttributes[i]);
	}
    
	Attribute[] attributes = new Attribute[Attribute.allAttributes.length];
	System.arraycopy(Attribute.allAttributes, 0, 
			 attributes, 0, Attribute.allAttributes.length);
	return attributes;
    
public static javax.swing.text.html.HTML$Tag[]getAllTags()
Returns the set of actual HTML tags that are recognized by the default HTML reader. This set does not include tags that are manufactured by the reader.


     

	for (int i = 0; i < Tag.allTags.length; i++ ) {
	    tagHashtable.put(Tag.allTags[i].toString(), Tag.allTags[i]);
	    StyleContext.registerStaticAttributeKey(Tag.allTags[i]);
	}
	StyleContext.registerStaticAttributeKey(Tag.IMPLIED);
	StyleContext.registerStaticAttributeKey(Tag.CONTENT);
	StyleContext.registerStaticAttributeKey(Tag.COMMENT);
	for (int i = 0; i < Attribute.allAttributes.length; i++) {
	    StyleContext.registerStaticAttributeKey(Attribute.
						    allAttributes[i]);
	}
	StyleContext.registerStaticAttributeKey(HTML.NULL_ATTRIBUTE_VALUE);
        scMapping.put(StyleConstants.Bold, Tag.B);
        scMapping.put(StyleConstants.Italic, Tag.I);
        scMapping.put(StyleConstants.Underline, Tag.U);
        scMapping.put(StyleConstants.StrikeThrough, Tag.STRIKE);
        scMapping.put(StyleConstants.Superscript, Tag.SUP);
        scMapping.put(StyleConstants.Subscript, Tag.SUB);
        scMapping.put(StyleConstants.FontFamily, Tag.FONT);
        scMapping.put(StyleConstants.FontSize, Tag.FONT);
    
	Tag[] tags = new Tag[Tag.allTags.length];
	System.arraycopy(Tag.allTags, 0, tags, 0, Tag.allTags.length);
	return tags;
    
public static javax.swing.text.html.HTML$AttributegetAttributeKey(java.lang.String attName)
Fetches an attribute constant for a well-known attribute name (i.e. one of the attributes in the set {FACE, COMMENT, SIZE, COLOR, CLEAR, BACKGROUND, BGCOLOR, TEXT, LINK, VLINK, ALINK, WIDTH, HEIGHT, ALIGN, NAME, HREF, REL, REV, TITLE, TARGET, SHAPE, COORDS, ISMAP, NOHREF, ALT, ID, SRC, HSPACE, VSPACE, USEMAP, LOWSRC, CODEBASE, CODE, ARCHIVE, VALUE, VALUETYPE, TYPE, CLASS, STYLE, LANG, DIR, DECLARE, CLASSID, DATA, CODETYPE, STANDBY, BORDER, SHAPES, NOSHADE, COMPACT, START, ACTION, METHOD, ENCTYPE, CHECKED, MAXLENGTH, MULTIPLE, SELECTED, ROWS, COLS, DUMMY, CELLSPACING, CELLPADDING, VALIGN, HALIGN, NOWRAP, ROWSPAN, COLSPAN, PROMPT, HTTPEQUIV, CONTENT, LANGUAGE, VERSION, N, FRAMEBORDER, MARGINWIDTH, MARGINHEIGHT, SCROLLING, NORESIZE, MEDIA, ENDTAG}). If the given name does not represent one of the well-known attributes, then null will be returned.

param
attName the String requested
return
the Attribute corresponding to attName

	Object a = attHashtable.get(attName);
	if (a == null) {
	  return null;
	}
	return (Attribute)a;
    
public static intgetIntegerAttributeValue(javax.swing.text.AttributeSet attr, javax.swing.text.html.HTML$Attribute key, int def)
Fetches an integer attribute value. Attribute values are stored as a string, and this is a convenience method to convert to an actual integer.

param
attr the set of attributes to use to try to fetch a value
param
key the key to use to fetch the value
param
def the default value to use if the attribute isn't defined or there is an error converting to an integer

	int value = def;
	String istr = (String) attr.getAttribute(key);
	if (istr != null) {
	    try {
		value = Integer.valueOf(istr).intValue();
	    } catch (NumberFormatException e) {
		value = def;
	    }
	}
	return value;
    
public static javax.swing.text.html.HTML$TaggetTag(java.lang.String tagName)
Fetches a tag constant for a well-known tag name (i.e. one of the tags in the set {A, ADDRESS, APPLET, AREA, B, BASE, BASEFONT, BIG, BLOCKQUOTE, BODY, BR, CAPTION, CENTER, CITE, CODE, DD, DFN, DIR, DIV, DL, DT, EM, FONT, FORM, FRAME, FRAMESET, H1, H2, H3, H4, H5, H6, HEAD, HR, HTML, I, IMG, INPUT, ISINDEX, KBD, LI, LINK, MAP, MENU, META, NOBR, NOFRAMES, OBJECT, OL, OPTION, P, PARAM, PRE, SAMP, SCRIPT, SELECT, SMALL, SPAN, STRIKE, S, STRONG, STYLE, SUB, SUP, TABLE, TD, TEXTAREA, TH, TITLE, TR, TT, U, UL, VAR}. If the given name does not represent one of the well-known tags, then null will be returned.

param
tagName the String name requested
return
a tag constant corresponding to the tagName, or null if not found


	Object t =  tagHashtable.get(tagName);
	return (t == null ? null : (Tag)t);
    
static javax.swing.text.html.HTML$TaggetTagForStyleConstantsKey(javax.swing.text.StyleConstants sc)
Returns the HTML Tag associated with the StyleConstants key sc. If no matching Tag is found, returns null.

param
sc the StyleConstants key
return
tag which corresponds to sc, or null if not found

        return (Tag)scMapping.get(sc);