org.enhydra.xml.dom
Class DOMAccess

java.lang.Object
  |
  +--org.enhydra.xml.dom.DOMAccess

public final class DOMAccess
extends Object

Method to support accessing the LazyDOM without expanding it. This works both with standard DOMs and LazyDOMs, supporting the development of code that works with either DOM.

Most methods come in two flavors, static ones that take the instance document as an argument, an instance methods that use a document contained in an instance of this object. Great care should be used if the return nodes are to be modified, as read-only template nodes maybe returned. These methods also operate on any W3C DOM.


Constructor Summary
DOMAccess(Document document)
          Create a object to access a specific document.
 
Method Summary
static Attr accessAttribute(Document document, Element element, String namespaceURI, String name)
          Access an attribute of an Element.
 Attr accessAttribute(Element element, String namespaceURI, String name)
          Access an attribute of an Element.
 String accessAttributeValue(Attr attr)
          Access the value of an attribute
static String accessAttributeValue(Document document, Attr attr)
          Access the value of an attribute
 Element accessDocumentElement()
          Access the document element of the document.
static Element accessDocumentElement(Document document)
          Access the document element of a document.
 DocumentType accessDocumentType()
          Access the document type node.
static DocumentType accessDocumentType(Document document)
          Access the document type node.
static Node accessFirstChild(Document document, Node parent)
          Access the first child of a node.
 Node accessFirstChild(Node parent)
          Access the first child of a node.
static Node accessNextSibling(Document document, Node node)
          Access the next sibling of a node.
 Node accessNextSibling(Node node)
          Access the next sibling of a node.
static Element getExpandedElement(Document document, Element element)
          If an Element node is a LazyDOM template, expand it.
 Element getExpandedElement(Element element)
          If an Element node is a LazyDOM template, expand it This is a special case of getExpandedNode().
static Node getExpandedNode(Document document, Node node)
          If a Node is a LazyDOM template node, expand it.
 Node getExpandedNode(Node node)
          If a Node is a LazyDOM template node, expand it.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DOMAccess

public DOMAccess(Document document)
Create a object to access a specific document.
Parameters:
document - The document to access. if this is a LazyDOM instance document, access will switch between the instance and template as appropriate.
Method Detail

accessDocumentType

public static DocumentType accessDocumentType(Document document)
Access the document type node.
Parameters:
document - The instance document object.
Returns:
The document type object, or null if there is none.

accessDocumentType

public DocumentType accessDocumentType()
Access the document type node.
Returns:
The document type object, or null if there is none.

accessFirstChild

public static Node accessFirstChild(Document document,
                                    Node parent)
Access the first child of a node.
Parameters:
document - The instance document object.
parent - The parent node of the desired child.
Returns:
The first child or null if there is none.

accessFirstChild

public Node accessFirstChild(Node parent)
Access the first child of a node.
Parameters:
parent - The parent node of the desired child.
Returns:
The first child or null if there is none.

accessNextSibling

public static Node accessNextSibling(Document document,
                                     Node node)
Access the next sibling of a node.
Parameters:
document - The instance document object.
node - Get the next sibling of this node
Returns:
The first child or null if there is none.

accessNextSibling

public Node accessNextSibling(Node node)
Access the next sibling of a node.
Parameters:
node - Get the next sibling of this node
Returns:
The first child or null if there is none.

accessDocumentElement

public static Element accessDocumentElement(Document document)
Access the document element of a document.
Parameters:
document - The instance document object.
Returns:
The document element.

accessDocumentElement

public Element accessDocumentElement()
Access the document element of the document.
Returns:
The document element.

accessAttribute

public static Attr accessAttribute(Document document,
                                   Element element,
                                   String namespaceURI,
                                   String name)
Access an attribute of an Element.
Parameters:
document - The instance document object.
element - The Element node.
namespaceURI - The namespace URI, or null if there is none.
name - The name of the attribute.
Returns:
The attribute node, or null if it does not exist. The value should be accessed via accessAttributeValue().

accessAttribute

public Attr accessAttribute(Element element,
                            String namespaceURI,
                            String name)
Access an attribute of an Element.
Parameters:
element - The Element node.
namespaceURI - The namespace URI, or null if there is none.
name - The name of the attribute.
Returns:
The attribute node, or null if it does not exist. The value should be accessed via accessAttributeValue().

accessAttributeValue

public static String accessAttributeValue(Document document,
                                          Attr attr)
Access the value of an attribute
Parameters:
document - The instance document object.
attr - The Attr node.
Returns:
The value of the attribute, as a string.

accessAttributeValue

public String accessAttributeValue(Attr attr)
Access the value of an attribute
Parameters:
attr - The Attr node.
Returns:
The value of the attribute, as a string.

getExpandedNode

public static Node getExpandedNode(Document document,
                                   Node node)
If a Node is a LazyDOM template node, expand it.
Parameters:
document - The instance document object.
node - A node of the document or it's template.
Returns:
The expanded node, or the node unchanged if it is not a LazyDOM template.

getExpandedNode

public Node getExpandedNode(Node node)
If a Node is a LazyDOM template node, expand it.
Parameters:
node - A node of the document or it's template.
Returns:
The expanded node, or the node unchanged if it is not a LazyDOM template.

getExpandedElement

public static Element getExpandedElement(Document document,
                                         Element element)
If an Element node is a LazyDOM template, expand it. This is a special case of getExpandedNode().
Parameters:
document - The instance document object.
element - An element of the document or it's template.
Returns:
The expanded element, or the element unchanged if it is not a LazyDOM template.

getExpandedElement

public Element getExpandedElement(Element element)
If an Element node is a LazyDOM template, expand it This is a special case of getExpandedNode().
Parameters:
element - An element of the document or template.
Returns:
The expanded element, or the element unchanged if it is not a LazyDOM template.


Copyright © 1999-2002 enhydra.org (Mark Diekhans, David Li, Richard Kunze). All Rights reserved.