Class DTD
java.lang.Object
javax.swing.text.html.parser.DTD
- All Implemented Interfaces:
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:
-
Field Summary
FieldsModifier and TypeFieldDescriptionfinal Element
The element corresponding to applet.final Element
The element corresponding to base.final Element
The element corresponding to body.The hash table contains the name of element and the corresponding element.The vector of elementsThe hash table contains anObject
and the correspondingEntity
static final int
The version of a filefinal Element
The element corresponding to head.final Element
The element corresponding to html.final Element
The element corresponding to isindex.final Element
The element corresponding to meta.the name of the DTDfinal Element
The element corresponding to p.final Element
The element corresponding to param.final Element
The element corresponding to pcdata.final Element
The element corresponding to title.Fields declared in interface 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
Modifier and TypeFieldDescriptionstatic final int
The DTD constant corresponds to ANYstatic final int
The DTD constant corresponds to CDATAstatic final int
The DTD constant corresponds to CONREFstatic final int
The DTD constant corresponds to CURRENTstatic final int
The DTD constant corresponds to DEFAULTstatic final int
The DTD constant corresponds to EMPTYstatic final int
The DTD constant corresponds to ENDTAGstatic final int
The DTD constant corresponds to ENTITIESstatic final int
The DTD constant corresponds to ENTITYstatic final int
The DTD constant corresponds to FIXEDstatic final int
The DTD constant corresponds to GENERALstatic final int
The DTD constant corresponds to IDstatic final int
The DTD constant corresponds to IDREFstatic final int
The DTD constant corresponds to IDREFSstatic final int
The DTD constant corresponds to IMPLIEDstatic final int
The DTD constant corresponds to MDstatic final int
The DTD constant corresponds to MODELstatic final int
The DTD constant corresponds to MSstatic final int
The DTD constant corresponds to NAMEstatic final int
The DTD constant corresponds to NAMESstatic final int
The DTD constant corresponds to NMTOKENstatic final int
The DTD constant corresponds to NMTOKENSstatic final int
The DTD constant corresponds to NOTATIONstatic final int
The DTD constant corresponds to NUMBERstatic final int
The DTD constant corresponds to NUMBERSstatic final int
The DTD constant corresponds to NUTOKENstatic final int
The DTD constant corresponds to NUTOKENSstatic final int
The DTD constant corresponds to PARAMETERstatic final int
The DTD constant corresponds to PIstatic final int
The DTD constant corresponds to PUBLICstatic final int
The DTD constant corresponds to RCDATAstatic final int
The DTD constant corresponds to REQUIREDstatic final int
The DTD constant corresponds to SDATAstatic final int
The DTD constant corresponds to STARTTAGstatic final int
The DTD constant corresponds to SYSTEM -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected AttributeList
defAttributeList
(String name, int type, int modifier, String value, String values, AttributeList atts) Creates and returns anAttributeList
responding to a new attribute.protected ContentModel
defContentModel
(int type, Object obj, ContentModel next) Creates and returns a new content model.protected Element
defElement
(String name, int type, boolean omitStart, boolean omitEnd, ContentModel content, String[] exclusions, String[] inclusions, AttributeList atts) Creates and returns anElement
.Creates and returns a characterEntity
.protected Entity
Creates and returns anEntity
.void
defineAttributes
(String name, AttributeList atts) Defines attributes for anElement
.defineElement
(String name, int type, boolean omitStart, boolean omitEnd, ContentModel content, BitSet exclusions, BitSet inclusions, AttributeList atts) Returns theElement
which matches the specified parameters.defineEntity
(String name, int type, char[] data) Defines an entity.static DTD
Returns a DTD with the specifiedname
.getElement
(int index) Gets an element by index.getElement
(String name) Gets an element by name.getEntity
(int ch) Gets a character entity.Gets an entity by name.getName()
Gets the name of the DTD.static void
putDTDHash
(String name, DTD dtd) Put a name and appropriate DTD to hashtable.void
read
(DataInputStream in) Recreates a DTD from an archived format.toString()
Returns a string representation of this DTD.Methods declared in class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Modifier and TypeMethodDescriptionprotected Object
clone()
Creates and returns a copy of this object.boolean
Indicates whether some other object is "equal to" this one.protected void
finalize()
Deprecated, for removal: This API element is subject to removal in a future version.Finalization is deprecated and subject to removal in a future release.final Class
<?> getClass()
Returns the runtime class of thisObject
.int
hashCode()
Returns a hash code value for this object.final void
notify()
Wakes up a single thread that is waiting on this object's monitor.final void
Wakes up all threads that are waiting on this object's monitor.final void
wait()
Causes the current thread to wait until it is awakened, typically by being notified or interrupted.final void
wait
(long timeoutMillis) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.final void
wait
(long timeoutMillis, int nanos) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.
-
Field Details
-
name
the name of the DTD -
elements
-
elementHash
-
entityHash
-
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:
-
-
Constructor Details
-
DTD
Creates a new DTD with the specified name.- Parameters:
name
- the name, as aString
of the new DTD
-
-
Method Details
-
getName
-
getEntity
-
getEntity
Gets a character entity.- Parameters:
ch
- the character- Returns:
- the
Entity
corresponding to thech
character
-
getElement
-
getElement
Gets an element by index.- Parameters:
index
- the requested index- Returns:
- the
Element
corresponding toindex
-
defineEntity
Defines an entity. If theEntity
specified byname
,type
, anddata
exists, it is returned; otherwise a newEntity
is created and is returned.- Parameters:
name
- the name of theEntity
as aString
type
- the type of theEntity
data
- theEntity
's data- Returns:
- the
Entity
requested or a newEntity
if not found
-
defineElement
public Element defineElement(String name, int type, boolean omitStart, boolean omitEnd, ContentModel content, BitSet exclusions, BitSet inclusions, AttributeList atts) Returns theElement
which matches the specified parameters. If one doesn't exist, a new one is created and returned.- Parameters:
name
- the name of theElement
type
- the type of theElement
omitStart
-true
if start should be omittedomitEnd
-true
if end should be omittedcontent
- theContentModel
exclusions
- the set of elements that must not occur inside the elementinclusions
- the set of elements that can occur inside the elementatts
- theAttributeList
specifying theElement
- Returns:
- the
Element
specified
-
defineAttributes
Defines attributes for anElement
.- Parameters:
name
- the name of theElement
atts
- theAttributeList
specifying theElement
-
defEntity
-
defEntity
-
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
-true
if the element needs no starting tagomitEnd
-true
if 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 anAttributeList
responding 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
-
putDTDHash
-
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
- theDataInputStream
to read from- Throws:
IOException
- if an I/O error occurs
-