Joda System API

org.joda.property
Class JodaUtils

java.lang.Object
  |
  +--org.joda.property.JodaUtils

public class JodaUtils
extends java.lang.Object

JodaUtils groups together useful routines for handling Joda object models

Author:
Stephen Colebourne

Method Summary
static TreeNode createTreeNode(Bean bean)
          Create a TreeNode tree for a bean.
static void resolve(Bean staleBean, Bean updatedBean)
          Resolve an updated Bean into the local, stale, Bean.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

resolve

public static void resolve(Bean staleBean,
                           Bean updatedBean)
Resolve an updated Bean into the local, stale, Bean.

This routine is useful when complex state is held in the client with the server side performing updates. For example, client requests a list of people by surname. The surname returns a list of partially populated Person objects in a ClientSearch bean. The client then selects one of the Person objects in the list and calls the server asking for the full Person details. The Person object returned by the server needs to be reinserted back into the list in the ClientSearch object so that the client state is fully back in sync. This routine does that.

The resolution is based on Beans that implement Identifiable. All the identifiable beans from the updated bean are extracted. The stale bean is then searched for the same references, and the updated version is inserted instead.

The resolution mechanism works at an object level, so any local changes in the stale bean will be lost if a match is found in the updated bean.

Parameters:
staleBean - the locally held bean, that is now stale
updatedBean - the new updated bean to be inserted into the local one

createTreeNode

public static TreeNode createTreeNode(Bean bean)
Create a TreeNode tree for a bean. The tree structure will contain Bean and Property objects as the values of the TreeNode objects. Beans that are the children of another bean are represented as the children of the property within the parent bean.

Infinite recursion is blocked. If a bean occurs a second time, then it's children will not be added.

Parameters:
bean - the bean to get the tree for
Returns:
populated tree node

Joda System API

Copyright © 2001-2003 Stephen Colebourne. All Rights Reserved.