net.xoetrope.optional.data.pojo
Class XPojoHelper

java.lang.Object
  extended by net.xoetrope.optional.data.pojo.XPojoHelper

public class XPojoHelper
extends java.lang.Object

A helper for the pojo model nodes

Copyright (c) Xoetrope Ltd., 2001-2007
License: see license.txt


Constructor Summary
XPojoHelper(java.lang.Object model)
          Creates a new instance of XPojoHelper
 
Method Summary
protected static java.lang.Class convertType(java.lang.String typeName)
          Returns Class object whose simple name is in the given String
protected static java.lang.Object convertValue(java.lang.String type, java.lang.String value)
          Converts specified value to the specified type.
 XPojoModel get(java.lang.String path)
          Gets the pojo model at the specified path
protected static java.lang.Class[] getArgumentTypes(java.lang.String propertyMethod)
          Retrieves the argument types from the passed String describing property method( either getter or setter) The describing String must be in the format: method(typeName1, typeName2,...)
protected static java.lang.Object[] getArgumentValues(java.lang.String element)
          Retrieves argument values from the given element.
protected static java.lang.String getElementIndex(java.lang.String element)
          Retrieves index in the collection from the given element.
protected static java.lang.String getMethodName(java.lang.String propertyMethod)
          Retrieves the method name from the passed String describing property method.
protected static java.lang.String getPropertyName(java.lang.String element)
          Retrieves the property name from the given String which must be in the format: property(arg1,arg2)[idx]"
 XPojoModel getRootModel()
          Gets the root of the pojo model
static java.lang.Integer getSignatureKey(java.lang.Class[] types)
          Returns the key for the specified argument types which will be used in the getters/setters hashtable
 boolean isDirty(java.lang.String path)
          Indicates whether specified model node is dirty.
static boolean isSimpleType(java.lang.Class type)
          Determines whether given class is simple type (primitive or primitive wrapper)
static boolean needsAdapter(java.lang.Class type)
          Indicates whether specified class needs an adapter
 XPojoModel set(java.lang.String path, java.lang.Object value)
          Sets the model value for the specified child of the base node
static void setCurrentProject(XProject project)
          Sets the current project.
 void setDirty()
          Marks all nodes of the pojo model tree as dirty.
 void setDirty(java.lang.String path)
          Marks the specified model node and its properties substree as dirty.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XPojoHelper

public XPojoHelper(java.lang.Object model)
Creates a new instance of XPojoHelper

Parameters:
model - the root of the pojo model
Method Detail

setDirty

public void setDirty(java.lang.String path)
Marks the specified model node and its properties substree as dirty.

Parameters:
path - the path to the model node to be marked

setDirty

public void setDirty()
Marks all nodes of the pojo model tree as dirty.


isDirty

public boolean isDirty(java.lang.String path)
Indicates whether specified model node is dirty.

Parameters:
path - the path to the model node to be queried
Returns:
true if the specified node is dirty, false otherwise

getRootModel

public XPojoModel getRootModel()
Gets the root of the pojo model

Returns:
pojo model node

get

public XPojoModel get(java.lang.String path)
Gets the pojo model at the specified path

Parameters:
path - the path to the child node
Returns:
pojo model node

set

public XPojoModel set(java.lang.String path,
                      java.lang.Object value)
Sets the model value for the specified child of the base node

Parameters:
path - the path to the child node
value - the new value
Returns:
XPojoModel node located at the specified path

setCurrentProject

public static void setCurrentProject(XProject project)
Sets the current project.

Parameters:
project - thep project that owns the model being queried

needsAdapter

public static boolean needsAdapter(java.lang.Class type)
Indicates whether specified class needs an adapter

Parameters:
type - the Class to be checked
Returns:
true if the given class needs adapter, false whterwise

isSimpleType

public static boolean isSimpleType(java.lang.Class type)
Determines whether given class is simple type (primitive or primitive wrapper)

Parameters:
type - the class to be checked
Returns:
true if the specified type is simple type, false otherwise

convertValue

protected static java.lang.Object convertValue(java.lang.String type,
                                               java.lang.String value)
Converts specified value to the specified type.

Parameters:
type - the type to which the value is to be converted
value - the value to be converted
Returns:
converted value

convertType

protected static java.lang.Class convertType(java.lang.String typeName)
Returns Class object whose simple name is in the given String

Parameters:
typeName - the simple name of the type

getMethodName

protected static java.lang.String getMethodName(java.lang.String propertyMethod)
Retrieves the method name from the passed String describing property method. The describing String must be in the format: method(typeName1, typeName2, ...)

Parameters:
propertyMethod - String describing property method
Returns:
the name of the method

getArgumentTypes

protected static java.lang.Class[] getArgumentTypes(java.lang.String propertyMethod)
Retrieves the argument types from the passed String describing property method( either getter or setter) The describing String must be in the format: method(typeName1, typeName2,...)

Parameters:
propertyMethod - String describing property method
Returns:
table containing argument types or null if something went wrong (e.g. one of the specified types was incorrect)

getArgumentValues

protected static java.lang.Object[] getArgumentValues(java.lang.String element)
Retrieves argument values from the given element. if there are any (e.g. for the element "finder(String:arg1, String:arg2)" this method will return table containig "arg1" and "arg2" values that have specified types.

Parameters:
element - the binding path element
Returns:
table containing argument values

getElementIndex

protected static java.lang.String getElementIndex(java.lang.String element)
Retrieves index in the collection from the given element. (for the element "finder(arg1,arg2)[0]" this method will return "0" integer.

Parameters:
element - the binding path element
Returns:
index in the collection

getPropertyName

protected static java.lang.String getPropertyName(java.lang.String element)
Retrieves the property name from the given String which must be in the format: property(arg1,arg2)[idx]"

Parameters:
element - the binding path element
Returns:
the property name

getSignatureKey

public static java.lang.Integer getSignatureKey(java.lang.Class[] types)
Returns the key for the specified argument types which will be used in the getters/setters hashtable

Parameters:
argument - types signature
Returns:
key of the given argument types which can be used