org.springframework.richclient.command
Class CommandGroupModelBuilder

Show UML class diagram
java.lang.Object
  extended by org.springframework.richclient.command.CommandGroupModelBuilder
Direct Known Subclasses:
CommandGroupJComponentBuilder

public abstract class CommandGroupModelBuilder
extends Object

CommandGroupModelBuilder is a helper class that allows to build Object Models derived from ready command-group structures. These command-group structures are tree-like structures that this class will traverse. Actual building of specific matching object models (often also trees) is done through callbacks to specific buildXXXModel methods. (which are abstract on this generic traversing base-class) Actual use assumes one sublasses and implements those required abstract methods. Internally this class will traverse the commandGroup-structure and offer subclasses the opportunity to build up his matching model matching the command-group nesting by calling the various buildXXXModel methods.


Constructor Summary
CommandGroupModelBuilder()
           
 
Method Summary
protected abstract  Object buildChildModel(Object parentModel, AbstractCommand command, int level)
          Allows the implementation subclass to build a mapping object-model corresponding to a visited leaf node in the command-group structure.
protected abstract  Object buildGroupModel(Object parentModel, CommandGroup commandGroup, int level)
          Allows the implementation subclass to build a mapping object-model corresponding to a visited non-leaf node in the command-group structure.
 Object buildModel(CommandGroup commandGroup)
          Main service method of this method to call.
protected abstract  Object buildRootModel(CommandGroup commandGroup)
          Builds the real root object that will be returned from buildModel(CommandGroup).
protected  boolean continueDeeper(CommandGroup commandGroup, int level)
          Allows the implementation subclass to decide (by overriding) if traversing the structure should continue deeper down.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CommandGroupModelBuilder

public CommandGroupModelBuilder()
Method Detail

buildRootModel

protected abstract Object buildRootModel(CommandGroup commandGroup)
Builds the real root object that will be returned from buildModel(CommandGroup).

Parameters:
commandGroup - at the root of the structure
Returns:
the top level object model to build.

continueDeeper

protected boolean continueDeeper(CommandGroup commandGroup,
                                 int level)
Allows the implementation subclass to decide (by overriding) if traversing the structure should continue deeper down. Implementations can decide based on the current visited commandGroup and the level information. Default implementation at this abstract class level, is to keep on going down the structure. (subclasses should only override when needing to change that.)

Parameters:
commandGroup - currently visited.
level - in the structure we are at ATM
Returns:
true if children of the group should be visted, false if not.

buildChildModel

protected abstract Object buildChildModel(Object parentModel,
                                          AbstractCommand command,
                                          int level)
Allows the implementation subclass to build a mapping object-model corresponding to a visited leaf node in the command-group structure. (Note: for non-leaf nodes the version is called) Since the parentModel is also passed in, the implementation can use it to downcast that and possibly hook up the new client-structure.

Parameters:
parentModel - the objectmodel that was created for the parent-command.
command - currently visited command in the structure.
level - in the structure we are at ATM
Returns:
the top level object model to build.

buildGroupModel

protected abstract Object buildGroupModel(Object parentModel,
                                          CommandGroup commandGroup,
                                          int level)
Allows the implementation subclass to build a mapping object-model corresponding to a visited non-leaf node in the command-group structure. (Note: for leaf nodes the version is called) Since the parentModel is also passed in, this implementation can use it to downcast and decide to hook up the new client-structure. In a same manner the object-structure returned by this method will be passed down in the tree as the parentModel for nested nodes. In general, if an implementation subclass is not building extra stuff for a particular command at a particular level, then it is generally wise to just pass down the parentModel.

Parameters:
parentModel - the objectmodel that was created for the parent-command.
command - currently visited command in the structure.
level - in the structure we are at ATM
Returns:
the top level object model to build.

buildModel

public final Object buildModel(CommandGroup commandGroup)
Main service method of this method to call. This builds the complete mapping object-model by traversing the complete passed in command-group structure by performing the appropriate callbacks to the subclass implementations of buildRootModel(CommandGroup), buildChildModel(Object, AbstractCommand, int), and buildGroupModel(Object, CommandGroup, int). Additionally,

Parameters:
commandGroup - the root of the structure for which an mapping objectmodel will be built.
Returns:
the build object model


Copyright © 2004-2009 The Spring Framework. All Rights Reserved.