javax.rad.model
Class RowDefinition

java.lang.Object
  extended by javax.rad.model.RowDefinition
All Implemented Interfaces:
Serializable, Cloneable, IRowDefinition

public class RowDefinition
extends Object
implements IRowDefinition, Serializable

A RowDefinition contains all ColumnDefintion's of a DataRow.

Example:

 
 // construct a RowDefinition
 RowDefinition rdRowDefinition = new RowDefinition();
 
 // construct some ColumnDefinitions
 ColumnDefinition cdId   = new ColumnDefinition("id");
 ColumnDefinition cdName = new ColumnDefinition("name");
 
 rdRowDefinition.addColumnDefinition(cdId);             
 rdRowDefinition.addColumnDefinition(cdName);
 
 

See Also:
IRowDefinition, ColumnDefinition, Serialized Form

Constructor Summary
RowDefinition()
           
 
Method Summary
 void addColumnDefinition(ColumnDefinition pColumnDefinition)
          Adds an ColumnDefinition to this IRowDefinition.
 void addControl(IControl pControl)
          Adds a IControl to the IRowDefinition.
 void addDataBook(IDataBook rowDefinitionListener)
          It register and adds a IDataBook to this IRowDefinition, which uses this IRowDefintion.
 IRowDefinition createRowDefinition(String[] pColumnNames)
          Returns a cloned IRowDefinition with only a subset of ColumnDefinitions, specified by a column name String[].
 int getColumnCount()
          Returns the column count of this IRowDefintion.
 ColumnDefinition getColumnDefinition(int pColumnIndex)
          Returns the ColumnDefinition by index.
 ColumnDefinition getColumnDefinition(String pColumnName)
          Returns the ColumnDefinition by name.
 int getColumnDefinitionIndex(String pColumnName)
          Returns the index of the ColumnDefinition name of this IRowDefinition.
 String[] getColumnNames()
          Returns the String[] of all column names in this IRowDefintion.
 ColumnView getColumnView(Class<? extends IControl> pTargetControl)
          Gets the ColumnView to use for GUI controls.
 Class<? extends IControl>[] getColumnViewClasses()
          Gets the classes for which ColumnViews are set.
 IControl[] getControls()
          Returns all IControl's from the IRowDefinition.
 IDataBook[] getDataBooks()
          It returns the list of IDataBooks corresponding to this IRowDefintion.
 ColumnView getDefaultColumnView()
          Returns the default table columns names.
static String[] getDefaultIgnoredColumnNames()
          Gets the list of columns which are not included in the table columns when no specific table columns are set.
 ReferenceDefinition getLinkReference(String pColumnName)
          Gets the link reference of the column name.
 String[] getLinkReferenceColumnNames(String pColumnName)
          Gets all columns with a LinkReference including pColumnName.
 ReferenceDefinition getMasterReference()
          Gets the master reference.
 String[] getPrimaryKeyColumnNames()
          Returns the String[] of all column names in the primary key.
 String[] getReadOnly()
          Returns all read only (true) column names.
static boolean isColumnIgnored(String pColumnName)
          Gets whether a column name is ignored through the default ignored column names.
 boolean isMasterLinkColumn(String pColumnName)
          Gets true, if the column is a LinkReferenceColumn for the MasterReference definition.
 void removeControl(IControl pControl)
          Removes the IControl from the IRowDefinition.
 void removeDataBook(IDataBook rowDefinitionListener)
          It removes the DataBook reference to this IRowDefinition, which used this IRowDefintion before.
 void setColumnView(Class<? extends IControl> pTargetControl, ColumnView pColumnView)
          Sets the column view to use for GUI controls.
static void setDefaultIgnoredColumnNames(String... pColumnNames)
          Sets a list of columns which are excluded from the table columns when no specific table columns are set.
 void setPrimaryKeyColumnNames(String[] pColumnNames)
          Sets all primary key column names.
 void setReadOnly(String[] pColumnNames)
          Sets the specified column names as read only true.
 String toString()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RowDefinition

public RowDefinition()
Method Detail

addDataBook

public void addDataBook(IDataBook rowDefinitionListener)
                 throws ModelException
It register and adds a IDataBook to this IRowDefinition, which uses this IRowDefintion. The IDataBook implementations has to remove their self in the close() method.

Specified by:
addDataBook in interface IRowDefinition
Parameters:
rowDefinitionListener - the IDataBook to add
Throws:
ModelException - if the xxxColumnsName (eg.xxx=Table) are not existing in the IRowDefinition.

removeDataBook

public void removeDataBook(IDataBook rowDefinitionListener)
It removes the DataBook reference to this IRowDefinition, which used this IRowDefintion before. The IDataBook implementations has to remove their self in the close() method.

Specified by:
removeDataBook in interface IRowDefinition
Parameters:
rowDefinitionListener - the IDataBook to remove

