org.apache.crimson.tree
Class Doctype

java.lang.Object
  extended byorg.apache.crimson.tree.NodeBase
      extended byorg.apache.crimson.tree.Doctype
All Implemented Interfaces:
org.w3c.dom.DocumentType, org.w3c.dom.Node, NodeEx, org.w3c.dom.NodeList, XmlWritable

final class Doctype
extends NodeBase
implements org.w3c.dom.DocumentType

Class representing a DTD in DOM Level 1; this class exists purely for editor support, and is of dubious interest otherwise.

Author:
David Brownell

Nested Class Summary
(package private) static class Doctype.EntityNode
           
(package private) static class Doctype.Nodemap
           
(package private) static class Doctype.NotationNode
           
 
Field Summary
private  Doctype.Nodemap entities
           
private  String internalSubset
           
private  String name
           
private  Doctype.Nodemap notations
           
(package private)  XmlDocument ownerDocument
           
private  String publicId
           
(package private)  boolean readonly
           
private  String systemId
           
 
Fields inherited from interface org.w3c.dom.Node
ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE
 
Constructor Summary
(package private) Doctype(String pub, String sys, String subset)
          XXX Obsolete, but keep it for backwards compatibility
(package private) Doctype(String name, String publicId, String systemId, String internalSubset)
          New DOM Level 2 constructor
 
Method Summary
(package private)  void addEntityNode(String name, String value)
          Adds an entity node for an internal parsed entity.
(package private)  void addEntityNode(String name, String pub, String sys, String not)
          Adds an entity node for an external entity, which could be parsed or unparsed.
(package private)  void addNotation(String name, String pub, String sys)
          Adds a notation node.
 org.w3c.dom.Node appendChild(org.w3c.dom.Node newChild)
          DOM: Throws a HIERARCHY_REQUEST_ERR DOMException.
 org.w3c.dom.Node cloneNode(boolean deep)
          Only implement shallow clone for now, which is allowed in DOM Level 2.
 org.w3c.dom.NamedNodeMap getAttributes()
          DOM: returns null.
 org.w3c.dom.NodeList getChildNodes()
          DOM: Returns an object which permits "live" access to all this node's children.
 org.w3c.dom.NamedNodeMap getEntities()
          DOM: Returns the internal, external, and unparsed entities declared in this DTD.
 org.w3c.dom.Node getFirstChild()
          DOM: Returns null.
 int getIndexOf(org.w3c.dom.Node maybeChild)
          Returns the index of the node in the list of children, such that item() will return that child.
 String getInheritedAttribute(String name)
          Returns the value of a given attribute, tracing up through ancestors if needed.
 String getInternalSubset()
          The internal subset as a string.
 String getLanguage()
          Returns the language id (value of xml:lang attribute) applicable to this node, if known.
 org.w3c.dom.Node getLastChild()
          DOM: returns null.
 int getLength()
          DOM: Returns zero.
 String getLocalName()
          DOM2: returns null.
(package private)  String getMessage(String messageId)
           
(package private)  String getMessage(String messageId, Object[] parameters)
           
 String getName()
          DOM: Returns the name declared for the document root node.
 String getNamespaceURI()
          DOM2: returns null.
 org.w3c.dom.Node getNextSibling()
          DOM: Returns the node immediately following this node in a breadth first traversal of the tree, or null if there is no such sibling.
 String getNodeName()
          DOM: Returns the name declared for the document root node.
 short getNodeType()
          DOM: Returns DOCUMENT_TYPE_NODE
 String getNodeValue()
          DOM: Returns null; overridden by subclasses as needed.
 org.w3c.dom.NamedNodeMap getNotations()
          DOM: Returns the notations declared in this DTD.
 org.w3c.dom.Document getOwnerDocument()
          DOM: Returns the document to which this node belongs.
