Version: 1.1.1

org.biomoby.service.dashboard.data
Class DataTypeNode

java.lang.Object
  extended by org.biomoby.service.dashboard.data.DataTypeNode

public class DataTypeNode
extends Object

A node in a tree representing a Biomoby data type. These nodes are used and managed by DataTypeModel which is then used by DataTypeTreeTable to display and to edit Biomoby input data.

Each DataTypeNode represents a MobyDataType instance and it knows how to create sub-nodes that contain member types of this MobyDataType. It also contains id, namespace, and (for primitive types) a value.

It also provides a table cell renderer and editor - they are used if this DataTypeNode represents a Biomoby primitive type for rendering and editing its value. The renderer and editor are here because they can differ from line to line (they are not the same for the whole table column as it is usual).

If this node represents a Biomoby String primitive type, it provides a boolean cell renderer and editor for a column where a user can specify that - in the resulting XML - the string value should be normally escaped, or wrapped in a CDATA section. Also the user an indicate that the String value can have more lines - in such case a special text area appears to allow it.

Finally, for nodes representing HAS relationship, there are several buttons allowing to add, clone or remove its HAS sibling.

Version:
$Id: DataTypeNode.java,v 1.13 2006/02/20 05:51:10 senger Exp $
Author:
Martin Senger

Method Summary
static DataTypeNode createNode(MobyDataType dataType, String memberName, int memberRel, DataTypeNode parent, HashMap dtTable, DataTypeModel model)
          A factory for a node.
 Object fixValue(Object value)
          If the given value does not correspond with the type of this node (which happens for empty values) change it to more appropriate value.
 TableCellEditor getButtonEditor(int column)
          Return a cell editor for given column, assuming that this column is one of those displaying buttons for adding, cloning and removing HAS siblings.
 TableCellRenderer getButtonRenderer(int column)
          Return a cell renderer for given column, assuming that this column is one of those displaying buttons for adding, cloning and removing HAS siblings.
 TableCellEditor getCDATAEditor(JTable table)
          Return a boolean cell editor for given table.
 Object getCDATAFlag()
          Get flag indicating whether to use a CDATA wrapper for values of String primitive types.
 TableCellRenderer getCDATARenderer(JTable table)
          Return a boolean cell renderer for given table.
 Object getChild(int i)
          Return an i-th child of this node.
 int getChildCount()
          How many children this node has.
 DataTypeNode[] getChildren()
          Return children nodes of this node (after loading them if not yet done).
 MobyDataType getDataType()
          Return a Biomoby data type represented by this node.
 String getId()
          Return an ID assigned to this node.
 String getMemberName()
          Return a member name (article name) assigned to this node.
 String getNamespace()
          Return a namespace assigned to this node.
 DataTypeNode getParentNode()
          Return a parent node.
 Object getValue()
          Return a value stored in this node (makes sense only for Biomoby primitive types).
 TableCellEditor getValueEditor(JTable table)
          Return a cell editor (of column containing the value) for given table.
 TableCellRenderer getValueRenderer(JTable table, Object value)
          Return a cell renderer for given table and for given value.
 boolean isHAS()
          Return true if this node has HAS relationship to its parents.
 boolean isLeaf()
          Return true if this node represents a leaf in a data type tree.
 boolean isPrimitive()
          Return true if this node represents a primitive data type.
 boolean isString()
          Return true if this node represents a String Biomoby primitive type.
 void setCDATAFlag(Object value)
          Set flag indicating whether to use a CDATA wrapper for values of String primitive types.
 void setId(String newValue)
          Assign an ID to this node.
 void setNamespace(String newValue)
          Assign a namespace to this node.
 void setValue(Object newValue)
          Assign a new value to this node (makes sense only for Biomoby primitive types).
 String toString()
           
 org.jdom.Element toXML()
          Create an XML element representing this node.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

toString

public String toString()
Overrides:
toString in class Object

toXML

public org.jdom.Element toXML()
Create an XML element representing this node. This is similar what is done for org.biomoby.shared.datatypes.MobyObject - but without provision and cross references.

Returns:
a jDom element that can be easily incorporated into a bigger XML document. Return null if this is a Biomoby primitive type and its value is empty.

isLeaf

public boolean isLeaf()
Return true if this node represents a leaf in a data type tree.


isPrimitive

public boolean isPrimitive()
Return true if this node represents a primitive data type.


isString

public boolean isString()
Return true if this node represents a String Biomoby primitive type.


isHAS

public boolean isHAS()
Return true if this node has HAS relationship to its parents.


getParentNode

public DataTypeNode getParentNode()
Return a parent node.


getDataType

public MobyDataType getDataType()
Return a Biomoby data type represented by this node.


getId

public String getId()
Return an ID assigned to this node.


setId

public void setId(String newValue)
Assign an ID to this node.


getNamespace

public String getNamespace()
Return a namespace assigned to this node.


setNamespace

public void setNamespace(String newValue)
Assign a namespace to this node.


getMemberName

public String getMemberName()
Return a member name (article name) assigned to this node.


getValue

public Object getValue()
Return a value stored in this node (makes sense only for Biomoby primitive types).


setValue

public void setValue(Object newValue)
Assign a new value to this node (makes sense only for Biomoby primitive types).


getValueRenderer

public TableCellRenderer getValueRenderer(JTable table,
                                          Object value)
Return a cell renderer for given table and for given value. The value is here because for some node types there will be a different renderers for an empty and non-empty values.


getValueEditor

public TableCellEditor getValueEditor(JTable table)
Return a cell editor (of column containing the value) for given table.


fixValue

public Object fixValue(Object value)
If the given value does not correspond with the type of this node (which happens for empty values) change it to more appropriate value.


setCDATAFlag

public void setCDATAFlag(Object value)
Set flag indicating whether to use a CDATA wrapper for values of String primitive types.


getCDATAFlag

public Object getCDATAFlag()
Get flag indicating whether to use a CDATA wrapper for values of String primitive types.


getCDATARenderer

public TableCellRenderer getCDATARenderer(JTable table)
Return a boolean cell renderer for given table. It is used (for String primitive type only) to indicate wrapping into a CDATA section in the resulting XML.


getCDATAEditor

public TableCellEditor getCDATAEditor(JTable table)
Return a boolean cell editor for given table. It is used (for String primitive type only) to indicate wrapping into a CDATA section in the resulting XML.


getButtonRenderer

public TableCellRenderer getButtonRenderer(int column)
Return a cell renderer for given column, assuming that this column is one of those displaying buttons for adding, cloning and removing HAS siblings.


getButtonEditor

public TableCellEditor getButtonEditor(int column)
Return a cell editor for given column, assuming that this column is one of those displaying buttons for adding, cloning and removing HAS siblings.


createNode

public static DataTypeNode createNode(MobyDataType dataType,
                                      String memberName,
                                      int memberRel,
                                      DataTypeNode parent,
                                      HashMap dtTable,
                                      DataTypeModel model)
A factory for a node.

Parameters:
dataType - represented by this node
memberName - how this data type is named (article name) in its parent
memberRel - how this node is related to its parent (should be Central.iHAS or Central.iHASA or -1 (if it does not have any parent)
parent - data type
dtTable - contains all other data types (so we can find our children)
model - that drives the tree-table where this node sits in

getChildCount

public int getChildCount()
How many children this node has.


getChild

public Object getChild(int i)
Return an i-th child of this node.


getChildren

public DataTypeNode[] getChildren()
Return children nodes of this node (after loading them if not yet done).


Version: 1.1.1

Submit a bug or feature
Generated: Sat May 29 04:26:35 EDT 2010