Oracle UIX API Reference
Release 2.1.22.0.0
B12196-01

oracle.cabo.ui.path
Class DeltaTree

java.lang.Object
  |
  +--oracle.cabo.ui.path.DeltaTree

public class DeltaTree
extends java.lang.Object

DeltaTree supports layering differences on top of a UINode tree. Because it does not modify the original tree, modifications can be made to a tree that is being reused multiple times without worrying about thread safety. It also has much lower memory requirements than duplicating an entire tree.

Clients that simply need to hide and show parts of a tree probably do not need a DeltaTree. Instead, they should look at the "rendered" attribute supported by all UIX Component (Marlin) beans; making this attribute databound provides all the advantages of DeltaTree for this simpler case, and requires even less memory and much less indirection for affected nodes.

UINodes in the DeltaTree are located by Path objects. The PathUtils class may help in creating these Paths.

Example:

A page is largely static, but one portion of it must be generated from scratch on each request. Create the rest of the page as normal, but add a dummy node where the dynamic contents will go. Give that node an ID that will let you find it later.
   // Generate the dynamic contents
   UINode dynamicSubtree = _getDynamicSubtree(...);
 
   // Create a DeltaTree around the root of your page
   DeltaTree tree = new DeltaTree(rootBean);

   // Get the path to the stub node (ideally, this path
   // gets generated once and cached)
   Path pathToNode = PathUtils.findPathWithNodeID(rootBean, "stubID");
 
   // Replace that node.
   tree.replaceNode(pathToNode, newSubtree);
  
   // And render the DeltaTree's root instead of the root bean
   tree.getRoot().render(context);
 

See Also:
Path, PathUtils

Constructor Summary
DeltaTree(UINode root)
          Create a DeltaTree for the given root node.
 
Method Summary
 MutableUINode getMutableUINode(RenderingContext context, MutableUINode base, int childIndex)
          Gets a mutable node for an indexed child of a parent node in the DeltaTree.
 MutableUINode getMutableUINode(RenderingContext context, MutableUINode base, java.lang.String childName)
          Gets a mutable node for a named child of a parent node in the DeltaTree.
 MutableUINode getMutableUINode(RenderingContext context, Path path)
          Returns a MutableUINode that corresponds to following the Path from the root node.
 MutableUINode getMutableUINode(RenderingContext context, Path path, MutableUINode base)
          Returns a MutableUINode that corresponds to following the Path from a node in the delta tree.
 MutableUINode getRoot()
          Return the modified root; this does not return the original root node, but the mutated proxy.
 boolean replaceNode(RenderingContext context, Path path, UINode newChild)
          Replaces a node with another UINode, following a path from the root node.
 boolean replaceNode(RenderingContext context, Path path, UINode newChild, MutableUINode base)
          Replaces the node with another UINode, following a path from an arbitrary base node.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DeltaTree

public DeltaTree(UINode root)
Create a DeltaTree for the given root node.
Method Detail

getRoot

public MutableUINode getRoot()
Return the modified root; this does not return the original root node, but the mutated proxy.
Parameters:
return - a MutableUINode proxying the root

getMutableUINode

public MutableUINode getMutableUINode(RenderingContext context,
                                      Path path)
Returns a MutableUINode that corresponds to following the Path from the root node.
Parameters:
path - a path instance
Returns:
a MutableUINode proxying that child, or null if there was no such child

getMutableUINode

public MutableUINode getMutableUINode(RenderingContext context,
                                      Path path,
                                      MutableUINode base)
Returns a MutableUINode that corresponds to following the Path from a node in the delta tree. The base node must have been directly retrieved from the tree; it is an error to use a node from the original tree.
Parameters:
path - a path instance
base - the UINode to start the path from. The node must have been retrieved directly from the tree.
Returns:
a MutableUINode proxying that child, or null if there was no such child

getMutableUINode

public MutableUINode getMutableUINode(RenderingContext context,
                                      MutableUINode base,
                                      java.lang.String childName)
Gets a mutable node for a named child of a parent node in the DeltaTree. The base node must have been directly retrieved from the DeltaTree; it is an error to pass a node from the original tree.
Parameters:
base - the base UINode
childName - the name of the child
return - a MutableUINode proxying that child, or null if there was no such child

getMutableUINode

public MutableUINode getMutableUINode(RenderingContext context,
                                      MutableUINode base,
                                      int childIndex)
Gets a mutable node for an indexed child of a parent node in the DeltaTree. The base node must have been directly retrieved from the DeltaTree; it is an error to pass a node from the original tree.
Parameters:
base - the base UINode
childIndex - the index of the child
return - a MutableUINode proxying that child, or null if there was no such child

replaceNode

public boolean replaceNode(RenderingContext context,
                           Path path,
                           UINode newChild)
Replaces a node with another UINode, following a path from the root node.
Parameters:
path - a path instance
newChild - the new child; if null, the old node at that location will be removed
Returns:
false if the path could not be followed

replaceNode

public boolean replaceNode(RenderingContext context,
                           Path path,
                           UINode newChild,
                           MutableUINode base)
Replaces the node with another UINode, following a path from an arbitrary base node. The base node must have been directly retrieved from the DeltaTree; it is an error to pass a node from the original tree.
Parameters:
path - a path instance
newChild - the new child; if null, the old node at that location will be removed
base - the UINode to start the path from. The node must have been retrieved directly from the DeltaTree.
Returns:
false if the path could not be followed

Oracle UIX API Reference
Release 2.1.22.0.0
B12196-01

Copyright © 2002,2003, Oracle. All Rights Reserved.