(package private)  ParentNode getParentImpl()
           
 org.w3c.dom.Node getParentNode()
          DOM: Returns the node's parent.
 String getPrefix()
          DOM2: returns null.
 org.w3c.dom.Node getPreviousSibling()
          DOM: Returns the node immediately preceding this node in a breadth first traversal of the tree, or null if there is no such sibling.
 String getPublicId()
          The public identifier of the external subset.
 String getSystemId()
          The system identifier of the external subset.
 boolean hasAttributes()
          Returns whether this node (if it is an element) has any attributes.
 boolean hasChildNodes()
          DOM: Returns false.
 org.w3c.dom.Node insertBefore(org.w3c.dom.Node newChild, org.w3c.dom.Node refChild)
          DOM: Throws a HIERARCHY_REQUEST_ERR DOMException.
 boolean isReadonly()
          Method to allow easy determination of whether a node is read only.
 boolean isSupported(String feature, String version)
          DOM2:
 org.w3c.dom.Node item(int i)
          DOM: Returns null.
 void normalize()
          DOM2: noop.
 org.w3c.dom.Node removeChild(org.w3c.dom.Node oldChild)
          DOM: Throws a HIERARCHY_REQUEST_ERR DOMException.
 org.w3c.dom.Node replaceChild(org.w3c.dom.Node newChild, org.w3c.dom.Node refChild)
          DOM: Throws a HIERARCHY_REQUEST_ERR DOMException.
 void setNodeValue(String value)
          DOM: does nothing; overridden by subclasses as needed.
protected  void setOwnerDocument(XmlDocument doc)
           
(package private)  void setParentNode(ParentNode arg, int index)
           
 void setPrefix(String prefix)
          DOM2: throws DOMException.NAMESPACE_ERR Overridden by subclasses that support namespaces.
(package private)  void setPrintInfo(String pub, String sys, String subset)
           
(package private)  void setReadonly()
          Marks the sets of entities and notations as readonly.
 void setReadonly(boolean deep)
          Sets the node to be readonly; applies recursively to the children of this node if the parameter is true.
 void writeChildrenXml(XmlWriteContext context)
          Does nothing; this type of node has no children.
 void writeXml(XmlWriteContext context)
          Writes out a textual DTD, trusting that any internal subset text is in fact well formed XML.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.w3c.dom.Node
appendChild, getAttributes, getChildNodes, getFirstChild, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getNodeValue, getOwnerDocument, getParentNode, getPrefix, getPreviousSibling, hasAttributes, hasChildNodes, insertBefore, isSupported, normalize, removeChild, replaceChild, setNodeValue, setPrefix
 

Field Detail

name

private String name

entities

private Doctype.Nodemap entities

notations

private Doctype.Nodemap notations

publicId

private String publicId

systemId

private String systemId

internalSubset

private String internalSubset

ownerDocument

XmlDocument ownerDocument

readonly

boolean readonly
Constructor Detail

Doctype

Doctype(String pub,
        String sys,
        String subset)
XXX Obsolete, but keep it for backwards compatibility


Doctype

Doctype(String name,
        String publicId,
        String systemId,
        String internalSubset)
New DOM Level 2 constructor

Method Detail

setPrintInfo

void setPrintInfo(String pub,
                  String sys,
                  String subset)

writeXml

public void writeXml(XmlWriteContext context)
              throws IOException
Writes out a textual DTD, trusting that any internal subset text is in fact well formed XML.

Specified by:
writeXml in interface XmlWritable
Throws:
IOException

getNodeType

public short getNodeType()
DOM: Returns DOCUMENT_TYPE_NODE

Specified by:
getNodeType in interface org.w3c.dom.Node

getName

public String getName()
DOM: Returns the name declared for the document root node.

Specified by:
getName in interface org.w3c.dom.DocumentType

getNodeName

public String getNodeName()
DOM: Returns the name declared for the document root node.

Specified by:
getNodeName in interface org.w3c.dom.Node

cloneNode

public org.w3c.dom.Node cloneNode(boolean deep)
Only implement shallow clone for now, which is allowed in DOM Level 2.

Specified by:
cloneNode in interface org.w3c.dom.Node

getEntities

public org.w3c.dom.NamedNodeMap getEntities()
DOM: Returns the internal, external, and unparsed entities declared in this DTD.

Specified by:
getEntities in interface org.w3c.dom.DocumentType

getNotations

public org.w3c.dom.NamedNodeMap getNotations()
DOM: Returns the notations declared in this DTD.

Specified by:
getNotations in interface org.w3c.dom.DocumentType

getPublicId

public String getPublicId()
The public identifier of the external subset.

Specified by:
getPublicId in interface org.w3c.dom.DocumentType
Since:
DOM Level 2

getSystemId

public String getSystemId()
The system identifier of the external subset.

Specified by:
getSystemId in interface org.w3c.dom.DocumentType
Since:
DOM Level 2

getInternalSubset

public String getInternalSubset()
The internal subset as a string.

