org.javagen.agile.core.util
Class ModelUtil

java.lang.Object
  extended by org.javagen.agile.core.util.ModelUtil

public class ModelUtil
extends Object

Model tree navigation utils.

Author:
Richard Easterling

Constructor Summary
ModelUtil()
           
 
Method Summary
static Model getRootNode(Model currentNode)
           
static void injectPropertiesIntoModelContext(Properties properties, Model model)
          Load properties into Model's context.
static Model lookupChildByName(Model parent, String name, boolean includeSubTrees)
          Calls lookupChildByName with null type.
static Model lookupChildByName(Model parent, String name, Class type, boolean includeSubTrees)
          Lookup child by name.
static Model modelPath(Model currentNode, String path)
          Defines a simple XPath-like language to grab arbitrary model instances out of a model tree.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ModelUtil

public ModelUtil()
Method Detail

getRootNode

public static Model getRootNode(Model currentNode)
Parameters:
currentNode - in model tree
Returns:
root node (ie node with no parent model)

lookupChildByName

public static Model lookupChildByName(Model parent,
                                      String name,
                                      Class type,
                                      boolean includeSubTrees)
Lookup child by name.

Parameters:
parent -
name - case-insensitive model name
type - if specified restricts Model subclass to specified type.
includeSubTrees - if true searches the whole subtree
Returns:

lookupChildByName

public static Model lookupChildByName(Model parent,
                                      String name,
                                      boolean includeSubTrees)
Calls lookupChildByName with null type.


modelPath

public static Model modelPath(Model currentNode,
                              String path)
Defines a simple XPath-like language to grab arbitrary model instances out of a model tree.

Valid paths examples look like this:

Paths starting with '/' are treated as absolute (ie starting with the root node), otherwise they are relative to the provided input argument. Recognized path elements are:

  1. .. - parent node.
  2. key:someName - strips off key: prefix and lookup model with someName in the current context.
  3. id:idName - strips off id: prefix and lookup model someName in the current context.
  4. child:modelName - strips off child: prefix and look for child model with modelName as the model name. The child: prefix is optional.


injectPropertiesIntoModelContext

public static void injectPropertiesIntoModelContext(Properties properties,
                                                    Model model)
Load properties into Model's context.



Copyright 2006-2006-2007 Outsource Cafe Inc.. All Rights Reserved.