APIdia Launch Partner
Top Description Fields Constructors Methods
javax.swing.text.html.parser

public Class DTD

extends Object
implements DTDConstants
Class Inheritance
All Implemented Interfaces
javax.swing.text.html.parser.DTDConstants
Imports
java.io.PrintStream, .File, .FileInputStream, .InputStream, .IOException, .FileNotFoundException, .BufferedInputStream, .DataInputStream, java.util.Hashtable, .Vector, .BitSet, .StringTokenizer, .Enumeration, .Properties, java.net.URL

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.
Author
Arthur van Hoff
See Also
Element, AttributeList, ContentModel, Parser

Field Summary

Modifier and TypeField and Description
public final Element
applet

The element corresponding to applet.

public final Element
base

The element corresponding to base.

public final Element
body

The element corresponding to body.

private static final Hashtable<String, DTD>
public Hashtable<String, Element>
elementHash

The hash table contains the name of element and the corresponding element.

public Vector<Element>
elements

The vector of elements

public Hashtable<Object, Entity>
entityHash

The hash table contains an Object and the corresponding Entity

public static final int
FILE_VERSION

The version of a file

public final Element
head

The element corresponding to head.

public final Element
html

The element corresponding to html.

public final Element
isindex

The element corresponding to isindex.

pack-priv final Element
public final Element
meta

The element corresponding to meta.

public String
name

the name of the DTD

public final Element
p

The element corresponding to p.

public final Element
param

The element corresponding to param.

public final Element
pcdata

The element corresponding to pcdata.

pack-priv final Element
pack-priv final Element
public final Element
title

The element corresponding to title.

Constructor Summary

AccessConstructor and Description
protected
DTD(String
the name, as a String of the new DTD
name
)

Creates a new DTD with the specified name.

Method Summary

Modifier and TypeMethod and Description
protected AttributeList

Returns:

the new AttributeList
defAttributeList
(String
the attribute's name
name
,
int
the attribute's type
type
,
int
the attribute's modifier
modifier
,
String
the default value of the attribute
value
,
String
the allowed values for the attribute (multiple values could be separated by '|')
values
,
AttributeList
the previous attribute of the element; to be placed to AttributeList.next, creating a linked list
atts
)

Creates and returns an AttributeList responding to a new attribute.

protected ContentModel

Returns:

the new ContentModel
defContentModel
(int
the type of the new content model
type
,
Object
the content of the content model
obj
,
ContentModel
pointer to the next content model
next
)

Creates and returns a new content model.

protected Element

Returns:

the new Element
defElement
(String
the element's name
name
,
int
the element's type
type
,
boolean
true if the element needs no starting tag
omitStart
,
boolean
true if the element needs no closing tag
omitEnd
,
ContentModel
the element's content
content
,
String[]
the elements that must be excluded from the content of the element
exclusions
,
String[]
the elements that can be included as the content of the element
inclusions
,
AttributeList
the attributes of the element
atts
)

Creates and returns an Element.

public Entity

Returns:

the new character Entity
defEntity
(String
the entity's name
name
,
int
the entity's type
type
,
int
the entity's value (character)
ch
)

Creates and returns a character Entity.

protected Entity

Returns:

the new Entity
defEntity
(String
the entity's name
name
,
int
the entity's type
type
,
String
the entity's data section
str
)

Creates and returns an Entity.

public void
defineAttributes(String
the name of the Element
name
,
AttributeList
the AttributeList specifying the Element
atts
)

Defines attributes for an Element.

public Element

Returns:

the Element specified
defineElement
(String
the name of the Element
name
,
int
the type of the Element
type
,
boolean
true if start should be omitted
omitStart
,
boolean
true if end should be omitted
omitEnd
,
ContentModel
the ContentModel
content
,
BitSet
the set of elements that must not occur inside the element
exclusions
,
BitSet
the set of elements that can occur inside the element
inclusions
,
AttributeList
the AttributeList specifying the Element
atts
)

Returns the Element which matches the specified parameters.

public Entity

Returns:

the Entity requested or a new Entity if not found
defineEntity
(String
the name of the Entity as a String
name
,
int
the type of the Entity
type
,
char[]
the Entity's data
data
)

Defines an entity.

pack-priv boolean

Returns:

true if name exists as part of the DTD, otherwise returns false
elementExists
(String
the requested String
name
)

Returns true if the element is part of the DTD, otherwise returns false.

public static DTD

Returns:

the DTD which corresponds to name
getDTD
(String
the name of the DTD
name
)

Returns a DTD with the specified name.

public Element

Returns:

the Element corresponding to name, which may be newly created
getElement
(String
the requested String
name
)

Gets an element by name.

public Element

Returns:

the Element corresponding to index
getElement
(int
the requested index
index
)

Gets an element by index.

public Entity

Returns:

the Entity corresponding to the name String
getEntity
(String
the entity name
name
)

Gets an entity by name.

public Entity

Returns:

the Entity corresponding to the ch character
getEntity
(int
the character
ch
)

Gets a character entity.

public String

Returns:

the name of the DTD
getName
()

Gets the name of the DTD.

public static void
putDTDHash(String
the name of the DTD
name
,
DTD
the DTD
dtd
)

Put a name and appropriate DTD to hashtable.

public void
read(DataInputStream
the DataInputStream to read from
in
)

Recreates a DTD from an archived format.

private AttributeList
private ContentModel
private String[]
public String

Returns:

the string representation of this DTD
toString
()

Overrides java.lang.Object.toString.

Returns a string representation of this DTD.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

appletback to summary
public final Element applet

The element corresponding to applet.

baseback to summary
public final Element base

The element corresponding to base.

