|
||||||||||
| 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.xui.data.XBaseModel
public class XBaseModel
The basic implementation of the XModel is handled by this class. Static data is loaded from an XML file pointed to by the startup.properties file by default using an XDataSource. The model is central to XUI 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) Xoetrope Ltd., 1998-2003
License: see license.txt
| Field Summary | |
|---|---|
protected boolean |
addByDefault
If set, paths not found will automatically be allocated |
protected static boolean |
appendByDefault
append XModel 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 XModel[] |
values
array of Object values |
| Fields inherited from class net.xoetrope.xui.data.XModel |
|---|
parentModel, tagName |
| Constructor Summary | |
|---|---|
XBaseModel()
null ctor. |
|
XBaseModel(XModel parent)
Constructs an instance of the model node. |
|
XBaseModel(XModel parent,
java.lang.String id,
java.lang.Object value)
Constructor which sets the id and value attributes and appends this XModel to the parent model. |
|
| Method Summary | |
|---|---|
java.lang.Object |
append(java.lang.String elementName)
Append a new node with the specified name. |
void |
append(XModel childNode)
Appends a node to the model. |
java.lang.Object |
get()
gets the value attribute |
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. |
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 |
XModel |
getModel(java.lang.String elementName)
Gets the value attribute of the specified node as an XModel. |
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(XModel newNode,
int idx)
Insert a node at a specified index in the list of children |
void |
remove(XModel child)
Remove a child node from this XModel 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 XModel 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(XModel nodeA,
XModel nodeB)
Move a child node up or down in the list of children |
| Methods inherited from class net.xoetrope.xui.data.XModel |
|---|
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 XModel[] 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 XBaseModel(XModel parent)
parent - The XModel to which this instance will be appended
public XBaseModel(XModel parent,
java.lang.String id,
java.lang.Object value)
parent - the XModel instance which will be the parent of this instanceid - the id of this instancevalue - the initial value of this instancepublic XBaseModel()
| Method Detail |
|---|
public void insertChildAt(XModel newNode,
int idx)
newNode - the new model nodeidx - the index at which to insert
public void swapNodes(XModel nodeA,
XModel 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 XModelelement - The path to the XModel required
public void set(java.lang.String elementName,
java.lang.Object newObject)
set( newObject )
set in class XModelelementName - The path to the XModel in the format 'base/foonewObject - The new value of the attributepublic int getAttribute(java.lang.String attribName)
getAttribute in class XModelattribName - The name of the attribute we are trying to locate
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 set(java.lang.Object s)
set in class XModels - the new valuepublic void hasAutoId(boolean b)
hasAutoId in class XModelb - true if there was no name in the DataSourcepublic boolean hasAutoId()
hasAutoId in class XModelpublic java.lang.String getId()
getId in class XModelpublic void setId(java.lang.String newName)
setId in class XModelnewName - the new namepublic java.lang.String getAttribName(int i)
getAttribName in class XModeli - The index of the attributeNames 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 java.lang.String getAttribValueAsString(int i)
getAttribValueAsString 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 index)
getAttribValueAsInt in class XModelindex - The index of the attributeValues array whose value we want
public void setAttribValue(int index,
java.lang.Object value)
setAttribValue in class XModelindex - 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 XModelindex - 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 XModelelementName - The name of the element to be retrieved from this instance
public int getValueAsInt(java.lang.String elementName)
getValueAsInt in class XModelelementName - The name of the element to be retrieved from this instance
public java.lang.String getValueAsString(java.lang.String elementName)
getValueAsString in class XModelelementName - The name of the element to be retrieved from this instance
public XModel getModel(java.lang.String elementName)
elementName - The name of the element to be retrieved from this instance
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 java.lang.Object append(java.lang.String elementName)
append in class XModelelementName - The immediate path to the XModel required
public void append(XModel childNode)
append in class XModelchildNode - the child nodepublic void remove(XModel child)
child - the child to be removed.public void removeAttributes()
public void removeChildren()
removeChildren in class XModelpublic 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 XModelnum - 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 | |||||||||