getDataBooks

public IDataBook[] getDataBooks()
It returns the list of IDataBooks corresponding to this IRowDefintion.

Specified by:
getDataBooks in interface IRowDefinition
Returns:
An IDataBook array of currently using this IRowDefinition.

createRowDefinition

public IRowDefinition createRowDefinition(String[] pColumnNames)
                                   throws ModelException
Returns a cloned IRowDefinition with only a subset of ColumnDefinitions, specified by a column name String[].

Specified by:
createRowDefinition in interface IRowDefinition
Parameters:
pColumnNames - column names to use
Returns:
a cloned IRowDefinition with only a subset column names String[].
Throws:
ModelException - if the IRowDefinition couldn't constructed

addColumnDefinition

public void addColumnDefinition(ColumnDefinition pColumnDefinition)
                         throws ModelException
Adds an ColumnDefinition to this IRowDefinition.
Implementation need to check, that this ColumnDefinition is only added in one IRowDefinition. After an IDataBook is registered (at open()) to this IRowDefinition, it is not allowed to add columns.

Specified by:
addColumnDefinition in interface IRowDefinition
Parameters:
pColumnDefinition - the new ColumnDefinition
Throws:
ModelException - if the ColumnDefinition name already exists or it is already added to another IRowDefintion or if an IDataBook is registered (at open()) to the IRowDefinition.

getColumnDefinition

public ColumnDefinition getColumnDefinition(String pColumnName)
                                     throws ModelException
Returns the ColumnDefinition by name.

Specified by:
getColumnDefinition in interface IRowDefinition
Parameters:
pColumnName - name of the ColumnDefinition
Returns:
the ColumnDefinition by name.
Throws:
ModelException - if the ColumnDefinition name not exists.

getColumnDefinition

public ColumnDefinition getColumnDefinition(int pColumnIndex)
Returns the ColumnDefinition by index.

Specified by:
getColumnDefinition in interface IRowDefinition
Parameters:
pColumnIndex - index of the ColumnDefinition
Returns:
the ColumnDefinition by index.

getColumnDefinitionIndex

public int getColumnDefinitionIndex(String pColumnName)
Returns the index of the ColumnDefinition name of this IRowDefinition.

Specified by:
getColumnDefinitionIndex in interface IRowDefinition
Parameters:
pColumnName - name of the ColumnDefinition
Returns:
the index of the ColumnDefinition name of this IRowDefinition, or -1 if it does not exist.

getColumnCount

public int getColumnCount()
Returns the column count of this IRowDefintion.

Specified by:
getColumnCount in interface IRowDefinition
Returns:
the column count of this IRowDefintion.

getColumnNames

public String[] getColumnNames()
Returns the String[] of all column names in this IRowDefintion.

Specified by:
getColumnNames in interface IRowDefinition
Returns:
the String[] of all column names in this IRowDefintion.

getPrimaryKeyColumnNames

public String[] getPrimaryKeyColumnNames()
Returns the String[] of all column names in the primary key.

Specified by:
getPrimaryKeyColumnNames in interface IRowDefinition
Returns:
the String[] of all column names in the primary key.

setPrimaryKeyColumnNames

public void setPrimaryKeyColumnNames(String[] pColumnNames)
                              throws ModelException
Sets all primary key column names.
It isn't allowed to change the primary key after open() the corresponding DataBook or if the DataRow is in use.

Specified by:
setPrimaryKeyColumnNames in interface IRowDefinition
Parameters:
pColumnNames - the new String[] with the column names to set the primary key
Throws:
ModelException - if an IDataBook already registered (at open()) to this IRowdDefinition.

getColumnViewClasses

public Class<? extends IControl>[] getColumnViewClasses()
Gets the classes for which ColumnViews are set.

Specified by:
getColumnViewClasses in interface IRowDefinition
Returns:
the classes for which ColumnViews are set.

getColumnView

public ColumnView getColumnView(Class<? extends IControl> pTargetControl)
Gets the ColumnView to use for GUI controls.
The target control class has to be instance of IControl (eg. ITableControl, ITreeControl, IEditorControl) or null for default.
The ColumnView is stored to the base interface or class that is instance of IControl. So it does not matter if you use getColumnView(ITableControl) or getColumnView(ITable), getColumnView(UITable) because they are all base on ITableControl.
The default is used as long as no ColumnView is set for a specific type of IControl.
eg:
if you set: rowDef.setColumnView(null, new ColumnView("NAME")) then rowDef.getColumnView(null) and rowDef.getColumnView(ITableControl) and rowDef.getColumnView(ITreeControl)... are returning the same instance set before.
if you set: rowDef.setColumnView(UITree, new ColumnView("NAME")) then rowDef.getColumnView(null) and rowDef.getColumnView(ITableControl) are returning the default.
rowDef.getColumnView(ITreeControl) and rowDef.getColumnView(UITree) are returning the same instance set with UITree.

