|
|||||||||
| 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.aria.data.BaseModel
public class BaseModel
The basic implementation of the DataModel is handled by this class. Static data is loaded from an XML file pointed to by the startup.properties file by default using an DataSource. The model is central to Aria and allows the UI components to be separated from the data in an abstract fashion. This model element is designed to support static data, text, list and tabular structures.
Copyright (c) Formaria Ltd., 2008
License: see license.txt
| Field Summary | |
|---|---|
protected boolean |
addByDefault
If set, paths not found will automatically be allocated |
protected static boolean |
appendByDefault
append DataModel elements which are not found by default. |
protected java.lang.String[] |
attributeNames
|
protected java.lang.Object[] |
attributeValues
|
static int |
ID_ATTRIBUTE
|
static int |
NUM_FIXED_ATTRIBUTE
|
static int |
VALUE_ATTRIBUTE
|
protected DataModel[] |
values
array of Object values |
| Fields inherited from class org.formaria.aria.data.DataModel |
|---|
parentModel, tagName |
| Constructor Summary | |
|---|---|
BaseModel()
null ctor. |
|
BaseModel(DataModel parent)
Constructs an instance of the model node. |
|
BaseModel(DataModel parent,
java.lang.String id,
java.lang.Object value)
Constructor which sets the id and value attributes and appends this DataModel to the parent model. |
|
| Method Summary | |
|---|---|
void |
append(DataModel childNode)
Appends a node to the model. |
java.lang.Object |
append(java.lang.String elementName)
Append a new node with the specified name. |
void |
appendAttribute(java.lang.String name,
java.lang.Object value)
Append an attribute, creating a new attribute slot if necessary |
java.lang.Object |
get()
gets the value attribute |
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. |
boolean |
getAddByDefault()
Get the flags that determines if attributes are added when queried |
static boolean |
getAppendByDefault()
Get the flags that determines if attributes are added when queried |
static java.lang.String |
getAttribFromPath(java.lang.String path)
Get the attribute from a path e.g. |
java.lang.String |
getAttribName(int i)
Set the name of the attribute located at the specified index |
int |
getAttribute(java.lang.String attribName)
Get the index of the attribiteNames array whose value is the same as the attribName |
java.lang.Object |
getAttribValue(int i)
Retrive the value of the attribute at the specified index |
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 index)
Convert the attribute at the specified index to an int and return it. |
java.lang.String |
getAttribValueAsString(int i)
Convert the attribute at the specified index to a String and return it |
static java.lang.String |
getBaseFromPath(java.lang.String path)
Get the base path from a path e.g. |
boolean |
getChildExists(java.lang.String name)
Check to see if the specified child node exists. |
java.lang.String |
getId()
Gets the name attribute |
DataModel |
getModel(java.lang.String elementName)
Gets the value attribute of the specified node as an DataModel. |
int |
getNumAttributes()
Gets the number of attributes of this node |
int |
getNumChildren()
Gets the number of immediate children of this node |
double |
getValueAsDouble(java.lang.String elementName)
Gets the value attribute as a Double value |
int |
getValueAsInt(java.lang.String elementName)
Gets the value attribute of the specified node as an int. |
java.lang.String |
getValueAsString(java.lang.String elementName)
Gets the value attribute of the specified node as a string. |
boolean |
hasAutoId()
Determine if the element needs a name assigned temporarily because one doesn't exist in the DataSource. |
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. |
void |
insertChildAt(DataModel newNode,
int idx)
Insert a node at a specified index in the list of children |
void |
remove(DataModel child)
Remove a child node from this DataModel instance. |
void |
removeAttributes()
Remove the nodes attributes and attribute names |
void |
removeChild(java.lang.String name)
Remove a child node |
void |
removeChild(java.lang.String name,
java.lang.String value)
Remove a child node |
void |
removeChildren()
Remove the children of this node |
void |
set(java.lang.Object s)
Sets the model value of this node. |
void |
set(java.lang.String elementName,
java.lang.Object newObject)
Set the value of the element in the child DataModel located at the elementName. |
void |
setAddByDefault(boolean state)
Set the flags that determines if attributes are added when queried |
static void |
setAppendByDefault(boolean state)
Set the flags that determines if attributes are added when queried |
void |
setAttribValue(int index,
java.lang.Object value)
Sets the attribute value |
void |
setAttribValue(int index,
java.lang.String attribName,
java.lang.Object value)
Sets the attribute value |
void |
setId(java.lang.String newName)
Sets the name attribute |
void |
setNumAttributes(int num)
Setup the attributeNames and attributeValues arrays. |
void |
setNumChildren(int num)
Set the number of children of this node |
void |
swapNodes(DataModel nodeA,
DataModel nodeB)
Move a child node up or down in the list of children |
| Methods inherited from class org.formaria.aria.data.DataModel |
|---|
addModelListener, clear, fireModelUpdated, getParent, getTagName, prefixOutputPath, reset, resetAttributes, setParent, setTagName |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected DataModel[] values
protected java.lang.Object[] attributeValues
protected java.lang.String[] attributeNames
protected boolean addByDefault
protected static boolean appendByDefault
public static final int VALUE_ATTRIBUTE
public static final int ID_ATTRIBUTE
public static final int NUM_FIXED_ATTRIBUTE
| Constructor Detail |
|---|
public BaseModel(DataModel parent)
parent - The DataModel to which this instance will be appended
public BaseModel(DataModel parent,
java.lang.String id,
java.lang.Object value)
parent - the DataModel instance which will be the parent of this instanceid - the id of this instancevalue - the initial value of this instancepublic BaseModel()
| Method Detail |
|---|
public void insertChildAt(DataModel newNode,
int idx)
newNode - the new model nodeidx - the index at which to insert
public void swapNodes(DataModel nodeA,
DataModel nodeB)
nodeA - the child node to movenodeB - the child node to movepublic boolean getChildExists(java.lang.String name)
name - the name of the child we are looking for
public java.lang.Object get(java.lang.String element)
get in class DataModelelement - The path to the DataModel required
public void set(java.lang.String elementName,
java.lang.Object newObject)
set( newObject )
set in class DataModelelementName - The path to the DataModel in the format 'base/foonewObject - The new value of the attributepublic int getAttribute(java.lang.String attribName)
getAttribute in class DataModelattribName - The name of the attribute we are trying to locate
public DataModel get(int i)
get in class DataModeli - The index of the values array
public java.lang.Object get()
get in class DataModelpublic void set(java.lang.Object s)
set in class DataModels - the new valuepublic void hasAutoId(boolean b)
hasAutoId in class DataModelb - true if there was no name in the DataSourcepublic boolean hasAutoId()
hasAutoId in class DataModelpublic java.lang.String getId()
getId in class DataModelpublic void setId(java.lang.String newName)
setId in class DataModelnewName - the new namepublic java.lang.String getAttribName(int i)
getAttribName in class DataModeli - The index of the attributeNames 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 java.lang.String getAttribValueAsString(int i)
getAttribValueAsString 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 index)
getAttribValueAsInt in class DataModelindex - The index of the attributeValues array whose value we want
public void setAttribValue(int index,
java.lang.Object value)
setAttribValue in class DataModelindex - The index of the attributeValues array whose value we wantvalue - the value object
public void setAttribValue(int index,
java.lang.String attribName,
java.lang.Object value)
setAttribValue in class DataModelindex - The index of the attributeValues array whose value we wantattribName - the name of the attributevalue - the value objectpublic double getValueAsDouble(java.lang.String elementName)
getValueAsDouble in class DataModelelementName - The name of the element to be retrieved from this instance
public int getValueAsInt(java.lang.String elementName)
getValueAsInt in class DataModelelementName - The name of the element to be retrieved from this instance
public java.lang.String getValueAsString(java.lang.String elementName)
getValueAsString in class DataModelelementName - The name of the element to be retrieved from this instance
public DataModel getModel(java.lang.String elementName)
elementName - The name of the element to be retrieved from this instance
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 java.lang.Object append(java.lang.String elementName)
append in class DataModelelementName - The immediate path to the DataModel required
public void append(DataModel childNode)
append in class DataModelchildNode - the child node
public void appendAttribute(java.lang.String name,
java.lang.Object value)
name - the name of the attributevalue - public void remove(DataModel child)
child - the child to be removed.public void removeAttributes()
public void removeChildren()
removeChildren in class DataModelpublic void removeChild(java.lang.String name)
name - the ID or name of the node
public void removeChild(java.lang.String name,
java.lang.String value)
name - the ID or name of the nodevalue - the value of the matching node to removepublic void setNumAttributes(int num)
setNumAttributes in class DataModelnum - The new size of the arraypublic static java.lang.String getAttribFromPath(java.lang.String path)
path - the path to split
public static java.lang.String getBaseFromPath(java.lang.String path)
path - the path to split
public void setAddByDefault(boolean state)
state - true to add an attribute if it is missing, false to return -1
when querying a node attribute with "getAttribute( name )".public boolean getAddByDefault()
public static void setAppendByDefault(boolean state)
state - true to add an attribute if it is missing, false to return -1
when querying a node attribute with "getAttribute( name )".public static boolean getAppendByDefault()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||