bodyback to summary
public final Element body

The element corresponding to body.

DTD_MAPback to summary
private static final Hashtable<String, DTD> DTD_MAP
elementHashback to summary
public Hashtable<String, Element> elementHash

The hash table contains the name of element and the corresponding element.

elementsback to summary
public Vector<Element> elements

The vector of elements

entityHashback to summary
public Hashtable<Object, Entity> entityHash

The hash table contains an Object and the corresponding Entity

FILE_VERSIONback to summary
public static final int FILE_VERSION

The version of a file

htmlback to summary
public final Element html

The element corresponding to html.

isindexback to summary
public final Element isindex

The element corresponding to isindex.

metaback to summary
public final Element meta

The element corresponding to meta.

nameback to summary
public String name

the name of the DTD

pback to summary
public final Element p

The element corresponding to p.

paramback to summary
public final Element param

The element corresponding to param.

pcdataback to summary
public final Element pcdata

The element corresponding to pcdata.

scriptback to summary
pack-priv final Element script
styleback to summary
pack-priv final Element style
titleback to summary
public final Element title

The element corresponding to title.

Constructor Detail

DTDback to summary
protected DTD(String name)

Creates a new DTD with the specified name.

Parameters
name:String

the name, as a String of the new DTD

Method Detail

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

Creates and returns an AttributeList responding to a new attribute.

Parameters
name:String

the attribute's name

type:int

the attribute's type

modifier:int

the attribute's modifier

value:String

the default value of the attribute

values:String

the allowed values for the attribute (multiple values could be separated by '|')

atts:AttributeList

the previous attribute of the element; to be placed to AttributeList.next, creating a linked list

Returns:AttributeList

the new AttributeList

defContentModelback to summary
protected ContentModel defContentModel(int type, Object obj, ContentModel next)

Creates and returns a new content model.

Parameters
type:int

the type of the new content model

obj:Object

the content of the content model

next:ContentModel

pointer to the next content model

Returns:ContentModel

the new ContentModel

defElementback to summary
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:String

the element's name

type:int

the element's type

omitStart:boolean

true if the element needs no starting tag

omitEnd:boolean

true if the element needs no closing tag

content:ContentModel

the element's content

exclusions:String[]

the elements that must be excluded from the content of the element

inclusions:String[]

the elements that can be included as the content of the element

atts:AttributeList

the attributes of the element

Returns:Element

the new Element

defEntityback to summary
public Entity defEntity(String name, int type, int ch)

Creates and returns a character Entity.

Parameters
name:String

the entity's name

type:int

the entity's type

ch:int

the entity's value (character)

Returns:Entity

the new character Entity

defEntityback to summary
protected Entity defEntity(String name, int type, String str)

Creates and returns an Entity.

Parameters
name:String

the entity's name

type:int

the entity's type

str:String

the entity's data section

Returns:Entity

the new Entity

defineAttributesback to summary
public void defineAttributes(String name, AttributeList atts)

Defines attributes for an Element.

Parameters
name:String

the name of the Element

atts:AttributeList

the AttributeList specifying the Element

defineElementback to summary
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:String

the name of the Element

type:int

the type of the Element

omitStart:boolean

true if start should be omitted

omitEnd:boolean

true if end should be omitted

content:ContentModel

the ContentModel

exclusions:BitSet

the set of elements that must not occur inside the element

inclusions:BitSet

the set of elements that can occur inside the element

atts:AttributeList

the AttributeList specifying the Element

Returns:Element

the Element specified

defineEntityback to summary
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:String

the name of the Entity as a String

type:int

the type of the Entity

data:char[]

the Entity's data

Returns:Entity

the Entity requested or a new Entity if not found

elementExistsback to summary
pack-priv boolean elementExists(String name)

Returns true if the element is part of the DTD, otherwise returns false.

Parameters
name:String

the requested String

Returns:boolean

true if name exists as part of the DTD, otherwise returns false

getDTDback to summary
public static DTD getDTD(String name) throws IOException

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:String

the name of the DTD

Returns:DTD

the DTD which corresponds to name

Exceptions
IOException:
if an I/O error occurs
getElementback to summary
public Element getElement(String name)

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

Parameters
name:String

the requested String

Returns:Element

the Element corresponding to name, which may be newly created

getElementback to summary
public Element getElement(int index)

Gets an element by index.

Parameters
index:int

the requested index

Returns:Element

the Element corresponding to index

getEntityback to summary
public Entity getEntity(String name)

Gets an entity by name.

Parameters
name:String

the entity name

Returns:Entity

the Entity corresponding to the name String

getEntityback to summary
public Entity getEntity(int ch)

Gets a character entity.

Parameters
ch:int

the character

Returns:Entity

the Entity corresponding to the ch character

getNameback to summary
public String getName()

Gets the name of the DTD.

Returns:String

the name of the DTD

putDTDHashback to summary
public static void putDTDHash(String name, DTD dtd)

Put a name and appropriate DTD to hashtable.

Parameters
name:String

the name of the DTD

dtd:DTD

the DTD

readback to summary
public void read(DataInputStream in) throws IOException

Recreates a DTD from an archived format.

Parameters
in:DataInputStream

the DataInputStream to read from

Exceptions
IOException:
if an I/O error occurs
readAttributeListback to summary
private AttributeList readAttributeList(DataInputStream in, String[] names) throws IOException
readContentModelback to summary
private ContentModel readContentModel(DataInputStream in, String[] names) throws IOException
readNameArrayback to summary
private String[] readNameArray(DataInputStream in, String[] names) throws IOException
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Returns a string representation of this DTD.

Returns:String

the string representation of this DTD