Specified by:
getColumnView in interface IRowDefinition
Parameters:
pTargetControl - the type of target class.
Returns:
the column view to use for GUI controls.

setColumnView

public void setColumnView(Class<? extends IControl> pTargetControl,
                          ColumnView pColumnView)
                   throws ModelException
Sets the column view to use for GUI controls. The target control class has to be instance of IControl (eg. ITableControl, ITreeControl, IEditorControl) or null for default.
The ColumnView is stored to the base interface or class that is instance of IControl. So it does not matter if you use getColumnView(ITableControl) or getColumnView(ITable), getColumnView(UITable) because they are all base on ITableControl.
The default is used as long as no ColumnView is set for a specific type of IControl.
eg:
if you set: rowDef.setColumnView(null, new ColumnView("NAME")) then rowDef.getColumnView(null) and rowDef.getColumnView(ITableControl) and rowDef.getColumnView(ITreeControl)... are returning the same instance set before.
if you set: rowDef.setColumnView(UITree, new ColumnView("NAME")) then rowDef.getColumnView(null) and rowDef.getColumnView(ITableControl) are returning the default.
rowDef.getColumnView(ITreeControl) and rowDef.getColumnView(UITree) are returning the same instance set with UITree.

Specified by:
setColumnView in interface IRowDefinition
Parameters:
pTargetControl - the type of target class.
pColumnView - the column view to use for GUI controls.
Throws:
ModelException - if the xxxColumnsName (eg.xxx=Table) are not existing in the IRowDefinition.

setReadOnly

public void setReadOnly(String[] pColumnNames)
                 throws ModelException
Sets the specified column names as read only true.

Specified by:
setReadOnly in interface IRowDefinition
Parameters:
pColumnNames - the column names to use. if null or empty, then all columns are used.
Throws:
ModelException - if one column name doesn't exist.

getReadOnly

public String[] getReadOnly()
Returns all read only (true) column names.

Specified by:
getReadOnly in interface IRowDefinition
Returns:
all read only (true) column names.

addControl

public void addControl(IControl pControl)
Adds a IControl to the IRowDefinition.
The registered IControl methods will be called if IRowDefinition has changed.

Specified by:
addControl in interface IRowDefinition
Parameters:
pControl - the IControl
See Also:
IControl

removeControl

public void removeControl(IControl pControl)
Removes the IControl from the IRowDefinition.

Specified by:
removeControl in interface IRowDefinition
Parameters:
pControl - the IControl
See Also:
IControl

getControls

public IControl[] getControls()
Returns all IControl's from the IRowDefinition.

Specified by:
getControls in interface IRowDefinition
Returns:
all IControl's from the IRowDefinition.

toString

public String toString()

Overrides:
toString in class Object

getDefaultColumnView

public ColumnView getDefaultColumnView()
Returns the default table columns names.
Thats all columns without the PK columns.

Returns:
the default table columns names.

getLinkReferenceColumnNames

public String[] getLinkReferenceColumnNames(String pColumnName)
Gets all columns with a LinkReference including pColumnName.

Parameters:
pColumnName - the column name.
Returns:
all columns with a LinkReference including pColumnName.

getLinkReference

public ReferenceDefinition getLinkReference(String pColumnName)
Gets the link reference of the column name.

Parameters:
pColumnName - the column name.
Returns:
the link reference

getMasterReference

public ReferenceDefinition getMasterReference()
Gets the master reference.

Returns:
the master reference

isMasterLinkColumn

public boolean isMasterLinkColumn(String pColumnName)
Gets true, if the column is a LinkReferenceColumn for the MasterReference definition.

Parameters:
pColumnName - the column name.
Returns:
true, if the column is a LinkReferenceColumn for the MasterReference definition.

setDefaultIgnoredColumnNames

public static void setDefaultIgnoredColumnNames(String... pColumnNames)
Sets a list of columns which are excluded from the table columns when no specific table columns are set. The column names are specified with or without wildcard, e.g. *_id. The column names are case insensitive.

Parameters:
pColumnNames - a list of column names to ignore

getDefaultIgnoredColumnNames

public static String[] getDefaultIgnoredColumnNames()
Gets the list of columns which are not included in the table columns when no specific table columns are set.

Returns:
the list of ignored column names
See Also:
setDefaultIgnoredColumnNames(String...)

isColumnIgnored

public static boolean isColumnIgnored(String pColumnName)
Gets whether a column name is ignored through the default ignored column names.

Parameters:
pColumnName - the column name to check
Returns:
true when the column is ignored, false if it is not ignored


Copyright © 2009 SIB Visions GmbH. All Rights Reserved.