java.lang.Object
javax.swing.text.html.parser.DTD
- All Implemented Interfaces:
DTDConstants
public class DTD extends Object implements DTDConstants
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.
- See Also:
Element,AttributeList,ContentModel,Parser
-
Field Summary
Fields Modifier and Type Field Description ElementappletThe element corresponding to applet.ElementbaseThe element corresponding to base.ElementbodyThe element corresponding to body.Hashtable<String,Element>elementHashThe hash table contains the name of element and the corresponding element.Vector<Element>elementsThe vector of elementsHashtable<Object,Entity>entityHashThe hash table contains anObjectand the correspondingEntitystatic intFILE_VERSIONThe version of a fileElementheadThe element corresponding to head.ElementhtmlThe element corresponding to html.ElementisindexThe element corresponding to isindex.ElementmetaThe element corresponding to meta.Stringnamethe name of the DTDElementpThe element corresponding to p.ElementparamThe element corresponding to param.ElementpcdataThe element corresponding to pcdata.ElementtitleThe element corresponding to title.Fields declared in interface javax.swing.text.html.parser.DTDConstants
ANY, CDATA, CONREF, CURRENT, DEFAULT, EMPTY, ENDTAG, ENTITIES, ENTITY, FIXED, GENERAL, ID, IDREF, IDREFS, IMPLIED, MD, MODEL, MS, NAME, NAMES, NMTOKEN, NMTOKENS, NOTATION, NUMBER, NUMBERS, NUTOKEN, NUTOKENS, PARAMETER, PI, PUBLIC, RCDATA, REQUIRED, SDATA, STARTTAG, SYSTEM -
Constructor Summary
-
Method Summary
Modifier and Type Method Description protected AttributeListdefAttributeList(String name, int type, int modifier, String value, String values, AttributeList atts)Creates and returns anAttributeListresponding to a new attribute.protected ContentModeldefContentModel(int type, Object obj, ContentModel next)Creates and returns a new content model.protected ElementdefElement(String name, int type, boolean omitStart, boolean omitEnd, ContentModel content, String[] exclusions, String[] inclusions, AttributeList atts)Creates and returns anElement.EntitydefEntity(String name, int type, int ch)Creates and returns a characterEntity.protected EntitydefEntity(String name, int type, String str)Creates and returns anEntity.voiddefineAttributes(String name, AttributeList atts)Defines attributes for anElement.ElementdefineElement(String name, int type, boolean omitStart, boolean omitEnd, ContentModel content, BitSet exclusions, BitSet inclusions, AttributeList atts)Returns theElementwhich matches the specified parameters.EntitydefineEntity(String name, int type, char[] data)Defines an entity.static DTDgetDTD(String name)Returns a DTD with the specifiedname.ElementgetElement(int index)Gets an element by index.ElementgetElement(String name)Gets an element by name.EntitygetEntity(int ch)Gets a character entity.EntitygetEntity(String name)Gets an entity by name.StringgetName()Gets the name of the DTD.static voidputDTDHash(String name, DTD dtd)Put a name and appropriate DTD to hashtable.voidread(DataInputStream in)Recreates a DTD from an archived format.StringtoString()Returns a string representation of this DTD.
-
Field Details
-
name
the name of the DTD -
elements
The vector of elements -
elementHash
The hash table contains the name of element and the corresponding element. -
entityHash
The hash table contains anObjectand the correspondingEntity -
pcdata
The element corresponding to pcdata. -
html
The element corresponding to html. -
meta
The element corresponding to meta. -
base
The element corresponding to base. -
isindex
The element corresponding to isindex. -
head
The element corresponding to head. -
body
The element corresponding to body. -
applet
The element corresponding to applet. -
param
The element corresponding to param. -
p
The element corresponding to p. -
title
The element corresponding to title. -
FILE_VERSION
public static final int FILE_VERSIONThe version of a file- See Also:
- Constant Field Values
-
-
Constructor Details
-
DTD
Creates a new DTD with the specified name.- Parameters:
name- the name, as aStringof the new DTD
-
-
Method Details
-
getName
Gets the name of the DTD.- Returns:
- the name of the DTD
-
getEntity
Gets an entity by name.- Parameters:
name- the entity name- Returns:
- the
Entitycorresponding to thenameString
-
getEntity
Gets a character entity.- Parameters:
ch- the character- Returns:
- the
Entitycorresponding to thechcharacter
-
getElement
Gets an element by name. A new element is created if the element doesn't exist.- Parameters:
name- the requestedString- Returns:
- the
Elementcorresponding toname, which may be newly created
-
getElement
Gets an element by index.- Parameters:
index- the requested index- Returns:
- the
Elementcorresponding toindex
-
defineEntity
Defines an entity. If theEntityspecified byname,type, anddataexists, it is returned; otherwise a newEntityis created and is returned.- Parameters:
name- the name of theEntityas aStringtype- the type of theEntitydata- theEntity's data- Returns:
- the
Entityrequested or a newEntityif not found
-
defineElement
public Element defineElement(String name, int type, boolean omitStart, boolean omitEnd, ContentModel content, BitSet exclusions, BitSet inclusions, AttributeList atts)Returns theElementwhich matches the specified parameters. If one doesn't exist, a new one is created and returned.- Parameters:
name- the name of theElementtype- the type of theElementomitStart-trueif start should be omittedomitEnd-trueif end should be omittedcontent- theContentModelexclusions- the set of elements that must not occur inside the elementinclusions- the set of elements that can occur inside the elementatts- theAttributeListspecifying theElement- Returns:
- the
Elementspecified
-
defineAttributes
Defines attributes for anElement.- Parameters:
name- the name of theElementatts- theAttributeListspecifying theElement
-
defEntity
Creates and returns a characterEntity.- Parameters:
name- the entity's nametype- the entity's typech- the entity's value (character)- Returns:
- the new character
Entity
-
defEntity
Creates and returns anEntity.- Parameters:
name- the entity's nametype- the entity's typestr- the entity's data section- Returns:
- the new
Entity
-
defElement
protected Element defElement(String name, int type, boolean omitStart, boolean omitEnd, ContentModel content, String[] exclusions, String[] inclusions, AttributeList atts)Creates and returns anElement.- Parameters:
name- the element's nametype- the element's typeomitStart-trueif the element needs no starting tagomitEnd-trueif the element needs no closing tagcontent- the element's contentexclusions- the elements that must be excluded from the content of the elementinclusions- the elements that can be included as the content of the elementatts- the attributes of the element- Returns:
- the new
Element
-
defAttributeList
protected AttributeList defAttributeList(String name, int type, int modifier, String value, String values, AttributeList atts)Creates and returns anAttributeListresponding to a new attribute.- Parameters:
name- the attribute's nametype- the attribute's typemodifier- the attribute's modifiervalue- the default value of the attributevalues- the allowed values for the attribute (multiple values could be separated by '|')atts- the previous attribute of the element; to be placed toAttributeList.next, creating a linked list- Returns:
- the new
AttributeList
-
defContentModel
Creates and returns a new content model.- Parameters:
type- the type of the new content modelobj- the content of the content modelnext- pointer to the next content model- Returns:
- the new
ContentModel
-
toString
Returns a string representation of this DTD. -
putDTDHash
Put a name and appropriate DTD to hashtable.- Parameters:
name- the name of the DTDdtd- the DTD
-
getDTD
Returns a DTD with the specifiedname. 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- if an I/O error occurs
-
read
Recreates a DTD from an archived format.- Parameters:
in- theDataInputStreamto read from- Throws:
IOException- if an I/O error occurs
-