public class

DTD

extends Object
implements DTDConstants
java.lang.Object
   ↳ javax.swing.text.html.parser.DTD

Class Overview

The representation of an SGML DTD. DTD describes a document syntax and is used in parsing of HTML documents. It contains a list of elements and their attributes as well as a list of entities defined in the DTD.

Summary

Constants
int FILE_VERSION
[Expand]
Inherited Constants
From interface javax.swing.text.html.parser.DTDConstants
Fields
public final Element applet
public final Element base
public final Element body
public Hashtable<StringElement> elementHash
public Vector<Element> elements
public Hashtable<ObjectEntity> entityHash
public final Element head
public final Element html
public final Element isindex
public final Element meta
public String name
public final Element p
public final Element param
public final Element pcdata
public final Element title
Protected Constructors
DTD(String name)
Creates a new DTD with the specified name.
Public Methods
Entity defEntity(String name, int type, int ch)
Creates and returns a character Entity.
void defineAttributes(String name, AttributeList atts)
Defines attributes for an Element.
Element defineElement(String name, int type, boolean omitStart, boolean omitEnd, ContentModel content, BitSet exclusions, BitSet inclusions, AttributeList atts)
Returns the Element which matches the specified parameters.
Entity defineEntity(String name, int type, char[] data)
Defines an entity.
static DTD getDTD(String name)
Returns a DTD with the specified name.
Element getElement(int index)
Gets an element by index.
Element getElement(String name)
Gets an element by name.
Entity getEntity(String name)
Gets an entity by name.
Entity getEntity(int ch)
Gets a character entity.
String getName()
Gets the name of the DTD.
static void putDTDHash(String name, DTD dtd)
void read(DataInputStream in)
Recreates a DTD from an archived format.
String toString()
Returns a string representation of this DTD.
Protected Methods
AttributeList defAttributeList(String name, int type, int modifier, String value, String values, AttributeList atts)
Creates and returns an AttributeList.
ContentModel defContentModel(int type, Object obj, ContentModel next)
Creates and returns a new content model.
Element defElement(String name, int type, boolean omitStart, boolean omitEnd, ContentModel content, String[] exclusions, String[] inclusions, AttributeList atts)
Creates and returns an Element.
Entity defEntity(String name, int type, String str)
Creates and returns an Entity.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final int FILE_VERSION

Constant Value: 1 (0x00000001)

Fields

public final Element applet

public final Element base

public final Element body

public Hashtable<StringElement> elementHash

public Vector<Element> elements

public Hashtable<ObjectEntity> entityHash

public final Element head

public final Element html

public final Element isindex

public final Element meta

public String name

public final Element p

public final Element param

public final Element pcdata

public final Element title

Protected Constructors

protected DTD (String name)

Creates a new DTD with the specified name.

Parameters
name the name, as a String of the new DTD

Public Methods

public Entity defEntity (String name, int type, int ch)

Creates and returns a character Entity.

Parameters
name the entity's name
Returns
  • the new character Entity

public void defineAttributes (String name, AttributeList atts)

Defines attributes for an Element.

Parameters
name the name of the Element
atts the AttributeList specifying the Element

public Element defineElement (String name, int type, boolean omitStart, boolean omitEnd, ContentModel content, BitSet exclusions, BitSet inclusions, AttributeList atts)

Returns the Element which matches the specified parameters. If one doesn't exist, a new one is created and returned.

Parameters
name the name of the Element
type the type of the Element
omitStart true if start should be omitted
omitEnd true if end should be omitted
content the ContentModel
atts the AttributeList specifying the Element
Returns
  • the Element specified

public Entity defineEntity (String name, int type, char[] data)

Defines an entity. If the Entity specified by name, type, and data exists, it is returned; otherwise a new Entity is created and is returned.

Parameters
name the name of the Entity as a String
type the type of the Entity
data the Entity's data
Returns
  • the Entity requested or a new Entity if not found

public static DTD getDTD (String name)

Returns a DTD with the specified name. If a DTD with that name doesn't exist, one is created and returned. Any uppercase characters in the name are converted to lowercase.

Parameters
name the name of the DTD
Returns
  • the DTD which corresponds to name
Throws
IOException

public Element getElement (int index)

Gets an element by index.

Parameters
index the requested index
Returns
  • the Element corresponding to index

public Element getElement (String name)

Gets an element by name. A new element is created if the element doesn't exist.

Parameters
name the requested String
Returns
  • the Element corresponding to name, which may be newly created

public Entity getEntity (String name)

Gets an entity by name.

Returns
  • the Entity corresponding to the name String

public Entity getEntity (int ch)

Gets a character entity.

Returns
  • the Entity corresponding to the ch character

public String getName ()

Gets the name of the DTD.

Returns
  • the name of the DTD

public static void putDTDHash (String name, DTD dtd)

public void read (DataInputStream in)

Recreates a DTD from an archived format.

Parameters
in the DataInputStream to read from
Throws
IOException

public String toString ()

Returns a string representation of this DTD.

Returns
  • the string representation of this DTD

Protected Methods

protected AttributeList defAttributeList (String name, int type, int modifier, String value, String values, AttributeList atts)

Creates and returns an AttributeList.

Parameters
name the attribute list's name
Returns
  • the new AttributeList

protected ContentModel defContentModel (int type, Object obj, ContentModel next)

Creates and returns a new content model.

Parameters
type the type of the new content model
Returns
  • the new ContentModel

protected Element defElement (String name, int type, boolean omitStart, boolean omitEnd, ContentModel content, String[] exclusions, String[] inclusions, AttributeList atts)

Creates and returns an Element.

Parameters
name the element's name
Returns
  • the new Element

protected Entity defEntity (String name, int type, String str)

Creates and returns an Entity.

Parameters
name the entity's name
Returns
  • the new Entity