com.ibm.portal.state.dom
Interface DocumentModel

All Superinterfaces:
Disposable
All Known Subinterfaces:
DocumentController

public interface DocumentModel
extends Disposable

Read-only version of the document model. You may query topology information of the node hierarchy from this model. Individual nodes may however be shared across document models.

It is important to note that each accessor method in the document model assumes that the node that is passed in as a parameter belongs to this model (e.g. it has either be returned by a query on this model or it has been generated via the document controller). Implementations are not required to check if this contract is satisfied. The retult of an operations and subsequent operations that has been invoked with an invalid node is undefined.

The document model implementation does not need to be thread safe. It is in the responsibility of the caller to ensure that the object is not accessed synchroneously.

The document model should be disposed by calling the dispose() method if it is no longer in use. It is up to the client of this API to decide when this is the case, the implementation does not keep track of pending references.

Since:
5.1

Method Summary
 org.xml.sax.Attributes getAttributes(Node node)
          Return a collection of attributes for a given node.
 java.util.List<Node> getChildren(Node node)
          Returns an immutable list of children for the node.
 Node getParent(Node node)
          Returns the parent for a given node.
 Node getRoot()
          Returns the root node of the document.
 boolean hasAttributes(Node node)
          Performs a quick check if a given node contains attributes.
 boolean hasChildren(Node node)
          Performs a quick check if a given node contains children.
 
Methods inherited from interface com.ibm.portal.Disposable
dispose
 

Method Detail

getAttributes

org.xml.sax.Attributes getAttributes(Node node)
Return a collection of attributes for a given node.

Parameters:
node - Node from this model (must not be null)
Returns:
Map of attributes for this node, an empty map or null.

getRoot

Node getRoot()
Returns the root node of the document. There is alwasy a root node which is immutable.

Returns:
root node (will never be null)

getParent

Node getParent(Node node)
Returns the parent for a given node. It is not necessarily the case that each node from the document has a parent node. In case a node has been removed or created if will be removed from the hierarchy (i.e. does not have a parent) but will still belong the model.

Parameters:
node - Node from this model (must not be null)
Returns:
Parent node or null

getChildren

java.util.List<Node> getChildren(Node node)
Returns an immutable list of children for the node. It is up to the caller of this API to make sure that the list is not modified. The model is free to return a readable or writable list.

Parameters:
node - Node from this model (must not be null)
Returns:
List of children, an empty list or null

hasChildren

boolean hasChildren(Node node)
Performs a quick check if a given node contains children. If this method returns true, a subsequent invocation of getChildren will not return null.

Parameters:
node - Node from this model (must not be null)
Returns:
true if the node contains children, else false

hasAttributes

boolean hasAttributes(Node node)
Performs a quick check if a given node contains attributes. If this method returns true, a subsequent invocation of getAttributes will not return null.

Parameters:
node - Node from this model (must not be null)
Returns:
true if the node contains attributes, else false