gnu.javax.swing.text.html.parser

Class gnuDTD

Implemented Interfaces:
DTDConstants, Serializable
Known Direct Subclasses:
HTML_401F

public class gnuDTD
extends DTD
implements DTDConstants, Serializable

The class is derived from gnu.javax.swing.text.html.parser.DTD making structure creation methods public. This is required when creating the DTD by SGML parser that must have access to the structure. SGML DTD representation. 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 parser constructor.

This implementation also provides you the derived class gnu.javax.swing.text.html.parser.DTD.HTML_4_0_1, where all fields are initialized to the values, representing HTML 4.01 ("-//W3C//DTD HTML 4.01 Frameset//EN") DTD. You can use it if you do not care about the portability between different implementations of the core class libraries.

Use javax.swing.HTML.HTMLEditorKit.Parser.parse for parsing in accordance with "-//W3C//DTD HTML 4.01 Frameset//EN" without specifying DTD separately.

See Also:
Serialized Form

Field Summary

static int
Char
The Char element type
static int
Color
The Color element type
static int
Length
The Length element type
static int
URI
The URI element type (not defined in DTDConstants).

Fields inherited from class javax.swing.text.html.parser.DTD

Element>(), Entity>(), Entity>entityHash, FILE_VERSION, applet, base, body, elementHash, elements, head, html, isindex, meta, name, p, param, pcdata, title

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

gnuDTD(String name)
Creates a new instance of gnuDTD.

Method Summary

protected AttributeList
attr(String name, String default_value, String[] allowed_values, int type, int modifier)
Creates the attribute.
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).
void
defAttrsFor(String forElement, AttributeList attributes)
Define the attributes for the element with the given name.
ContentModel
defContentModel(int type, Object content, ContentModel next)
Creates a new content model.
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.
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.
Element
defElement(String name, int type, boolean headless, boolean tailless, ContentModel content, Collection<E> exclusions, Collection<E> inclusions, AttributeList attributes)
Defines a new element and adds it to the element table.
Entity
defEntity(String name, int type, String data)
Creates, adds into the internal table and returns the character entity like &lt; (means '<' ); This method inactivates the recursive refenrences to the same entity.
protected void
defineEntity(String name, int character)
Define the general entity, holding a single character.
void
dump(PrintStream p)
Summarises the document content into the given PrintStream.
void
dump(BitSet b)
Prints the content of the given attribute set to the System.out.

Methods inherited from class javax.swing.text.html.parser.DTD

defAttributeList, defContentModel, defElement, defEntity, defEntity, defineAttributes, defineElement, defineEntity, getDTD, getElement, getElement, getEntity, getEntity, getName, putDTDHash, read, toString

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Details

Char

public static final int Char
The Char element type
Field Value:
514

Color

public static final int Color
The Color element type
Field Value:
515

Length

public static final int Length
The Length element type
Field Value:
513

URI

public static final int URI
The URI element type (not defined in DTDConstants).
Field Value:
512

Constructor Details

gnuDTD

public gnuDTD(String name)
Creates a new instance of gnuDTD.
Parameters:
name - the name of the DTD.

Method Details

attr

protected AttributeList attr(String name,
                             String default_value,
                             String[] allowed_values,
                             int type,
                             int modifier)
Creates the attribute.
Parameters:
name - The attribute name.
allowed_values - Allowed values (or null)
type - The attribute type.
modifier - The attribute modifier.
Returns:
The newly created AttributeList. The next field is initialized to null.

defAttributeList

public 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).
Overrides:
defAttributeList in interface DTD
Parameters:
name - the name of this attribute
type - the type of this attribute (FIXED, IMPLIED or REQUIRED from DTDConstants).
modifier - the modifier of this attribute
default_value - the default value of this attribute or null if it is not specified.
allowed_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.
Returns:

defAttrsFor

public void defAttrsFor(String forElement,
                        AttributeList attributes)
Define the attributes for the element with the given name. If the element is not exist, it is created. This method is needed if the element attributes are defined befor the element itself.
Parameters:
forElement -
attributes -

defContentModel

public ContentModel defContentModel(int type,
                                    Object content,
                                    ContentModel next)
Creates a new content model.
Overrides:
defContentModel in interface DTD
Parameters:
type - specifies the BNF operation for this content model. The valid operations are documented in the ContentModel.type.
content - the content of this content model
next - if the content model is specified by BNF-like expression, contains the rest of this expression.
Returns:
The newly created content model.

defElement

public 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. If the element alredy exists, overrides it settings with the specified values.
Overrides:
defElement in interface DTD
Parameters:
name - the name of the new element
type - the type of the element
headless - true if the element needs no starting tag
tailless - true if the element needs no closing tag
content - 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.
Returns:
the created or updated element.

defElement

public 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. If the element alredy exists, overrides it settings with the specified values.
Parameters:
name - the name of the new element
type - the type of the element
headless - true if the element needs no starting tag
tailless - true if the element needs no closing tag
content - 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 (an array and not a linked list). The attributes are chained into the linked list inside this method.
Returns:
the created or updated element.

defElement

public Element defElement(String name,
                          int type,
                          boolean headless,
                          boolean tailless,
                          ContentModel content,
                          Collection<E> exclusions,
                          Collection<E> inclusions,
                          AttributeList attributes)
Defines a new element and adds it to the element table. If the element alredy exists, overrides it settings with the specified values.
Parameters:
name - the name of the new element
type - the type of the element
headless - true if the element needs no starting tag
tailless - true if the element needs no closing tag
content - 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.
Returns:
the created or updated element.

defEntity

public Entity defEntity(String name,
                        int type,
                        String data)
Creates, adds into the internal table and returns the character entity like &lt; (means '<' ); This method inactivates the recursive refenrences to the same entity.
Overrides:
defEntity in interface DTD
Parameters:
name - The entity name (without heading & and closing ;)
type - The entity type
Returns:
The created entity

defineEntity

protected void defineEntity(String name,
                            int character)
Define the general entity, holding a single character.
Parameters:
name - The entity name (for example, 'amp'). The defined entity is stored into the entity table.
character - The entity character (for example, '&').

dump

public void dump(PrintStream p)
Summarises the document content into the given PrintStream.

dump

public void dump(BitSet b)
Prints the content of the given attribute set to the System.out.
Parameters:
b -

gnuDTD.java -- Copyright (C) 2005 Free Software Foundation, Inc. This file is part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Classpath; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.