|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.xoetrope.xui.data.XModel
public abstract class XModel
The XModel is designed to support an MVC like structure. The model allows data to be maintained separately from UI code and separately from the control logic. The model supports an XPath like way of naming nodes and accessing data. The model is hierarchical and therefore a variety of data can be stored including simple scalar values to vectors and arrays. The model can be supplemented by adding custom node types and by using adapters and bindings.
The XModel is one of the main ideas behind XUI and central to providing the
clean separation of the data. The XUI UI components can be abstractly bound
to the model as instances of XModel although the actual nodes may be
implemented by a range of classes representing tables or lists of even more
complex nodes. All the UI component need know the path to the node in the model.
In some cases an adapter is used to simplify access to the data and perhaps
maintain additional information needed by the UI component (e.g. the selected
value in a list).
Copyright (c) Xoetrope Ltd., 1998-2003
License: see license.txt
| Field Summary | |
|---|---|
protected XModel |
parentModel
The parent XModel of this instance. null if this instance has no parent |
protected java.lang.String |
tagName
The tagname to be output for this XModel if it is being persisted to an XML structure |
| Constructor Summary | |
|---|---|
XModel()
|
|
| Method Summary | |
|---|---|
void |
addModelListener(XModelListener listener,
java.lang.String name)
Add a new listener to this model node |
abstract java.lang.Object |
append(java.lang.String elementName)
Append a new node with the specified name. |
abstract void |
append(XModel childNode)
Append a node |
void |
clear()
Return this node to its initial state by removing its children and attributes |
void |
fireModelUpdated()
Notify the listeners that this model node has changed |
abstract java.lang.Object |
get()
gets the value attribute |
abstract 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 If the attribName parameter is not null we get the value of the attributeValues |
abstract java.lang.String |
getAttribName(int i)
Retrieve the name of the attribute at the specified index |
abstract int |
getAttribute(java.lang.String attribName)
returns the index of the attribiteNames array whose value is the same as the attribName |
abstract java.lang.Object |
getAttribValue(int i)
Retrieve the value of the attribute at the specified index and return it. |
abstract 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. |
abstract double |
getAttribValueAsDouble(int i,
char decimalSeparator,
char groupingSeparator)
Convert the attribute at the specified index to a double and return it |
abstract int |
getAttribValueAsInt(int i)
Retrieve the value of the attribute at the specified index, convert it to an int and return it. |
abstract java.lang.String |
getAttribValueAsString(int i)
Retrieve the value of the attribute at the specified index, convert it to a String and return it. |
abstract 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 |
XModel |
getParent()
Retrieve the parent XModel of this XModel instance. |
java.lang.String |
getTagName()
Gets the model element tag name, e.g. |
abstract double |
getValueAsDouble(java.lang.String elementName)
Retrieve the named child, convert it's value to a double and return it. |
abstract int |
getValueAsInt(java.lang.String elementName)
Retrieve the named child, convert it's value to an int and return it. |
abstract java.lang.String |
getValueAsString(java.lang.String elementName)
Retrieve the named child, convert it's value to a String and return it. |
boolean |
hasAutoId()
Determine if there is no id set for this model in the datasource |
void |
hasAutoId(boolean b)
Used for elements which need a name assigned temporarily because one doesn't exist in the DataSource. |
abstract int |
hashCode()
Get a hash code for the node. |
static java.lang.String |
prefixOutputPath(java.lang.String path)
Prefix the output path if the prefix is not already present |
void |
removeChildren()
Remove the children of this node |
XModel |
reset(XProject currentProject)
Reset the whole model, giving a new root node and a new hierarchy 'deprecated since 1.0.3 |
void |
resetAttributes()
Reset the attributes of this node |
abstract void |
set(java.lang.Object s)
Sets the model value |
abstract void |
set(java.lang.String elementName,
java.lang.Object newObject)
Set the named attribute value of this XModel node. |
abstract void |
setAttribValue(int i,
java.lang.Object value)
Sets the attribute value |
abstract void |
setAttribValue(int i,
java.lang.String attribName,
java.lang.Object value)
Sets the attribute name and value |
void |
setId(java.lang.String newId)
Sets the ID attribute |
void |
setNumAttributes(int num)
Setup the attributeNames and attributeValues arrays. |
void |
setNumChildren(int num)
Set the number of children of this node |
void |
setParent(XModel parent)
Set the XModel parent of this instance |
void |
setTagName(java.lang.String name)
Sets the model element tag name, e.g. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected java.lang.String tagName
protected XModel parentModel
| Constructor Detail |
|---|
public XModel()
| Method Detail |
|---|
public XModel reset(XProject currentProject)
public void clear()
public void resetAttributes()
public void removeChildren()
public void setTagName(java.lang.String name)
name - Set the name of the tag which should be set when outputting the XModelpublic java.lang.String getTagName()
public boolean hasAutoId()
public abstract java.lang.String getId()
public void setId(java.lang.String newId)
newId - the new namepublic java.lang.Object get(java.lang.String element)
element - The path to the XModel we require
public XModel getParent()
public void setParent(XModel parent)
parent - The new XModel parent of this instance
public abstract void set(java.lang.String elementName,
java.lang.Object newObject)
elementName - The path to the XModel in the format 'base/foonewObject - The new value of the XModelpublic abstract int getAttribute(java.lang.String attribName)
attribName - The name of the attribute we are trying to locate
public abstract void setAttribValue(int i,
java.lang.Object value)
i - The index of the attributeValues array whose value we wantvalue - the value object
public abstract void setAttribValue(int i,
java.lang.String attribName,
java.lang.Object value)
i - The index of the attributeValues array whose value we wantattribName - the name of the attributevalue - the value objectpublic abstract XModel get(int i)
i - The index of the values array
public abstract java.lang.Object get()
public abstract void set(java.lang.Object s)
s - the new valuepublic void hasAutoId(boolean b)
b - true if there was no name in the DataSourcepublic abstract java.lang.String getAttribName(int i)
i - The index of the attributeNames array whose value we want
public abstract java.lang.String getAttribValueAsString(int i)
i - The index of the attributeValues array whose value we want
public abstract java.lang.Object getAttribValue(int i)
i - The index of the attributeValues array whose value we want
public abstract double getAttribValueAsDouble(int i)
i - The index of the attributeValues array whose value we want
public abstract double getAttribValueAsDouble(int i,
char decimalSeparator,
char groupingSeparator)
i - The index of the attributeValues array whose value we wantdecimalSeparator - the decimal separatorgroupingSeparator - the grouping (thousands) separator
public abstract int getAttribValueAsInt(int i)
i - The index of the attributeValues array whose value we want
public abstract double getValueAsDouble(java.lang.String elementName)
elementName - The name of the child whose value is required
public abstract int getValueAsInt(java.lang.String elementName)
elementName - The name of the child to be retrieved
public abstract java.lang.String getValueAsString(java.lang.String elementName)
elementName - The name of the child whose value is required
public abstract int hashCode()
hashCode in class java.lang.Objectpublic int getNumChildren()
public int getNumAttributes()
public void setNumChildren(int num)
num - the new number of childrenpublic abstract void append(XModel childNode)
childNode - the child nodepublic abstract java.lang.Object append(java.lang.String elementName)
elementName - The immediate path to the XModel required
public void setNumAttributes(int num)
num - The new size of the array
public void addModelListener(XModelListener listener,
java.lang.String name)
listener - the listener objectname - the name of the metod to be invokedpublic void fireModelUpdated()
public static java.lang.String prefixOutputPath(java.lang.String path)
path - The path to which the prefix will be applied
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||