|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.xoetrope.xui.data.XModel
net.xoetrope.optional.data.pojo.XPojoModel
public class XPojoModel
A model node for interacting with POJOs
Copyright (c) Xoetrope Ltd., 2001-2006
License: see license.txt
| Field Summary | |
|---|---|
protected XPojoAdapter |
adapter
|
protected XPojoModel[] |
collectionElements
|
protected XPojoDataSource |
dataSource
|
protected boolean |
dirty
|
protected int |
elIdx
|
protected java.lang.reflect.Method |
getter
|
protected java.lang.Object[] |
getterArgValues
|
protected java.lang.Object |
pojo
|
protected java.util.Hashtable |
properties
|
protected java.lang.String |
propertyName
|
protected java.lang.reflect.Method |
setter
|
| Fields inherited from class net.xoetrope.xui.data.XModel |
|---|
parentModel, tagName |
| Constructor Summary | |
|---|---|
protected |
XPojoModel(XModel parent,
java.lang.Object p,
XPojoDataSource ds)
Creates a new instance of XPojoModel |
protected |
XPojoModel(XModel parent,
java.lang.String subPath,
XPojoDataSource ds)
Creates a new instance of XPojoModel |
| Method Summary | |
|---|---|
java.lang.Object |
append(java.lang.String elementName)
Append a new node with the specified name. |
void |
append(XModel childNode)
Append a node |
void |
clear()
Removes all POJOs from the tree the root of which is this model node |
void |
copyTo(XPojoModel target)
Copies the underlying pojo to the specified target model |
protected java.lang.Object |
executeGetter(XPojoModel childNode)
Executes the getter method of the given model node and returns the value returned by it. |
protected void |
executeSetter(XPojoModel childNode,
java.lang.Object value)
Executes the setter method of the given model node |
java.lang.Object |
get()
Gets the value of this model node |
XModel |
get(int i)
Get the XModel at element i |
java.lang.Object |
get(java.lang.String element)
Get the value of the element located at the path in the element parameter. |
java.lang.String |
getAttribName(int i)
Retrieve the name of the attribute at the specified index |
int |
getAttribute(java.lang.String attribName)
Returns the index of the attribiteNames array whose value is the same as the attribName |
java.lang.Object |
getAttribValue(int i)
Retrieve the value of the attribute at the specified index and return it. |
double |
getAttribValueAsDouble(int i)
Deprecated. use getAttribValueAsDouble( i, 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. |
double |
getAttribValueAsDouble(int i,
char decimalSeparator,
char groupingSeparator)
Convert the attribute at the specified index to a double and return it |
int |
getAttribValueAsInt(int i)
Retrieve the value of the attribute at the specified index, convert it to an int and return it. |
java.lang.String |
getAttribValueAsString(int i)
Retrieve the value of the attribute at the specified index, convert it to a String and return it. |
protected XPojoModel[] |
getCollectionElements()
Gets the table containing pojo collection elements |
XPojoDataSource |
getDataSource()
Gets the data source object |
protected int |
getElIdx()
Gets the collection's position at which the pojo of this model node is located |
protected java.lang.reflect.Method |
getGetter()
Returns the getter method that should be used to obtain a pojo of this model node. |
protected java.lang.Object[] |
getGetterArguments()
Gets the argument values of the getter method associated with this model node |
java.lang.String |
getId()
Gets the value of the ID attribute |
int |
getNumAttributes()
Gets the number of attributes of this node |
int |
getNumChildren()
Gets the number of immediate children of this node |
protected java.lang.Object |
getPojo()
Gets the underlying POJO |
protected java.lang.String |
getPropertyName()
Gets the property name of this model node |
protected java.lang.Object |
getPropertyValue(XPojoModel childNode)
Gets the value of the specified property |
protected java.lang.reflect.Method |
getSetter()
Returns the setter method which should be used to set this model node's pojo |
double |
getValueAsDouble(java.lang.String elementName)
Retrieve the named child, convert it's value to a double and return it. |
int |
getValueAsInt(java.lang.String elementName)
Retrieve the named child, convert it's value to an int and return it. |
java.lang.String |
getValueAsString(java.lang.String elementName)
Retrieve the named child, convert it's value to a String and return it. |
void |
hasAutoId(boolean b)
Used for elements which need a name assigned temporarily because one doesn't exist in the DataSource. |
int |
hashCode()
The hashcode of this instance. |
protected boolean |
hasTransientAncestestor()
Tests whether the property wrapped by this node has a transient ancestor in the pojo property tree |
boolean |
isCollection()
Tests whether the underlying pojo is an instance of Collection |
boolean |
isDirty()
Gets the dirty flag of this node. |
protected boolean |
isPropertyTransient(java.lang.String propertyName)
Tests whether the specified property of this model node is transient. |
boolean |
isTransient()
Tests whether the property wrapped by this model node is transient. |
protected void |
markSubtreeAsDirty()
Marks the children of this node as dirty. |
protected XPojoModel |
retrieveModelNode(java.lang.String subPath)
Gets the previously created model node located at the specified subpath. |
protected void |
saveModelNode(java.lang.String subPath,
XPojoModel model)
Stores the specified model node |
void |
set(java.lang.Object value)
Sets the model value |
void |
set(java.lang.String elementName,
java.lang.Object newObject)
Set the named attribute value of this XModel node. |
void |
setAttribValue(int i,
java.lang.Object value)
Sets the attribute value |
void |
setAttribValue(int i,
java.lang.String attribName,
java.lang.Object value)
Sets the attribute name and value |
void |
setDirty(boolean isDirty)
Sets the dirty state of this node. |
protected void |
setGetter(java.lang.reflect.Method gtr)
Sets the getter method which should be used to obtain this model node's pojo |
void |
setId(java.lang.String newId)
Sets the ID attribute |
void |
setNumChildren(int num)
Set the number of children of this node |
protected void |
setPojo(java.lang.Object newPojo)
Sets the new pojo of this model |
protected void |
setPropertyValue(XPojoModel childNode,
java.lang.Object value)
Sets the pojo of the passed XPojoModel object |
protected void |
setSetter(java.lang.reflect.Method str)
Sets the setter method which should be used to set this model node's pojo |
protected void |
sync()
Syncs the underlying pojo |
| Methods inherited from class net.xoetrope.xui.data.XModel |
|---|
addModelListener, fireModelUpdated, getParent, getTagName, hasAutoId, prefixOutputPath, removeChildren, reset, resetAttributes, setNumAttributes, setParent, setTagName |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected XPojoAdapter adapter
protected XPojoDataSource dataSource
protected java.lang.String propertyName
protected java.lang.reflect.Method getter
protected java.lang.reflect.Method setter
protected java.lang.Object[] getterArgValues
protected int elIdx
protected java.lang.Object pojo
protected XPojoModel[] collectionElements
protected java.util.Hashtable properties
protected boolean dirty
| Constructor Detail |
|---|
protected XPojoModel(XModel parent,
java.lang.String subPath,
XPojoDataSource ds)
parent - the parent model nodesubPath - String in the format:
propertyName(property arguments)[collection idx]
protected XPojoModel(XModel parent,
java.lang.Object p,
XPojoDataSource ds)
XPojoModel
parent - the parent model nodep - the root pojods - the data source object| Method Detail |
|---|
protected void setPojo(java.lang.Object newPojo)
newPojo - the new pojopublic XPojoDataSource getDataSource()
protected java.lang.reflect.Method getGetter()
protected void setGetter(java.lang.reflect.Method gtr)
gtr - the getter methodprotected java.lang.reflect.Method getSetter()
protected void setSetter(java.lang.reflect.Method str)
str - the setter methodprotected java.lang.String getPropertyName()
protected java.lang.Object[] getGetterArguments()
protected int getElIdx()
protected void markSubtreeAsDirty()
public void setDirty(boolean isDirty)
isDirty - the new dirty statepublic boolean isDirty()
protected java.lang.Object getPojo()
protected XPojoModel[] getCollectionElements()
public java.lang.String getId()
getId in class XModelpublic void setId(java.lang.String newId)
setId in class XModelnewId - the new name
public void set(java.lang.String elementName,
java.lang.Object newObject)
set in class XModelelementName - The path to the XModel in the format 'base/foonewObject - The new value of the XModelpublic int getAttribute(java.lang.String attribName)
getAttribute in class XModelattribName - The name of the attribute we are trying to locate
public void setAttribValue(int i,
java.lang.Object value)
setAttribValue in class XModeli - The index of the attributeValues array whose value we wantvalue - the value object
public void setAttribValue(int i,
java.lang.String attribName,
java.lang.Object value)
setAttribValue in class XModeli - The index of the attributeValues array whose value we wantattribName - the name of the attributevalue - the value of the objectprotected void sync()
public XModel get(int i)
get in class XModeli - The index of the values array
public java.lang.Object get()
get in class XModelpublic void copyTo(XPojoModel target)
target - modelprotected boolean isPropertyTransient(java.lang.String propertyName)
propertyName - the name of the property
protected boolean hasTransientAncestestor()
public boolean isTransient()
public boolean isCollection()
protected java.lang.Object getPropertyValue(XPojoModel childNode)
childNode - the model representing property
, the value of which is to be retrieved
protected java.lang.Object executeGetter(XPojoModel childNode)
throws java.lang.Exception
childNode - the model node whose getter is to
be called.
java.lang.Exceptionpublic void set(java.lang.Object value)
set in class XModelvalue - the new valuepublic void clear()
clear in class XModel
protected void setPropertyValue(XPojoModel childNode,
java.lang.Object value)
childNode - model node of the property which
value is to be set.value - the new value of the property
protected void executeSetter(XPojoModel childNode,
java.lang.Object value)
throws java.lang.Exception
childNode - the model node whose getter is to
be calledvalue - the object to be passed as an argument to the setter call
java.lang.Exceptionprotected XPojoModel retrieveModelNode(java.lang.String subPath)
subPath - path to the required model node
protected void saveModelNode(java.lang.String subPath,
XPojoModel model)
subPath - the sub path at wich
the model is locatedmodel - the model node to be savedpublic java.lang.Object get(java.lang.String element)
get in class XModelelement - The path to the XModel required
public void hasAutoId(boolean b)
hasAutoId in class XModelb - true if there was no name in the DataSourcepublic java.lang.String getAttribName(int i)
getAttribName in class XModeli - The index of the attributeNames array whose value we want
public java.lang.String getAttribValueAsString(int i)
getAttribValueAsString in class XModeli - The index of the attributeValues array whose value we want
public java.lang.Object getAttribValue(int i)
getAttribValue in class XModeli - The index of the attributeValues array whose value we want
public double getAttribValueAsDouble(int i)
getAttribValueAsDouble in class XModeli - The index of the attributeValues array whose value we want
public double getAttribValueAsDouble(int i,
char decimalSeparator,
char groupingSeparator)
getAttribValueAsDouble in class XModeli - The index of the attributeValues array whose value we wantdecimalSeparator - the decimal separatorgroupingSeparator - the grouping (thousands) separator
public int getAttribValueAsInt(int i)
getAttribValueAsInt in class XModeli - The index of the attributeValues array whose value we want
public double getValueAsDouble(java.lang.String elementName)
getValueAsDouble in class XModelelementName - The name of the child whose value is required
public int getValueAsInt(java.lang.String elementName)
getValueAsInt in class XModelelementName - The name of the child to be retrieved
public java.lang.String getValueAsString(java.lang.String elementName)
getValueAsString in class XModelelementName - The name of the child whose value is required
public int hashCode()
hashCode in class XModelpublic int getNumChildren()
getNumChildren in class XModelpublic int getNumAttributes()
getNumAttributes in class XModelpublic void setNumChildren(int num)
setNumChildren in class XModelnum - the new number of childrenpublic void append(XModel childNode)
append in class XModelchildNode - the child node to be appendedpublic java.lang.Object append(java.lang.String elementName)
append in class XModelelementName - The immediate path to the XModel required
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||