DTDDoc
Class ExtendedDTD

java.lang.Object
  extended by DTDDoc.ExtendedDTD

public class ExtendedDTD
extends java.lang.Object

An object of this class represents a full DTD. That is, the result of interpretation of a DTD file and all the other files it includes. A DTD defines a bunch of elements and attributes (and small other things as well). A DTD file can includes other DTD's file. Therefore some pieces, although defined in some other files, are defined in the DTD represented by this. We call such pieces "external". One of the goals of this class is to improve over Mark Wutka's DTD class so that one can know if an element/attribute is "external" or not.

Author:
Stefan Champailler

Constructor Summary
ExtendedDTD(java.io.File dtdFilePath, Logger log, boolean getAroundNetBeanComments)
          Build all the information needed to make a ExtendedDTD out of a "normal" DTD.
 
Method Summary
static java.util.Set collectDeclaredChildren(com.wutka.dtd.DTDElement element)
          Collects the elements that appear in the definition of a given element (its "children").
 java.lang.String getDoctype()
          Returns the doctype of the DTD (see the doctype tag).
 java.lang.String getEffectiveEncoding()
          Get the effective encoding of the file: either the encoding specified in the file, or the default encoding (UTF-8) if not specified
 com.wutka.dtd.DTDElement getElementByName(com.wutka.dtd.DTDName name)
           
 com.wutka.dtd.DTDElement getElementByName(java.lang.String name)
           
 java.lang.String getElementOrigin(com.wutka.dtd.DTDElement element)
          Gives the file name of the DTD where a given element is defined.
 java.util.Map getElements()
          Return all the DTDElements of the DTD (a transparent wrapper around the same function in Wutka's library).
 java.util.Collection getElementsCollection()
           
 java.lang.String getEncoding()
          Get the encoding specified in the file, if any.
 java.util.Map getEntities()
          Return all the DTDEntities of the DTD (a transparent wrapper around the same function in Wutka's library).
 java.util.List getItems()
          Return all the DTDItems of the DTD (a transparent wrapper around the same function in Wutka's library).
 java.util.Set getParents(java.lang.String sonName)
          Gets the parents of an element.
 com.wutka.dtd.DTDElement getRootElement()
          Returns the root elements of the DTD, as defined by the \@root tag.
 java.io.File getSystemPath()
          Returns the full path to the original DTD.
 java.lang.String getTitle()
          Returns the title of the DTD (see the @title tag).
static java.lang.String getUniqueId(com.wutka.dtd.DTDAttlist attList, com.wutka.dtd.DTDAttribute attribute)
          Gives a unique id for an attribute in a DTD.
static java.lang.String getUniqueId(com.wutka.dtd.DTDElement element)
          Gives a unique id for an element of a DTD.
static java.lang.String getUniqueId(com.wutka.dtd.DTDElement element, com.wutka.dtd.DTDAttribute attribute)
          Gives a unique id for an attribute in a DTD.
 boolean isExternal(com.wutka.dtd.DTDAttlist attList)
          Determine if an attributes list is defined in this DTD.
 boolean isExternal(com.wutka.dtd.DTDElement element)
          Tells if an element is declared in a DTD outside the one represented in this.
 boolean isRoot(com.wutka.dtd.DTDElement element)
          Check if an element is root, that is, if it has no parent.
 com.wutka.dtd.DTDAttlist locateAttributesList(com.wutka.dtd.DTDAttribute attribute)
           
 void setRootElement(com.wutka.dtd.DTDElement element)
          Setter for the root elements of the DTD.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExtendedDTD

public ExtendedDTD(java.io.File dtdFilePath,
                   Logger log,
                   boolean getAroundNetBeanComments)
            throws java.io.IOException
Build all the information needed to make a ExtendedDTD out of a "normal" DTD. The original DTD will be read with Mark Wutka's powerful DTD parser.

Parameters:
dtdFilePath - Path to the original DTD.
Throws:
java.io.IOException
Method Detail

getEncoding

public java.lang.String getEncoding()
Get the encoding specified in the file, if any. For example, ISO-8859-1. This is dictated by the <? ... encoding="" ?> processing instruction.

Returns:
the encoding, or null if no encoding was set
See Also:
getEffectiveEncoding()

getEffectiveEncoding

public java.lang.String getEffectiveEncoding()
Get the effective encoding of the file: either the encoding specified in the file, or the default encoding (UTF-8) if not specified

Returns:
the effective encoding (not null)

getTitle

public java.lang.String getTitle()
Returns the title of the DTD (see the @title tag).

Returns:
the title of the DTD.

getDoctype

public java.lang.String getDoctype()
Returns the doctype of the DTD (see the doctype tag).

Returns:
the doctype of the DTD.

getItems

public java.util.List getItems()
Return all the DTDItems of the DTD (a transparent wrapper around the same function in Wutka's library).

Returns:
The DTD Items of the DTD.

getElements

public java.util.Map getElements()
Return all the DTDElements of the DTD (a transparent wrapper around the same function in Wutka's library).

Returns:
A mapping from the name of the elements to their instance.

getElementsCollection

public java.util.Collection getElementsCollection()

getElementByName

public com.wutka.dtd.DTDElement getElementByName(java.lang.String name)

getElementByName

public com.wutka.dtd.DTDElement getElementByName(com.wutka.dtd.DTDName name)

getEntities

public java.util.Map getEntities()
Return all the DTDEntities of the DTD (a transparent wrapper around the same function in Wutka's library).

Returns:
A mapping from the name of the entities to their instance.

getRootElement

public com.wutka.dtd.DTDElement getRootElement()
Returns the root elements of the DTD, as defined by the \@root tag.

Returns:
the root element.

setRootElement

public void setRootElement(com.wutka.dtd.DTDElement element)
Setter for the root elements of the DTD.

Parameters:
element - The root element.

getSystemPath

public java.io.File getSystemPath()
Returns the full path to the original DTD.

Returns:
Full path to the original DTD..

isExternal

public boolean isExternal(com.wutka.dtd.DTDElement element)
Tells if an element is declared in a DTD outside the one represented in this.

Parameters:
element - element to be checked for externality
Returns:
true if external, false if not (or element not part of the DTD's elements.

isExternal

public boolean isExternal(com.wutka.dtd.DTDAttlist attList)
Determine if an attributes list is defined in this DTD.

Parameters:
attList - attributes list to look for.
Returns:
true if the list is defined outside this DTD (therefore in another one.

getElementOrigin

public java.lang.String getElementOrigin(com.wutka.dtd.DTDElement element)
Gives the file name of the DTD where a given element is defined.

Parameters:
element - element to be checked
Returns:
the file name or null if the element is not part of the DTD.

getUniqueId

public static java.lang.String getUniqueId(com.wutka.dtd.DTDAttlist attList,
                                           com.wutka.dtd.DTDAttribute attribute)
Gives a unique id for an attribute in a DTD. The id construction relies on the fact that an attribute is always related to a element. That is each (element, attribute) pair is unique in a DTD.

Parameters:
attList - The attributes list the attibute is part of.
attribute - The attribute for which we seek the id.
Returns:
The id of the attribute.

getUniqueId

public static java.lang.String getUniqueId(com.wutka.dtd.DTDElement element,
                                           com.wutka.dtd.DTDAttribute attribute)
Gives a unique id for an attribute in a DTD.

Parameters:
element - The element to which the attribute belongs.
attribute - The attribute to get the id for.
Returns:
The id of the attribute.
See Also:
getUniqueId( DTDAttlist attList, DTDAttribute attribute)

getUniqueId

public static java.lang.String getUniqueId(com.wutka.dtd.DTDElement element)
Gives a unique id for an element of a DTD.

Parameters:
element - The element.
Returns:
The id of the element.

locateAttributesList

public com.wutka.dtd.DTDAttlist locateAttributesList(com.wutka.dtd.DTDAttribute attribute)

getParents

public java.util.Set getParents(java.lang.String sonName)
Gets the parents of an element.

Parameters:
sonName - The name of the element to look for.
Returns:
Null if the element doesn't exist or it has no parent.

isRoot

public boolean isRoot(com.wutka.dtd.DTDElement element)
Check if an element is root, that is, if it has no parent.

Parameters:
element - The element to check.
Returns:
True if its is root, false else.

collectDeclaredChildren

public static java.util.Set collectDeclaredChildren(com.wutka.dtd.DTDElement element)
Collects the elements that appear in the definition of a given element (its "children").

Special definitions such as ANY, EMPTY and PCDATA are ignored.

Parameters:
element - The element.
Returns:
The set of children or null if there ain't any child.


Copyright © 2002-2009 DTDDoc. All Rights Reserved.