|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.swing.text.html.parser.DTD
public class DTD
Representation or the SGML DTD document.
Provides basis for describing a syntax of the
HTML documents. The fields of this class are NOT initialized in
constructor. You need to do this separately before passing this data
structure to the HTML parser. The subclasses with the fields, pre-
initialized, for example, for HTML 4.01, can be available only between
the implementation specific classes
( for example, gnu.javax.swing.text.html.parser.HTML_401F
in this implementation).
If you need more information about SGML DTD documents, the author suggests to read SGML tutorial on http://www.w3.org/TR/WD-html40-970708/intro/sgmltut.html. We also recommend Goldfarb C.F (1991) The SGML Handbook, Oxford University Press, 688 p, ISBN: 0198537379.
Warning: the html, head and other tag fields will only be automatically assigned if the VM has the correctly implemented reflection mechanism. As these fields are not used anywhere in the implementation, not exception will be thrown in the opposite case.
Field Summary | |
---|---|
Element |
applet
The applet element for this DTD. |
Element |
base
The base element for this DTD. |
Element |
body
The body element for this DTD. |
Hashtable<String,Element> |
elementHash
The element for accessing all DTD elements by name. |
Vector<Element> |
elements
Contains all elements in this DTD. |
Hashtable<Object,Entity> |
entityHash
The entity table for accessing all DTD entities by name. |
static int |
FILE_VERSION
The version of the persistent data format. |
Element |
head
The head element for this DTD. |
Element |
html
The html element for this DTD. |
Element |
isindex
The isindex element of for this DTD. |
Element |
meta
The meta element for this DTD. |
String |
name
The name of this DTD. |
Element |
p
The p element for this DTD. |
Element |
param
The param element for this DTD. |
Element |
pcdata
The pcdata for this DTD. |
Element |
title
The title element for this DTD. |
Fields inherited from 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 | |
---|---|
protected |
DTD(String a_name)
Create a new DTD with the specified name. |
Method Summary | |
---|---|
protected AttributeList |
defAttributeList(String name,
int type,
int modifier,
String default_value,
String allowed_values,
AttributeList atts)
Creates and returns new attribute (not an attribute list). |
protected ContentModel |
defContentModel(int type,
Object content,
ContentModel next)
Creates a new content model. |
protected Element |
defElement(String name,
int type,
boolean headless,
boolean tailless,
ContentModel content,
String[] exclusions,
String[] inclusions,
AttributeList attributes)
Defines a new element and adds it to the element table. |
Entity |
defEntity(String name,
int type,
int character)
Creates, adds into the entity table and returns the character entity like <
(means '< ' ); |
protected Entity |
defEntity(String name,
int type,
String data)
Creates, intializes and adds to the entity table the new entity. |
void |
defineAttributes(String forElement,
AttributeList attributes)
Define the attributes for the element with the given name. |
Element |
defineElement(String name,
int type,
boolean headless,
boolean tailless,
ContentModel content,
BitSet exclusions,
BitSet inclusions,
AttributeList attributes)
Defines the element and adds it to the element table. |
Entity |
defineEntity(String name,
int type,
char[] data)
Creates, intializes and adds to the entity table the new entity. |
static DTD |
getDTD(String name)
Get this DTD by name. |
Element |
getElement(int index)
Get the element by the value of its Element.index field. |
Element |
getElement(String element_name)
Get the element by the element name. |
Entity |
getEntity(int id)
Get the entity with the given identifier. |
Entity |
getEntity(String entity_name)
Get the named entity by its name. |
String |
getName()
Get the name of this instance of DTD |
static void |
putDTDHash(String name,
DTD dtd)
Place this DTD into the DTD table. |
void |
read(DataInputStream stream)
Reads DTD from an archived format. |
String |
toString()
Returns the name of this instance of DTD. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int FILE_VERSION
public Element applet
public Element base
public Element body
public Element head
public Element html
public Element isindex
public Element meta
public Element p
public Element param
public Element pcdata
public Element title
public Hashtable<String,Element> elementHash
public Hashtable<Object,Entity> entityHash
public String name
public Vector<Element> elements
Constructor Detail |
---|
protected DTD(String a_name)
Method Detail |
---|
public static DTD getDTD(String name) throws IOException
IOException
public Element getElement(String element_name)
public Element getElement(int index)
Element.index
field.
public Entity getEntity(int id)
id
- that can be returned by
Entity.name2type(String an_entity)
public Entity getEntity(String entity_name)
public String getName()
public Entity defEntity(String name, int type, int character)
<
(means '<
' );
name
- The entity name (without heading & and closing ;)type
- The entity typecharacter
- The entity value (single character)
public void defineAttributes(String forElement, AttributeList attributes)
forElement
- attributes
- public Element defineElement(String name, int type, boolean headless, boolean tailless, ContentModel content, BitSet exclusions, BitSet inclusions, AttributeList attributes)
Element.index
field to the value, unique for this
instance of DTD. If the element with the given name already exists,
replaces all other its settings by the method argument values.
name
- the name of the elementtype
- the type of the elementheadless
- true if the element needs no starting tag
(should not occur in HTML).tailless
- true if the element needs no ending tag (like
<hr>
content
- the element contentexclusions
- the set of elements that must not occur inside
this element. The Element.index
value defines which
bit in this bitset corresponds to that element.inclusions
- the set of elements that can occur inside this
element. the Element.index
value defines which
bit in this bitset corresponds to that element.attributes
- the element attributes.
public Entity defineEntity(String name, int type, char[] data)
name
- the name of the entitytype
- the type of the entitydata
- the data section of the entity
public static void putDTDHash(String name, DTD dtd)
public void read(DataInputStream stream) throws IOException
Reads DTD from an archived format. This format is not standardized and differs between implementations.
This implementation reads and defines all entities and elements using ObjectInputStream. The elements and entities can be written into the stream in any order. The objects other than elements and entities are ignored.
stream
- A data stream to read from.
IOException
- If one is thrown by the input streampublic String toString()
toString
in class Object
Object.getClass()
,
Object.hashCode()
,
Class.getName()
,
Integer.toHexString(int)
protected AttributeList defAttributeList(String name, int type, int modifier, String default_value, String allowed_values, AttributeList atts)
name
- the name of this attributetype
- the type of this attribute (FIXED, IMPLIED or
REQUIRED from DTDConstants
).modifier
- the modifier of this attributedefault_value
- the default value of this attributeallowed_values
- the allowed values of this attribute. The multiple
possible values in this parameter are supposed to be separated by
'|', same as in SGML DTD <!ATTLIST
tag. This parameter
can be null if no list of allowed values is specified.atts
- the previous attribute of this element. This is
placed to the field
AttributeList.next
,
creating a linked list.
protected ContentModel defContentModel(int type, Object content, ContentModel next)
type
- specifies the BNF operation for this content model.
The valid operations are documented in the
ContentModel.type
.content
- the content of this content modelnext
- if the content model is specified by BNF-like
expression, contains the rest of this expression.
protected Element defElement(String name, int type, boolean headless, boolean tailless, ContentModel content, String[] exclusions, String[] inclusions, AttributeList attributes)
name
- the name of the new elementtype
- the type of the elementheadless
- true if the element needs no starting tagtailless
- true if the element needs no closing tagcontent
- the element content.exclusions
- the elements that must be excluded from the
content of this element, in all levels of the hierarchy.inclusions
- the elements that can be included as the
content of this element.attributes
- the element attributes.
protected Entity defEntity(String name, int type, String data)
name
- the name of the entitytype
- the type of the entitydata
- the data section of the entity
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |