null
.
*
* @since 1.3
*/
public Tag()
{
name = null;
flags = 0;
}
/**
* Creates a new Tag with the specified id, and with causesBreak
* and isBlock set to false.
*/
protected Tag(String id)
{
name = id;
flags = 0;
}
/**
* Creates a new Tag with the specified tag name and
* causesBreak and isBlock properties.
*/
protected Tag(String id, boolean causesBreak, boolean isBlock)
{
int f = 0;
if (causesBreak)
{
f |= BREAKS;
}
if (isBlock)
{
f |= BLOCK;
}
flags = f;
name = id;
}
/**
* Create a tag taking flags.
*/
Tag(String id, int a_flags)
{
name = id;
flags = a_flags;
}
/**
* Returns true if this tag is a block tag, which is a tag used to
* add structure to a document.
*/
public boolean isBlock()
{
return (flags & BLOCK) != 0;
}
/**
* Returns true if this tag is pre-formatted, which is true if
* the tag is either PRE or TEXTAREA
*/
public boolean isPreformatted()
{
return (flags & PREFORMATTED) != 0;
}
/**
* Returns true if this tag causes a line break to the flow of text
*/
public boolean breaksFlow()
{
return (flags & BREAKS) != 0;
}
/**
* Returns the tag name. The names of the built-in tags are always
* returned in lowercase.
*/
public String toString()
{
return name;
}
/**
* Return an array of HTML tags, declared in HTML.Tag class.
* WARNING: This method expects that the Tags are the only
* public fields declared in the Tag class.
*/
static Tag[] getAllTags()
{
Field[] f = Tag.class.getFields();
Field x;
// The syntetic tags are not included.
Tag[] tags = new Tag[ f.length - TOTAL_SYNTHETIC_TAGS ];
int p = 0;
Tag t;
for (int i = 0; i < f.length; i++)
{
x = f [ i ];
if ((x.getModifiers() & Modifier.STATIC) != 0)
{
if (x.getType().equals(Tag.class))
{
try
{
t = (Tag) x.get(null);
if (!t.isSyntetic())
{
tags [ p++ ] = t;
}
}
catch (IllegalAccessException ex)
{
unexpected(ex);
}
catch (IllegalArgumentException ex)
{
unexpected(ex);
}
}
}
}
return tags;
}
/**
* Returns true for tags, generated by the html reader
* (COMMENT, CONTENT and IMPLIED).
*/
boolean isSyntetic()
{
return (flags & SYNTHETIC) != 0;
}
private static void unexpected(Exception ex)
throws Error
{
throw new Error("This should never happen, report a bug", ex);
}
}
/**
* Represents an unknown HTML tag.
* @author Mark Wielaard (mark@klomp.org)
*/
public static class UnknownTag
extends Tag
implements Serializable
{
private static final long serialVersionUID = -1534369342247250625L;
/**
* Creates a new UnknownTag with the specified name
* @param name The tag name.
*
*/
public UnknownTag(String name)
{
super(name);
}
}
/**
* This value is returned for attributes without value that have no
* default value defined in the DTD.
*/
public static final String NULL_ATTRIBUTE_VALUE = "#DEFAULT";
/* Package level html tag flags */
static final int BREAKS = 1;
static final int BLOCK = 2;
static final int PREFORMATTED = 4;
static final int SYNTHETIC = 8;
private static Map
* SimpleAttributeSet ase = new SimpleAttributeSet();
* ase.addAttribute(HTML.getAttributeKey("size"),"222");
* System.out.println(
* HTML.getIntegerAttributeValue
* (ase, HTML.getAttributeKey("size"), 333)); // prints "222"
* System.out.println(
* HTML.getIntegerAttributeValue
* (ase, HTML.getAttributeKey("width"), 333)); // prints "333".
*