org.apache.tapestry5.dom
Class Document

java.lang.Object
  extended by org.apache.tapestry5.dom.Node
      extended by org.apache.tapestry5.dom.Document

public final class Document
extends Node

The root node of a DOM.


Field Summary
static String XML_NAMESPACE_URI
          XML Namespace URI.
static String XMLNS_NAMESPACE_URI
          Namespace used exclusively for defining namespaces.
 
Constructor Summary
Document()
          Builds with an instance of DefaultMarkupModel.
Document(MarkupModel model)
           
Document(MarkupModel model, String encoding)
           
 
Method Summary
 CData cdata(String content)
          Adds and returns a new CDATA node.
 Document comment(String text)
          Adds the comment and returns this document for further construction.
 void dtd(String name, String publicId, String systemId)
          Sets the DTD for the document, overriding any prior DTD.
 Element find(String path)
          Finds an element based on a path of element names.
 Document getDocument()
           
 Element getElementById(String id)
          Tries to find an element in this document whose id is specified.
 MarkupModel getMarkupModel()
           
protected  Map<String,String> getNamespaceURIToPrefix()
           
 Element getRootElement()
           
 boolean hasDTD()
          Returns true if the document has an explicit DTD (set via dtd(String, String, String)).
 Element newRootElement(String name)
          Creates the root element for this document, replacing any previous root element.
 Element newRootElement(String namespace, String name)
          Creates a new root element within a namespace.
 Document raw(String text)
          Adds the raw text and returns this document for further construction.
 Text text(String text)
          Adds and returns a new text node (the text node is returned so that Text.write(String) or [@link Text.writef(String, Object[]) may be invoked.
 void toMarkup(Document document, PrintWriter writer, Map<String,String> namespaceURIToPrefix)
          Implemented by each subclass, with the document passed in for efficiency.
 
Methods inherited from class org.apache.tapestry5.dom.Node
getContainer, moveAfter, moveBefore, moveToBottom, moveToTop, remove, toMarkup, toString, wrap
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

XML_NAMESPACE_URI

public static final String XML_NAMESPACE_URI
XML Namespace URI. May be bound to the "xml" but must not be bound to any other prefix.

See Also:
Constant Field Values

XMLNS_NAMESPACE_URI

public static final String XMLNS_NAMESPACE_URI
Namespace used exclusively for defining namespaces.

See Also:
Constant Field Values
Constructor Detail

Document

public Document(MarkupModel model)

Document

public Document(MarkupModel model,
                String encoding)

Document

public Document()
Builds with an instance of DefaultMarkupModel.

Method Detail

getDocument

public Document getDocument()
Overrides:
getDocument in class Node

find

public Element find(String path)
Finds an element based on a path of element names.

Parameters:
path - slash separated series of element names
Returns:
the matching element, or null if not found
See Also:
Element.find(String)

getMarkupModel

public MarkupModel getMarkupModel()

newRootElement

public Element newRootElement(String name)
Creates the root element for this document, replacing any previous root element.


newRootElement

public Element newRootElement(String namespace,
                              String name)
Creates a new root element within a namespace.

Parameters:
namespace - URI of namespace containing the element
name - name of element with namespace
Returns:
the root element

toMarkup

public void toMarkup(Document document,
                     PrintWriter writer,
                     Map<String,String> namespaceURIToPrefix)
Description copied from class: Node
Implemented by each subclass, with the document passed in for efficiency.


getRootElement

public Element getRootElement()

getElementById

public Element getElementById(String id)
Tries to find an element in this document whose id is specified.

Parameters:
id - the value of the id attribute of the element being looked for
Returns:
the element if found. null if not found.

dtd

public void dtd(String name,
                String publicId,
                String systemId)
Sets the DTD for the document, overriding any prior DTD.

Parameters:
name - non-blank name of document type (i.e., "html")
publicId - optional
systemId - optional

hasDTD

public boolean hasDTD()
Returns true if the document has an explicit DTD (set via dtd(String, String, String)).

Since:
5.3

getNamespaceURIToPrefix

protected Map<String,String> getNamespaceURIToPrefix()
Overrides:
getNamespaceURIToPrefix in class Node

comment

public Document comment(String text)
Adds the comment and returns this document for further construction.

Since:
5.1.0.0

raw

public Document raw(String text)
Adds the raw text and returns this document for further construction.

Since:
5.1.0.0

text

public Text text(String text)
Adds and returns a new text node (the text node is returned so that Text.write(String) or [@link Text.writef(String, Object[]) may be invoked.

Parameters:
text - initial text for the node
Returns:
the new Text node

cdata

public CData cdata(String content)
Adds and returns a new CDATA node.

Parameters:
content - the content to be rendered by the node
Returns:
the newly created node


Copyright © 2003-2012 The Apache Software Foundation.