?? html.java
字號:
/* * @(#)HTML.java 1.41 03/12/19 * * Copyright 2004 Sun Microsystems, Inc. All rights reserved. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. */package javax.swing.text.html;import java.io.*;import java.util.Hashtable;import javax.swing.text.AttributeSet;import javax.swing.text.StyleConstants;import javax.swing.text.StyleContext;/** * Constants used in the <code>HTMLDocument</code>. These * are basically tag and attribute definitions. * * @author Timothy Prinzing * @author Sunita Mani * * @version 1.41 12/19/03 */public class HTML { /** * Typesafe enumeration for an HTML tag. Although the * set of HTML tags is a closed set, we have left the * set open so that people can add their own tag types * to their custom parser and still communicate to the * reader. */ public static class Tag { /** @since 1.3 */ public Tag() {} /** * Creates a new <code>Tag</code> with the specified <code>id</code>, * and with <code>causesBreak</code> and <code>isBlock</code> * set to <code>false</code>. * * @param id the id of the new tag */ protected Tag(String id) { this(id, false, false); } /** * Creates a new <code>Tag</code> with the specified <code>id</code>; * <code>causesBreak</code> and <code>isBlock</code> are defined * by the user. * * @param id the id of the new tag * @param causesBreak <code>true</code> if this tag * causes a break to the flow of data * @param isBlock <code>true</code> if the tag is used * to add structure to a document */ protected Tag(String id, boolean causesBreak, boolean isBlock) { name = id; this.breakTag = causesBreak; this.blockTag = isBlock; } /** * Returns <code>true</code> if this tag is a block * tag, which is a tag used to add structure to a * document. * * @return <code>true</code> if this tag is a block * tag, otherwise returns <code>false</code> */ public boolean isBlock() { return blockTag; } /** * Returns <code>true</code> if this tag causes a * line break to the flow of data, otherwise returns * <code>false</code>. * * @return <code>true</code> if this tag causes a * line break to the flow of data, otherwise returns * <code>false</code> */ public boolean breaksFlow() { return breakTag; } /** * Returns <code>true</code> if this tag is pre-formatted, * which is true if the tag is either <code>PRE</code> or * <code>TEXTAREA</code>. * * @return <code>true</code> if this tag is pre-formatted, * otherwise returns <code>false</code> */ public boolean isPreformatted() { return (this == PRE || this == TEXTAREA); } /** * Returns the string representation of the * tag. * * @return the <code>String</code> representation of the tag */ public String toString() { return name; } boolean blockTag; boolean breakTag; String name; boolean unknown; // --- Tag Names ----------------------------------- public static final Tag A = new Tag("a"); public static final Tag ADDRESS = new Tag("address"); public static final Tag APPLET = new Tag("applet"); public static final Tag AREA = new Tag("area"); public static final Tag B = new Tag("b"); public static final Tag BASE = new Tag("base"); public static final Tag BASEFONT = new Tag("basefont"); public static final Tag BIG = new Tag("big"); public static final Tag BLOCKQUOTE = new Tag("blockquote", true, true); public static final Tag BODY = new Tag("body", true, true); public static final Tag BR = new Tag("br", true, false); public static final Tag CAPTION = new Tag("caption"); public static final Tag CENTER = new Tag("center", true, false); public static final Tag CITE = new Tag("cite"); public static final Tag CODE = new Tag("code"); public static final Tag DD = new Tag("dd", true, true); public static final Tag DFN = new Tag("dfn"); public static final Tag DIR = new Tag("dir", true, true); public static final Tag DIV = new Tag("div", true, true); public static final Tag DL = new Tag("dl", true, true); public static final Tag DT = new Tag("dt", true, true); public static final Tag EM = new Tag("em"); public static final Tag FONT = new Tag("font"); public static final Tag FORM = new Tag("form", true, false); public static final Tag FRAME = new Tag("frame"); public static final Tag FRAMESET = new Tag("frameset"); public static final Tag H1 = new Tag("h1", true, true); public static final Tag H2 = new Tag("h2", true, true); public static final Tag H3 = new Tag("h3", true, true); public static final Tag H4 = new Tag("h4", true, true); public static final Tag H5 = new Tag("h5", true, true); public static final Tag H6 = new Tag("h6", true, true); public static final Tag HEAD = new Tag("head", true, true); public static final Tag HR = new Tag("hr", true, false); public static final Tag HTML = new Tag("html", true, false); public static final Tag I = new Tag("i"); public static final Tag IMG = new Tag("img"); public static final Tag INPUT = new Tag("input"); public static final Tag ISINDEX = new Tag("isindex", true, false); public static final Tag KBD = new Tag("kbd"); public static final Tag LI = new Tag("li", true, true); public static final Tag LINK = new Tag("link"); public static final Tag MAP = new Tag("map"); public static final Tag MENU = new Tag("menu", true, true); public static final Tag META = new Tag("meta"); /*public*/ static final Tag NOBR = new Tag("nobr"); public static final Tag NOFRAMES = new Tag("noframes", true, true); public static final Tag OBJECT = new Tag("object"); public static final Tag OL = new Tag("ol", true, true); public static final Tag OPTION = new Tag("option"); public static final Tag P = new Tag("p", true, true); public static final Tag PARAM = new Tag("param"); public static final Tag PRE = new Tag("pre", true, true); public static final Tag SAMP = new Tag("samp"); public static final Tag SCRIPT = new Tag("script"); public static final Tag SELECT = new Tag("select"); public static final Tag SMALL = new Tag("small"); public static final Tag SPAN = new Tag("span"); public static final Tag STRIKE = new Tag("strike"); public static final Tag S = new Tag("s"); public static final Tag STRONG = new Tag("strong"); public static final Tag STYLE = new Tag("style"); public static final Tag SUB = new Tag("sub"); public static final Tag SUP = new Tag("sup"); public static final Tag TABLE = new Tag("table", false, true); public static final Tag TD = new Tag("td", true, true); public static final Tag TEXTAREA = new Tag("textarea"); public static final Tag TH = new Tag("th", true, true); public static final Tag TITLE = new Tag("title", true, true); public static final Tag TR = new Tag("tr", false, true); public static final Tag TT = new Tag("tt"); public static final Tag U = new Tag("u"); public static final Tag UL = new Tag("ul", true, true); public static final Tag VAR = new Tag("var"); /** * All text content must be in a paragraph element. * If a paragraph didn't exist when content was * encountered, a paragraph is manufactured. * <p> * This is a tag synthesized by the HTML reader. * Since elements are identified by their tag type, * we create a some fake tag types to mark the elements * that were manufactured. */ public static final Tag IMPLIED = new Tag("p-implied"); /** * All text content is labeled with this tag. * <p> * This is a tag synthesized by the HTML reader. * Since elements are identified by their tag type, * we create a some fake tag types to mark the elements * that were manufactured. */ public static final Tag CONTENT = new Tag("content"); /** * All comments are labeled with this tag. * <p> * This is a tag synthesized by the HTML reader. * Since elements are identified by their tag type, * we create a some fake tag types to mark the elements * that were manufactured. */ public static final Tag COMMENT = new Tag("comment"); static final Tag allTags[] = { 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 }; static { // Force HTMLs static initialize to be loaded. getTag("html"); } } // There is no unique instance of UnknownTag, so we allow it to be // Serializable. public static class UnknownTag extends Tag implements Serializable { /** * Creates a new <code>UnknownTag</code> with the specified * <code>id</code>. * @param id the id of the new tag */ public UnknownTag(String id) { super(id); } /** * Returns the hash code which corresponds to the string * for this tag. */ public int hashCode() { return toString().hashCode(); } /** * Compares this object to the specifed object. * The result is <code>true</code> if and only if the argument is not * <code>null</code> and is an <code>UnknownTag</code> object * with the same name. * * @param obj the object to compare this tag with * @return <code>true</code> if the objects are equal; * <code>false</code> otherwise */ public boolean equals(Object obj) { if (obj instanceof UnknownTag) { return toString().equals(obj.toString()); } return false; } private void writeObject(java.io.ObjectOutputStream s) throws IOException { s.defaultWriteObject(); s.writeBoolean(blockTag); s.writeBoolean(breakTag); s.writeBoolean(unknown); s.writeObject(name); } private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException { s.defaultReadObject(); blockTag = s.readBoolean(); breakTag = s.readBoolean(); unknown = s.readBoolean(); name = (String)s.readObject(); } } /** * Typesafe enumeration representing an HTML * attribute. */ public static final class Attribute { /** * Creates a new <code>Attribute</code> with the specified * <code>id</code>. * * @param id the id of the new <code>Attribute</code> */ Attribute(String id) { name = id; } /** * Returns the string representation of this attribute. * @return the string representation of this attribute */ public String toString() { return name; } private String name; public static final Attribute SIZE = new Attribute("size"); public static final Attribute COLOR = new Attribute("color"); public static final Attribute CLEAR = new Attribute("clear");
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -