Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.enhydra.xml.xmlc.dom
Class DocTypeBuilder  view DocTypeBuilder download DocTypeBuilder.java

java.lang.Object
  extended byorg.enhydra.xml.xmlc.dom.DocTypeBuilder

public class DocTypeBuilder
extends java.lang.Object

Class for building a DOM DocumentType. Used by XMLC parsers to build a document DOM.

Since the DOM level 1 does not address storing all of the information from the DOCTYPE and DTDs required by XMLC, routine are provided to add this information. Only a subset of the information is actually saved. The internal subset is needed to reproduce the DOCTYPE declaration in the compiled document. The attribute declarations from the external subset are needed to build the table of ID attributes used to generate access methods.


Field Summary
private  boolean createdDocType
          Flag to indicate that getCreateDocType() has been called.
private  java.lang.String docPublicId
           
private  java.lang.String docSystemId
           
private  org.w3c.dom.DocumentType docType
          DocumentType object, null until created.
private  java.lang.String docTypeName
          Information needed to build DocumentType.
private  XMLCDomFactory domFactory
          Factory for creating the document.
private  java.util.HashMap elementIdAttrs
          Table of element to id attribute name mappings.
private  java.lang.String internalSubsetStr
           
 
Constructor Summary
DocTypeBuilder(XMLCDomFactory domFactory)
          Constructor.
 
Method Summary
 void addAttributeDecl(java.lang.String elementName, java.lang.String attrName, java.lang.String attrType, java.lang.String attrEnum, java.lang.String defaultDecl, boolean internalSubset)
          Add an attribute declaration.
 void addElementDecl(java.lang.String name, java.lang.String contentSpec, boolean internalSubset)
          Add a document type declaration.
 void addEntityReference(java.lang.String name, boolean internalSubset)
          Add an EntityReference object.
 void addExternalEntityDecl(java.lang.String name, java.lang.String systemId, java.lang.String publicId, boolean paramEntity, boolean internalSubset)
          Add an external entity.
 void addIdAttribute(java.lang.String elementName, java.lang.String attributeName, boolean internalSubset)
          Define an element id attribute.
 void addInternalEntityDecl(java.lang.String name, java.lang.String entityValue, boolean paramEntity, boolean internalSubset)
          Add an internal entity.
 void addNotationDecl(java.lang.String name, java.lang.String systemId, java.lang.String publicId, boolean internalSubset)
          Add a notation.
 void addUnparsedEntityDecl(java.lang.String name, java.lang.String notationName, boolean internalSubset)
          Add an unparsed entity.
private  void checkIfAlreadyCreated()
          Generate an error if the doc type has been created, indicating a bug in the code using this class.
 org.w3c.dom.DocumentType getCreateDocType()
          Get the document type object, creating if necessary.
 java.lang.String getDocumentTypeName()
          Get the document type name (rootElement).
 java.lang.String getIdAttribute(java.lang.String elementName)
          Get the id attribute name for an element.
 java.lang.String getInternalSubset()
          Get the internal subset as a single string.
 java.lang.String getPublicId()
          Get the publicId.
 java.lang.String getSystemId()
          Get the systemId.
 void setDocumentTypeName(java.lang.String name)
          Set the document type name (rootElement).
 void setInternalSubset(java.lang.String subsetStr)
          Add internal subset as a single string.
 void setPublicId(java.lang.String publicId)
          Set the publicId.
 void setSystemId(java.lang.String systemId)
          Set the systemId.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

domFactory

private XMLCDomFactory domFactory
Factory for creating the document.


docType

private org.w3c.dom.DocumentType docType
DocumentType object, null until created.


docTypeName

private java.lang.String docTypeName
Information needed to build DocumentType.


docSystemId

private java.lang.String docSystemId

docPublicId

private java.lang.String docPublicId

internalSubsetStr

private java.lang.String internalSubsetStr

createdDocType

private boolean createdDocType
Flag to indicate that getCreateDocType() has been called. After this call, the attributes of this class can't be changed. A seperate flag is used, as the docType object maybe null.


elementIdAttrs

private java.util.HashMap elementIdAttrs
Table of element to id attribute name mappings.

Constructor Detail

DocTypeBuilder

public DocTypeBuilder(XMLCDomFactory domFactory)
Constructor.

Method Detail

getCreateDocType

public org.w3c.dom.DocumentType getCreateDocType()
Get the document type object, creating if necessary. Once created, no modifications can be made to this object. If setDocumentTypeName() has not been called, null is return. This is the cause when a document doesn't have a DTD.


checkIfAlreadyCreated

private void checkIfAlreadyCreated()
Generate an error if the doc type has been created, indicating a bug in the code using this class.


setDocumentTypeName

public void setDocumentTypeName(java.lang.String name)
Set the document type name (rootElement).


getDocumentTypeName

public java.lang.String getDocumentTypeName()
Get the document type name (rootElement).


setPublicId

public void setPublicId(java.lang.String publicId)
Set the publicId.


getPublicId

public java.lang.String getPublicId()
Get the publicId.


setSystemId

public void setSystemId(java.lang.String systemId)
Set the systemId.


getSystemId

public java.lang.String getSystemId()
Get the systemId.


addIdAttribute

public void addIdAttribute(java.lang.String elementName,
                           java.lang.String attributeName,
                           boolean internalSubset)
Define an element id attribute.


getIdAttribute

public java.lang.String getIdAttribute(java.lang.String elementName)
Get the id attribute name for an element. XML only allows one id attribute per element type.


addEntityReference

public void addEntityReference(java.lang.String name,
                               boolean internalSubset)
Add an EntityReference object.


addElementDecl

public void addElementDecl(java.lang.String name,
                           java.lang.String contentSpec,
                           boolean internalSubset)
Add a document type declaration.


addAttributeDecl

public void addAttributeDecl(java.lang.String elementName,
                             java.lang.String attrName,
                             java.lang.String attrType,
                             java.lang.String attrEnum,
                             java.lang.String defaultDecl,
                             boolean internalSubset)
Add an attribute declaration.


addInternalEntityDecl

public void addInternalEntityDecl(java.lang.String name,
                                  java.lang.String entityValue,
                                  boolean paramEntity,
                                  boolean internalSubset)
Add an internal entity.


addExternalEntityDecl

public void addExternalEntityDecl(java.lang.String name,
                                  java.lang.String systemId,
                                  java.lang.String publicId,
                                  boolean paramEntity,
                                  boolean internalSubset)
Add an external entity.


addUnparsedEntityDecl

public void addUnparsedEntityDecl(java.lang.String name,
                                  java.lang.String notationName,
                                  boolean internalSubset)
Add an unparsed entity.


addNotationDecl

public void addNotationDecl(java.lang.String name,
                            java.lang.String systemId,
                            java.lang.String publicId,
                            boolean internalSubset)
Add a notation.


setInternalSubset

public void setInternalSubset(java.lang.String subsetStr)
Add internal subset as a single string.


getInternalSubset

public java.lang.String getInternalSubset()
Get the internal subset as a single string.