|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.formaria.aria.data.ModelHelper
public class ModelHelper
A helper to eliminate some typecasting with the DataModel
Copyright (c) Formaria Ltd., 2008
$Revision: 1.14 $
License: see License.txt
License: see license.txt
| Constructor Summary | |
|---|---|
ModelHelper(java.lang.Object node)
Construct a new helper node |
|
| Method Summary | |
|---|---|
static double |
addModels(java.lang.Object model1,
java.lang.Object model2)
Retrieve the double values of the models and return their sum |
static DataModel |
clone(java.lang.Object src)
Clones the current model node. |
static DataModel |
clone(java.lang.Object src,
boolean cloneSubNodes)
Clones the current model node. |
DataModel |
get()
Do a get on the model and return its value as a model node |
static DataModel |
get(java.lang.Object baseNode)
Do a get on the model and return its value as a model node |
static DataModel |
get(Project project,
java.lang.Object baseNode,
java.lang.String path)
Get the model value for the specificed path and return its value as a model node |
DataModel |
get(java.lang.String path)
Get the model value for the specificed path and return its value as a model node |
static java.lang.String |
getAttrib(java.lang.Object model,
java.lang.String name)
Retrieve the named attribute of the passed model |
static boolean |
getBooleanValue(java.lang.Object model)
Retrieves the value of the passed model and converts it to a boolean |
static boolean |
getBooleanValue(java.lang.Object model,
java.lang.String att)
Retrieves the value of the specified attribute from the passed model and converts it to a boolean |
static double |
getDouble(java.lang.Object model,
java.lang.String path)
Deprecated. use getDoubleValue( model, att, decimalSeparator, groupingSeparator ) instead, if the locale is different from the locale used to write the values to the model, then the parsed value may be incorrect. |
static double |
getDouble(java.lang.Object model,
java.lang.String path,
char decimalSeparator,
char groupingSeparator)
Retrieves the value attribute of the passed model and converts it to a double |
static double |
getDouble(java.lang.Object model,
java.lang.String path,
double defaultValue)
Deprecated. use getDoubleValue( model, att, defaultValue, decimalSeparator, groupingSeparator ) instead, if the locale is different from the locale used to write the values to the model, then the parsed value may be incorrect. |
static double |
getDouble(java.lang.Object model,
java.lang.String path,
double defaultValue,
char decimalSeparator,
char groupingSeparator)
Deprecated. use getDoubleValue( model, att, defaultValue, decimalSeparator, groupingSeparator ) instead, if the locale is different from the locale used to write the values to the model, then the parsed value may be incorrect. |
static double |
getDoubleValue(java.lang.Object model)
Retrieves the value of the passed model and converts it to a double |
static double |
getDoubleValue(java.lang.Object model,
java.lang.String att)
Deprecated. use getDoubleValue( model, att, decimalSeparator, groupingSeparator ) instead, if the locale is different from the locale used to write the values to the model, then the parsed value may be incorrect. |
static double |
getDoubleValue(java.lang.Object model,
java.lang.String att,
char decimalSeparator,
char groupingSeparator)
Retrieves the named attribute of the passed model and converts it to a double |
static double |
getDoubleValue(java.lang.Object model,
java.lang.String att,
double defaultValue)
Deprecated. use getDoubleValue( model, att, defaultValue, decimalSeparator, groupingSeparator ) instead, if the locale is different from the locale used to write the values to the model, then the parsed value may be incorrect. |
static double |
getDoubleValue(java.lang.Object model,
java.lang.String att,
double defaultValue,
char decimalSeparator,
char groupingSeparator)
Deprecated. use getDoubleValue( model, att, defaultValue, decimalSeparator, groupingSeparator ) instead, if the locale is different from the locale used to write the values to the model, then the parsed value may be incorrect. |
static DataModel |
getFirstChild(DataModel model,
java.lang.String value)
Get the first child node that matches the speciofied value |
static DataModel |
getFirstChild(DataModel model,
java.lang.String path,
java.lang.String value)
Get the first child node that matches the speciofied value |
static int |
getInt(java.lang.Object model)
Retrieves the value of the passed model and converts it to an int |
static int |
getInt(java.lang.Object model,
java.lang.String path)
Retrieves the value of the passed model and converts it to an int |
static int |
getInt(java.lang.Object model,
java.lang.String path,
int defaultValue)
Retrieves the value of the passed model and converts it to an int |
static int |
getIntValue(java.lang.Object model)
Retrieves the value of the passed model and converts it to an int |
static int |
getIntValue(java.lang.Object model,
java.lang.String att)
Retrieves the named attribute of the passed model and converts it to an int |
static int |
getIntValue(java.lang.Object model,
java.lang.String att,
int defaultValue)
Retrieves the named attribute of the passed model and converts it to an int. |
static DataModel |
getNextSibling(DataModel modelNode,
boolean wrap)
Get the next sibling node |
static int |
getNodeCount(DataModel root)
Count the number of nodes in the tree whose root is given by the node argument |
static DataModel |
getParent(java.lang.Object model,
int level)
Retrive the parent of the passed model. |
static java.lang.String |
getPath(DataModel node)
Get the complete path for the node back to the root |
static int |
getPositionInModel(java.lang.Object refModel)
Retrieves the passed models position within its parent |
static DataModel |
getPrevSibling(DataModel modelNode,
boolean wrap)
Get the previous sibling node |
static DataModel |
getSibling(boolean forward,
DataModel modelNode,
boolean wrap)
Get the sibling node |
static java.lang.String |
getString(java.lang.Object baseNode,
java.lang.String path)
Get the model value for the specificed path and return its value as a model node |
static java.lang.String |
getString(Project project,
java.lang.Object baseNode,
java.lang.String path)
Get the model value for the specificed path and return its value as a model node |
static java.lang.String |
getString(java.lang.String path)
Get the model value for the specificed path and return its value as a model node |
static java.lang.String |
getTempVar(java.lang.String name)
Retrieve the value of the named node within the 'temp' section of the model |
static java.lang.String |
getValue(java.lang.Object model)
Retrieves the string value of the passed model |
static boolean |
isChildNode(java.lang.Object ref,
java.lang.Object parent)
Determines whether the ref DataModel is a child of the parent DataModel. |
static void |
merge(java.lang.Object mainmodel,
java.lang.Object newmodel)
merge the conents of one model with another. |
static double |
multipyAttribs(java.lang.Object model,
java.lang.String attrib1,
java.lang.String attrib2)
Retrieve the double values of the attributes within the passed model and return their product |
static double |
multipyModels(java.lang.Object model1,
java.lang.Object model2)
Retrieve the double values of the models and return their product |
void |
set(java.lang.Object value)
Set the model value for this node |
static void |
set(Project project,
java.lang.Object baseNode,
java.lang.String path,
java.lang.Object value)
Set the model value for the specificed child of the base node |
void |
set(java.lang.String path,
java.lang.Object value)
Set the model value for the specificed path |
static void |
setAttrib(java.lang.Object model,
java.lang.String name,
java.lang.Object value)
Set the value of the named attribute within the passed model |
static void |
setCurrentProject(Project project)
Set the current project, used for methods that do not provide a project as an argument |
static void |
setTempVar(java.lang.String name,
java.lang.String value)
Set the value of a node in the 'temp' section of the model |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ModelHelper(java.lang.Object node)
node - the model node on which to operate| Method Detail |
|---|
public static DataModel getNextSibling(DataModel modelNode,
boolean wrap)
wrap - true to wrap to the first node if the request node is the last nodemodelNode - the node whose next sibling is requested
public static DataModel getPrevSibling(DataModel modelNode,
boolean wrap)
wrap - true to wrap to the last node if the request node is the first nodemodelNode - the node whose next sibling is requested
public static DataModel getSibling(boolean forward,
DataModel modelNode,
boolean wrap)
forward - true to search in a forward direction (find the next node)wrap - true to wrap to the first/last node if the request node is the last/first nodemodelNode - the node whose next sibling is requested
public static void setCurrentProject(Project project)
project - the project that owns the model being queriedpublic DataModel get()
public DataModel get(java.lang.String path)
path - the path to the child node
public static DataModel get(java.lang.Object baseNode)
baseNode -
public static DataModel get(Project project,
java.lang.Object baseNode,
java.lang.String path)
baseNode - the base node from which to look for the specified pathpath - the path to the child node
public static java.lang.String getString(Project project,
java.lang.Object baseNode,
java.lang.String path)
baseNode - the base node from which to look for the specified pathpath - the path to the child node
public static java.lang.String getString(java.lang.Object baseNode,
java.lang.String path)
baseNode - the base node from which to look for the specified pathpath - the path to the child node
public static java.lang.String getString(java.lang.String path)
baseNode - the base node from which to look for the specified pathpath - the path to the child node
public void set(java.lang.Object value)
value - the new value
public void set(java.lang.String path,
java.lang.Object value)
path - the path to the child nodevalue - the new value
public static void set(Project project,
java.lang.Object baseNode,
java.lang.String path,
java.lang.Object value)
baseNode - the node whose child is being modifiedpath - the path to the child nodevalue - the new valuepublic static DataModel clone(java.lang.Object src)
src - The DataModel to be cloned
public static DataModel clone(java.lang.Object src,
boolean cloneSubNodes)
src - The DataModel to be clonedcloneSubNodes - boolean to indicate whether the child nodes should be
included in the cloning.
public static void merge(java.lang.Object mainmodel,
java.lang.Object newmodel)
mainmodel - The model to which the newmodel content will be mergednewmodel - the model which contains the data to be merge with the mainModel.
public static java.lang.String getAttrib(java.lang.Object model,
java.lang.String name)
model - the model whose attribute is requiredname - the name of the required attribute
public static void setAttrib(java.lang.Object model,
java.lang.String name,
java.lang.Object value)
model - the DataModel whose attribute is to be setname - the name of the attribute which is to be setvalue - the new value of the attribute
public static DataModel getParent(java.lang.Object model,
int level)
model - the model whose parent is requiredlevel - the number of parents to be navigated
public static int getPositionInModel(java.lang.Object refModel)
refModel - the model whose position is required
public static java.lang.String getValue(java.lang.Object model)
model - the model whose value is required
public static double getDouble(java.lang.Object model,
java.lang.String path)
model - the model whose value is requiredpath - the model path for the desired node
public static double getDouble(java.lang.Object model,
java.lang.String path,
char decimalSeparator,
char groupingSeparator)
model - the model whose value is requiredpath - the model path for the desired nodedecimalSeparator - the decimal separatorgroupingSeparator - the grouping (thousands) separator
public static double getDouble(java.lang.Object model,
java.lang.String path,
double defaultValue)
defaultValue - The double value to be returned if there is an
exceptionmodel - the model whose value is requiredpath - the model path for the desired node
public static double getDouble(java.lang.Object model,
java.lang.String path,
double defaultValue,
char decimalSeparator,
char groupingSeparator)
defaultValue - The double value to be returned if there is an
exceptionmodel - the model whose value is requiredpath - the model path for the desired nodedecimalSeparator - the decimal separatorgroupingSeparator - the grouping (thousands) separator
public static double getDoubleValue(java.lang.Object model)
model - the model whose value is required
public static double getDoubleValue(java.lang.Object model,
java.lang.String att)
model - the model whose value is requiredatt - the name of the attribute being requested
public static double getDoubleValue(java.lang.Object model,
java.lang.String att,
char decimalSeparator,
char groupingSeparator)
model - the model whose value is requiredatt - the name of the attribute being requesteddecimalSeparator - the decimal separatorgroupingSeparator - the grouping (thousands) separator
public static double getDoubleValue(java.lang.Object model,
java.lang.String att,
double defaultValue)
defaultValue - The double value to be returned if there is an
exceptionmodel - the model whose value is requiredatt - the name of the attribute being requested
public static double getDoubleValue(java.lang.Object model,
java.lang.String att,
double defaultValue,
char decimalSeparator,
char groupingSeparator)
defaultValue - The double value to be returned if there is an
exceptionmodel - the model whose value is requiredatt - the name of the attribute being requesteddecimalSeparator - the decimal separatorgroupingSeparator - the grouping (thousands) separator
public static int getInt(java.lang.Object model,
java.lang.String path)
model - the model whose value is requiredpath - the model path for the desired node
public static int getInt(java.lang.Object model,
java.lang.String path,
int defaultValue)
model - the model whose value is requiredpath - the model path for the desired node
public static int getInt(java.lang.Object model)
model - the model whose value is required
public static int getIntValue(java.lang.Object model)
model - the model whose value is required
public static int getIntValue(java.lang.Object model,
java.lang.String att)
model - the model whose value is requiredatt - the name of the attribute being requested
public static int getIntValue(java.lang.Object model,
java.lang.String att,
int defaultValue)
defaultValue - The value to be returned if there is a problemmodel - the model whose value is requiredatt - the name of the attribute being requested
public static double addModels(java.lang.Object model1,
java.lang.Object model2)
model1 - model whose value is to be addedmodel2 - model whose value is to be added
public static double multipyModels(java.lang.Object model1,
java.lang.Object model2)
model1 - model whose value is to be multipliedmodel2 - model whose value is to be multiplied
public static double multipyAttribs(java.lang.Object model,
java.lang.String attrib1,
java.lang.String attrib2)
model - model whose value is to be multipliedattrib1 - the name of the attribute to be multipliedattrib2 - the name of the attribute to be multiplied
public static void setTempVar(java.lang.String name,
java.lang.String value)
name - the name of the node to be setvalue - the String value which is to be setpublic static java.lang.String getTempVar(java.lang.String name)
name - the name of the node which is to be retrieved
public static boolean getBooleanValue(java.lang.Object model)
model - the model whose value is required
public static boolean getBooleanValue(java.lang.Object model,
java.lang.String att)
model - the model whose value is requiredatt - the name of the attribute to be converted
public static boolean isChildNode(java.lang.Object ref,
java.lang.Object parent)
ref - the DataModel whose parentage is in questionparent - the DataModel who is making a claim on the child
public static DataModel getFirstChild(DataModel model,
java.lang.String path,
java.lang.String value)
path - the model path for the desired nodevalue - the value of the value attribute
public static DataModel getFirstChild(DataModel model,
java.lang.String value)
value - the value of the value attribute
public static int getNodeCount(DataModel root)
root - the root node
public static java.lang.String getPath(DataModel node)
node -
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||