Specified by:
getInternalSubset in interface org.w3c.dom.DocumentType
Since:
DOM Level 2

setOwnerDocument

protected void setOwnerDocument(XmlDocument doc)
Overrides:
setOwnerDocument in class NodeBase

addNotation

void addNotation(String name,
                 String pub,
                 String sys)
Adds a notation node.


addEntityNode

void addEntityNode(String name,
                   String pub,
                   String sys,
                   String not)
Adds an entity node for an external entity, which could be parsed or unparsed.


addEntityNode

void addEntityNode(String name,
                   String value)
Adds an entity node for an internal parsed entity.


setReadonly

void setReadonly()
Marks the sets of entities and notations as readonly.


getParentImpl

ParentNode getParentImpl()

isReadonly

public boolean isReadonly()
Description copied from interface: NodeEx
Method to allow easy determination of whether a node is read only.

Specified by:
isReadonly in interface NodeEx
Returns:
true if the node is read only

setReadonly

public void setReadonly(boolean deep)
Description copied from interface: NodeEx
Sets the node to be readonly; applies recursively to the children of this node if the parameter is true.

Specified by:
setReadonly in interface NodeEx
Parameters:
deep - If true recursively set the nodes in the subtree under the current node to be read only. If false then set only the current node to be readonly

getLanguage

public String getLanguage()
Returns the language id (value of xml:lang attribute) applicable to this node, if known. Traces up through ancestors as needed.

Specified by:
getLanguage in interface NodeEx
Returns:
the value of the xml:lang attribute, or null if no such attribute is found.

getInheritedAttribute

public String getInheritedAttribute(String name)
Returns the value of a given attribute, tracing up through ancestors if needed. In the XML standard, two attributes are inherited: xml:lang and xml:space. This mechanism can also be involved with Cascading Style Sheets (CSS). The current version of XML Namespaces also uses inheritance.

Specified by:
getInheritedAttribute in interface NodeEx
Parameters:
name - identifies the attribute; colons may be included, but namespace prefixes are not interpreted
Returns:
the value of the inherited attribute, or null if no value was inherited.

writeChildrenXml

public void writeChildrenXml(XmlWriteContext context)
                      throws IOException
Does nothing; this type of node has no children.

Specified by:
writeChildrenXml in interface XmlWritable
Throws:
IOException

getParentNode

public org.w3c.dom.Node getParentNode()
DOM: Returns the node's parent. This will be null in cases such as newly created or removed nodes, and for attributes, fragments, and documents.

Specified by:
getParentNode in interface org.w3c.dom.Node

setParentNode

void setParentNode(ParentNode arg,
                   int index)
             throws org.w3c.dom.DOMException
Throws:
org.w3c.dom.DOMException

getOwnerDocument

public org.w3c.dom.Document getOwnerDocument()
DOM: Returns the document to which this node belongs.

Specified by:
getOwnerDocument in interface org.w3c.dom.Node

hasChildNodes

public boolean hasChildNodes()
DOM: Returns false. Overridden by subclasses which support children.

Specified by:
hasChildNodes in interface org.w3c.dom.Node

setNodeValue

public void setNodeValue(String value)
DOM: does nothing; overridden by subclasses as needed.

Specified by:
setNodeValue in interface org.w3c.dom.Node

getNodeValue

public String getNodeValue()
DOM: Returns null; overridden by subclasses as needed.

Specified by:
getNodeValue in interface org.w3c.dom.Node

getFirstChild

public org.w3c.dom.Node getFirstChild()
DOM: Returns null. Overridden by subclasses which support children.

Specified by:
getFirstChild in interface org.w3c.dom.Node

getLength

public int getLength()
DOM: Returns zero. Overridden by subclasses which support children.

Specified by:
getLength in interface org.w3c.dom.NodeList

item

public org.w3c.dom.Node item(int i)
DOM: Returns null. Overridden by subclasses which support children.

Specified by:
item in interface org.w3c.dom.NodeList

getChildNodes

public org.w3c.dom.NodeList getChildNodes()
DOM: Returns an object which permits "live" access to all this node's children.

In this implementation, nodes provide such access without needing another node as an intermediary; "this" is returned.

Specified by:
getChildNodes in interface org.w3c.dom.Node

getLastChild

public org.w3c.dom.Node getLastChild()
DOM: returns null. Overridden by subclasses which support children.

Specified by:
getLastChild in interface org.w3c.dom.Node

appendChild

