|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.formaria.aria.data.DataModel
org.formaria.data.pojo.PojoModel
public class PojoModel
A model node for interacting with POJOs
Copyright (c) Formaria Ltd., 2008
License: see license.txt
| Field Summary | |
|---|---|
protected PojoAdapter |
adapter
|
protected PojoModel[] |
collectionElements
|
protected PojoDataSource |
dataSource
|
protected boolean |
dirty
|
protected int |
elIdx
|
protected java.lang.Class[] |
getterArgTypes
|
protected java.lang.Object[] |
getterArgValues
|
protected java.lang.Object |
pojo
|
protected java.util.Hashtable |
properties
|
protected java.lang.String |
propertyKey
|
protected java.lang.String |
propertyName
|
| Fields inherited from class org.formaria.aria.data.DataModel |
|---|
parentModel, tagName |
| Constructor Summary | |
|---|---|
protected |
PojoModel(DataModel parent,
java.lang.Object p,
PojoDataSource ds)
Creates a new instance of PojoModel |
protected |
PojoModel(DataModel parent,
java.lang.String subPath,
PojoDataSource ds)
Creates a new instance of PojoModel |
| Method Summary | |
|---|---|
void |
append(DataModel childNode)
Append a node |
java.lang.Object |
append(java.lang.String elementName)
Append a new node with the specified name. |
void |
clear()
Removes all POJOs from the tree rooted at this model node. |
java.lang.Object |
get()
Gets the POJO encapsulated in this model node |
DataModel |
get(int i)
Get the DataModel 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 PojoModel[] |
getCollectionElements()
Gets the table containing pojo collection elements |
PojoDataSource |
getDataSource()
Gets the data source object of this POJO model. |
protected int |
getElIdx()
Gets the collection's position at which the pojo of this model node is located |
protected java.lang.Class[] |
getGetterArgTypes()
Gets the argument types of the getter method associated with this model node. |
protected java.lang.Object[] |
getGetterArgValues()
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 |
getPropertyKey()
Gets a String value that is used by the PojoAdapter associated with this node to store accessor methods. |
protected java.lang.String |
getPropertyName()
Gets the property name of this model node |
protected java.lang.Object |
getPropertyValue(PojoModel childNode)
Gets the value of the property represented by the specified model node. |
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. |
boolean |
hasSetter()
Indicates whether the value of the underlying property can be changed by invoking the relevant setter method on the parent object. |
boolean |
isAlwaysDirty()
Is the POJO always treated as dirty? |
boolean |
isCollection()
Tests whether the underlying POJO is an instance of a Collection |
boolean |
isDirty()
Gets the dirty flag of this node. |
boolean |
isTransient()
Tests whether the property wrapped by this model node is transient. |
protected boolean |
isTransient(java.lang.String propertyName)
Tests whether the specified property of this model node is transient. |
protected void |
markSubtreeAsAlwaysDirty(boolean isAlwaysDirty)
Marks the children of this node as dirty. |
protected void |
markSubtreeAsDirty()
Marks the children of this node as dirty. |
protected PojoModel |
retrieveModelNode(java.lang.String subPath)
Gets the previously created model node located at the specified subpath. |
protected void |
saveModelNode(java.lang.String subPath,
PojoModel 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 DataModel node. |
void |
setAlwaysDirty(boolean state)
Set the POJO as always dirty? |
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. |
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 node |
protected void |
setPropertyValue(PojoModel childNode,
java.lang.Object value)
Sets the given POJO of the given PojoModel object by invoking the setter method. |
protected void |
sync()
Synchronizes the underlying pojo by invoking the getter on the parent object. |
| Methods inherited from class org.formaria.aria.data.DataModel |
|---|
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 PojoAdapter adapter
protected PojoDataSource dataSource
protected java.lang.String propertyName
protected java.lang.Object[] getterArgValues
protected java.lang.Class[] getterArgTypes
protected java.lang.String propertyKey
protected int elIdx
protected java.lang.Object pojo
protected PojoModel[] collectionElements
protected java.util.Hashtable properties
protected boolean dirty
| Constructor Detail |
|---|
protected PojoModel(DataModel parent,
java.lang.String subPath,
PojoDataSource ds)
parent - the parent model nodesubPath - String in the format:
propertyName(property arguments)[collection idx]
protected PojoModel(DataModel parent,
java.lang.Object p,
PojoDataSource ds)
PojoModel
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 PojoDataSource getDataSource()
protected java.lang.String getPropertyKey()
protected java.lang.String getPropertyName()
protected java.lang.Object[] getGetterArgValues()
protected java.lang.Class[] getGetterArgTypes()
protected int getElIdx()
protected void markSubtreeAsDirty()
public void setDirty(boolean isDirty)
isDirty - the new dirty statepublic boolean isDirty()
protected java.lang.Object getPojo()
protected PojoModel[] getCollectionElements()
public java.lang.String getId()
getId in class DataModelpublic void setId(java.lang.String newId)
setId in class DataModelnewId - the new name
public void set(java.lang.String elementName,
java.lang.Object newObject)
set in class DataModelelementName - The path to the DataModel in the format 'base/foonewObject - The new value of the DataModelpublic int getAttribute(java.lang.String attribName)
getAttribute in class DataModelattribName - The name of the attribute we are trying to locate
public void setAttribValue(int i,
java.lang.Object value)
setAttribValue in class DataModeli - 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 DataModeli - The index of the attributeValues array whose value we wantattribName - the name of the attributevalue - the value of the objectprotected void sync()
public DataModel get(int i)
get in class DataModeli - The index of the values array
public java.lang.Object get()
get in class DataModelprotected boolean isTransient(java.lang.String propertyName)
propertyName - the name of the property
public boolean isTransient()
public boolean isCollection()
protected java.lang.Object getPropertyValue(PojoModel childNode)
childNode - the model node of the property
whose value is to be retrieved
public void set(java.lang.Object value)
set in class DataModelvalue - the new valuepublic void clear()
clear in class DataModelpublic boolean hasSetter()
protected void setPropertyValue(PojoModel childNode,
java.lang.Object value)
childNode - model node of the property which
value is to be set.value - the new value of the propertyprotected PojoModel retrieveModelNode(java.lang.String subPath)
subPath - path to the requested model node
protected void saveModelNode(java.lang.String subPath,
PojoModel model)
subPath - the path at which
the model will be locatedmodel - the model node to be savedpublic java.lang.Object get(java.lang.String element)
get in class DataModelelement - The path to the DataModel required
public void hasAutoId(boolean b)
hasAutoId in class DataModelb - true if there was no name in the DataSourcepublic java.lang.String getAttribName(int i)
getAttribName in class DataModeli - The index of the attributeNames array whose value we want
public java.lang.String getAttribValueAsString(int i)
getAttribValueAsString in class DataModeli - The index of the attributeValues array whose value we want
public java.lang.Object getAttribValue(int i)
getAttribValue in class DataModeli - The index of the attributeValues array whose value we want
public double getAttribValueAsDouble(int i)
getAttribValueAsDouble in class DataModeli - The index of the attributeValues array whose value we want
public double getAttribValueAsDouble(int i,
char decimalSeparator,
char groupingSeparator)
getAttribValueAsDouble in class DataModeli - 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 DataModeli - The index of the attributeValues array whose value we want
public double getValueAsDouble(java.lang.String elementName)
getValueAsDouble in class DataModelelementName - The name of the child whose value is required
public int getValueAsInt(java.lang.String elementName)
getValueAsInt in class DataModelelementName - The name of the child to be retrieved
public java.lang.String getValueAsString(java.lang.String elementName)
getValueAsString in class DataModelelementName - The name of the child whose value is required
public int hashCode()
hashCode in class DataModelpublic int getNumChildren()
getNumChildren in class DataModelpublic int getNumAttributes()
getNumAttributes in class DataModelpublic void setNumChildren(int num)
setNumChildren in class DataModelnum - the new number of childrenpublic void append(DataModel childNode)
append in class DataModelchildNode - the child node to be appendedpublic java.lang.Object append(java.lang.String elementName)
append in class DataModelelementName - The immediate path to the DataModel required
public boolean isAlwaysDirty()
public void setAlwaysDirty(boolean state)
state - true if the POJO always calls its getterprotected void markSubtreeAsAlwaysDirty(boolean isAlwaysDirty)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||