public org.w3c.dom.Node appendChild(org.w3c.dom.Node newChild)
                             throws org.w3c.dom.DOMException
DOM: Throws a HIERARCHY_REQUEST_ERR DOMException. Overridden by subclasses which support children.

Specified by:
appendChild in interface org.w3c.dom.Node
Throws:
org.w3c.dom.DOMException - thrown always.

insertBefore

public org.w3c.dom.Node insertBefore(org.w3c.dom.Node newChild,
                                     org.w3c.dom.Node refChild)
                              throws org.w3c.dom.DOMException
DOM: Throws a HIERARCHY_REQUEST_ERR DOMException. Overridden by subclasses which support children.

Specified by:
insertBefore in interface org.w3c.dom.Node
Throws:
org.w3c.dom.DOMException - thrown always.

replaceChild

public org.w3c.dom.Node replaceChild(org.w3c.dom.Node newChild,
                                     org.w3c.dom.Node refChild)
                              throws org.w3c.dom.DOMException
DOM: Throws a HIERARCHY_REQUEST_ERR DOMException. Overridden by subclasses which support children.

Specified by:
replaceChild in interface org.w3c.dom.Node
Throws:
org.w3c.dom.DOMException - thrown always.

removeChild

public org.w3c.dom.Node removeChild(org.w3c.dom.Node oldChild)
                             throws org.w3c.dom.DOMException
DOM: Throws a HIERARCHY_REQUEST_ERR DOMException. Overridden by subclasses which support children.

Specified by:
removeChild in interface org.w3c.dom.Node
Throws:
org.w3c.dom.DOMException - thrown always.

getNextSibling

public org.w3c.dom.Node getNextSibling()
DOM: Returns the node immediately following this node in a breadth first traversal of the tree, or null if there is no such sibling. In this implementation, sibling access from a node is slower than indexed access from its parent.

Specified by:
getNextSibling in interface org.w3c.dom.Node

getPreviousSibling

public org.w3c.dom.Node getPreviousSibling()
DOM: Returns the node immediately preceding this node in a breadth first traversal of the tree, or null if there is no such sibling. In this implementation, sibling access from a node is slower than indexed access from its parent.

Specified by:
getPreviousSibling in interface org.w3c.dom.Node

getAttributes

public org.w3c.dom.NamedNodeMap getAttributes()
DOM: returns null. Overridden by the ElementNode2 subclass.

Specified by:
getAttributes in interface org.w3c.dom.Node

normalize

public void normalize()
DOM2: noop.

Specified by:
normalize in interface org.w3c.dom.Node
Since:
DOM Level 2 Overridden by subclasses that need to support normalization.

isSupported

public boolean isSupported(String feature,
                           String version)
DOM2:

Specified by:
isSupported in interface org.w3c.dom.Node
Since:
DOM Level 2

getNamespaceURI

public String getNamespaceURI()
DOM2: returns null. Overridden by subclasses that support namespaces, ie. ElementNode2 and AttributeNode.

Specified by:
getNamespaceURI in interface org.w3c.dom.Node

getPrefix

public String getPrefix()
DOM2: returns null. Overridden by subclasses that support namespaces.

Specified by:
getPrefix in interface org.w3c.dom.Node

setPrefix

public void setPrefix(String prefix)
               throws org.w3c.dom.DOMException
DOM2: throws DOMException.NAMESPACE_ERR Overridden by subclasses that support namespaces.

Specified by:
setPrefix in interface org.w3c.dom.Node
Throws:
org.w3c.dom.DOMException

getLocalName

public String getLocalName()
DOM2: returns null. Overridden by subclasses that support namespaces.

Specified by:
getLocalName in interface org.w3c.dom.Node

hasAttributes

public boolean hasAttributes()
Returns whether this node (if it is an element) has any attributes. Overridden by Element implementations

Specified by:
hasAttributes in interface org.w3c.dom.Node
Since:
DOM Level 2

getIndexOf

public int getIndexOf(org.w3c.dom.Node maybeChild)
Description copied from interface: NodeEx
Returns the index of the node in the list of children, such that item() will return that child.

Specified by:
getIndexOf in interface NodeEx
Parameters:
maybeChild - the node which may be a child of this one
Returns:
the index of the node in the set of children, or else -1 if that node is not a child of this node.

getMessage

String getMessage(String messageId)

getMessage

String getMessage(String messageId,
                  Object[] parameters)