javax.rad.model
Class RowDefinition

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

public class RowDefinition
extends java.lang.Object
implements IRowDefinition, java.io.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

Field Summary
 
Fields inherited from interface javax.rad.model.IRowDefinition
ALL_COLUMNS
 
Constructor Summary
RowDefinition()
           
 
Method Summary
 void addColumnDefinition(ColumnDefinition pColumnDefinition)
          Adds the given ColumnDefinition.
 void addControl(IControl pControl)
          Adds the given IControl so that it is notified if the IRowDefinition changes.
 void addDataBook(IDataBook pDataBook)
          Adds the given IDataBook at this IRowDefinition, which means that the given IDataBook is using this IRowDefinition.
 IRowDefinition createRowDefinition(java.lang.String[] pColumnNames)
          Creates a IRowDefinition with only the ColumnDefinitions which have been specified.
 int getColumnCount()
          Gets the count of added ColumnDefinitions.
 ColumnDefinition getColumnDefinition(int pColumnIndex)
          Gets the ColumnDefinition with the given index.
 ColumnDefinition getColumnDefinition(java.lang.String pColumnName)
          Gets the ColumnDefinition with the given name.
 int getColumnDefinitionIndex(java.lang.String pColumnName)
          Gets the index of the ColumnDefinition with the given name.
 int[] getColumnDefinitionIndexes(java.lang.String[] pColumnNames)
          Returns the indexes of the ColumnDefinitions with the given names.
 ColumnDefinition[] getColumnDefinitions()
          Gets all added ColumnDefinitions as array.
 java.lang.String[] getColumnNames()
          Gets the names of all added ColumnDefinitions.
 ColumnView getColumnView(java.lang.Class<? extends IControl> pTargetControl)
          Gets the ColumnView to use for the given IControl.
 java.lang.Class<? extends IControl>[] getColumnViewClasses()
          Gets the classes for which ColumnViews are set.
 IControl[] getControls()
          Returns all added IControls.
 IDataBook[] getDataBooks()
          Gets the array if IDataBooks which have been added.
 ColumnView getDefaultColumnView()
          Returns the default table columns names.
static java.lang.String[] getDefaultIgnoredColumnNames()
          Gets the list of columns which are not included in the table columns when no specific table columns are set.
 ReferenceDefinition getLinkReference(java.lang.String pColumnName)
          Gets the link reference of the column name.
 java.lang.String[] getLinkReferenceColumnNames(java.lang.String pColumnName)
          Gets all columns with a LinkReference including pColumnName.
 ReferenceDefinition getMasterReference()
          Gets the master reference.
 java.lang.String[] getPrimaryKeyColumnNames()
          Gets the names of all added ColumnDefinitions which represent a primary key column.
 java.lang.String[] getReadOnly()
          Gets the names of the columns which are read only.
static boolean isColumnIgnored(java.lang.String pColumnName)
          Gets whether a column name is ignored through the default ignored column names.
 boolean isMasterLinkColumn(java.lang.String pColumnName)
          Gets true, if the column is a LinkReferenceColumn for the MasterReference definition.
 void removeControl(IControl pControl)
          Removes the given IControl.
 void removeDataBook(IDataBook pDataBook)
          Removes the given IDataBook from this IRowDefinition.
 void setColumnView(java.lang.Class<? extends IControl> pTargetControl, ColumnView pColumnView)
          Sets the ColumnView for the given IControl.
static void setDefaultIgnoredColumnNames(java.lang.String... pColumnNames)
          Sets a list of columns which are excluded from the table columns when no specific table columns are set.
 void setPrimaryKeyColumnNames(java.lang.String[] pColumnNames)
          Sets the names of all added ColumnDefinitions which represent a primary key column.
 void setReadOnly(java.lang.String[] pColumnNames)
          Sets that specified columns as read only.
 java.lang.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 pDataBook)
                 throws ModelException
Adds the given IDataBook at this IRowDefinition, which means that the given IDataBook is using this IRowDefinition.

The added IDataBook has to remove itself when appropriate.

Specified by:
addDataBook in interface IRowDefinition
Parameters:
pDataBook - the IDataBook to register.
Throws:
ModelException - if adding it was not possible.
See Also:
IRowDefinition.getDataBooks(), IRowDefinition.removeDataBook(IDataBook)

removeDataBook

public void removeDataBook(IDataBook pDataBook)
Removes the given IDataBook from this IRowDefinition.

The registered IDataBook has to remove itself when appropriate.

Specified by:
removeDataBook in interface IRowDefinition
Parameters:
pDataBook - the IDataBook to remove.
See Also:
IRowDefinition.addDataBook(IDataBook), IRowDefinition.getDataBooks()

getDataBooks

public IDataBook[] getDataBooks()
Gets the array if IDataBooks which have been added.

Specified by:
getDataBooks in interface IRowDefinition
Returns:
the array if IDataBooks which have been added. Note that this array is only a clone and changing it won't change the internal state of the IRowDefinition.
See Also:
IRowDefinition.addDataBook(IDataBook), IRowDefinition.removeDataBook(IDataBook)

createRowDefinition

public IRowDefinition createRowDefinition(java.lang.String[] pColumnNames)
                                   throws ModelException
Creates a IRowDefinition with only the ColumnDefinitions which have been specified.

If the given column names is null this instance is returned, additionally the instances of the IRowDefinitions can be cached, so that they same instance is returned for the same column names.

Specified by:
createRowDefinition in interface IRowDefinition
Parameters:
pColumnNames - the names of the ColumnDefinitions to copy.
Returns:
a IRowDefinition with only the ColumnDefinitions which have been specified.
Throws:
ModelException - if the IRowDefinition couldn't be constructed.

addColumnDefinition

public void addColumnDefinition(ColumnDefinition pColumnDefinition)
                         throws ModelException
Adds the given ColumnDefinition.

Implementations need to check that the given ColumnDefinition is not added to another IRowDefinition. Also it is not allowed to add a ColumnDefinition after an IDataBook has been added.

Specified by:
addColumnDefinition in interface IRowDefinition
Parameters:
pColumnDefinition - the ColumnDefinition to add.
Throws:
ModelException - if there is already a ColumnDefinition with that name or if the given ColumnDefinition is already added to another IRowDefinition or a IDataBook has already been added.

getColumnDefinition

public ColumnDefinition getColumnDefinition(java.lang.String pColumnName)
                                     throws ModelException
Gets the ColumnDefinition with the given name.

Specified by:
getColumnDefinition in interface IRowDefinition
Parameters:
pColumnName - name of the ColumnDefinition to get.
Returns:
the ColumnDefinition with the given name.
Throws:
ModelException - if there is no ColumnDefinition with that name.

getColumnDefinition

public ColumnDefinition getColumnDefinition(int pColumnIndex)
Gets the ColumnDefinition with the given index.

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

getColumnDefinitionIndex

public int getColumnDefinitionIndex(java.lang.String pColumnName)
Gets the index of the ColumnDefinition with the given name. Returns -1 if there is no ColumnDefinition with the given name.

Specified by:
getColumnDefinitionIndex in interface IRowDefinition
Parameters:
pColumnName - name of the ColumnDefinition.
Returns:
the index of the ColumnDefinition with the given name, -1 if there is none.
See Also:
IRowDefinition.getColumnDefinitionIndexes(String[])

getColumnDefinitionIndexes

public int[] getColumnDefinitionIndexes(java.lang.String[] pColumnNames)
Returns the indexes of the ColumnDefinitions with the given names.

If any of the given names does not exist, the resulting array will contain -1 at that position.

Specified by:
getColumnDefinitionIndexes in interface IRowDefinition
Parameters:
pColumnNames - the names of the ColumnDefinitions.
Returns:
the indexes of the ColumnDefinitions with the given names, -1 for non existing names.
See Also:
IRowDefinition.getColumnDefinitionIndex(String)

getColumnCount

public int getColumnCount()
Gets the count of added ColumnDefinitions.

Specified by:
getColumnCount in interface IRowDefinition
Returns:
the count of added ColumnDefinitions.
See Also:
IRowDefinition.addColumnDefinition(ColumnDefinition)

getColumnDefinitions

public ColumnDefinition[] getColumnDefinitions()
Gets all added ColumnDefinitions as array.

The returned array is a copy, so changing the array will not change the IRowDefinition.

Specified by:
getColumnDefinitions in interface IRowDefinition
Returns:
all added ColumnDefinitions as array.

getColumnNames

public java.lang.String[] getColumnNames()
Gets the names of all added ColumnDefinitions.

Specified by:
getColumnNames in interface IRowDefinition
Returns:
the names of all added ColumnDefinitions.
See Also:
IRowDefinition.addColumnDefinition(ColumnDefinition)

getPrimaryKeyColumnNames

public java.lang.String[] getPrimaryKeyColumnNames()
Gets the names of all added ColumnDefinitions which represent a primary key column.

Specified by:
getPrimaryKeyColumnNames in interface IRowDefinition
Returns:
the names of all added ColumnDefinitions.
See Also:
IRowDefinition.getPrimaryKeyColumnNames()

setPrimaryKeyColumnNames

public void setPrimaryKeyColumnNames(java.lang.String[] pColumnNames)
                              throws ModelException
Sets the names of all added ColumnDefinitions which represent a primary key column.

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 has already been added.
See Also:
IRowDefinition.getPrimaryKeyColumnNames()

getColumnViewClasses

public java.lang.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.
See Also:
IRowDefinition.getColumnView(Class), IRowDefinition.setColumnView(Class, ColumnView)

getColumnView

public ColumnView getColumnView(java.lang.Class<? extends IControl> pTargetControl)
Gets the ColumnView to use for the given IControl. The given IControl class can also be null to get the default ColumnView.

If there is no ColumnView for the given class the default one will be returned.

The ColumnView is stored to the base interface, so it does not matter if you use the interface or the implementing class.

Specified by:
getColumnView in interface IRowDefinition
Parameters:
pTargetControl - the class of the IControl for which to get the ColumnView, can be null for the default one.
Returns:
the ColumnView for the given IControl class.
See Also:
IRowDefinition.getColumnViewClasses(), IRowDefinition.setColumnView(Class, ColumnView)

setColumnView

public void setColumnView(java.lang.Class<? extends IControl> pTargetControl,
                          ColumnView pColumnView)
                   throws ModelException
Sets the ColumnView for the given IControl. The given IControl class can also be null to set the default ColumnView.

The ColumnView is stored to the base interface, so it does not matter if you use the interface or the implementing class.

Specified by:
setColumnView in interface IRowDefinition
Parameters:
pTargetControl - the class of the IControl for which to set the ColumnView, can be null to set the default one.
pColumnView - the ColumnView for the given IControl class.
Throws:
ModelException - if any of the column names specified in the ColumnView does not exist in this IRowDefinition.
See Also:
IRowDefinition.getColumnViewClasses(), IRowDefinition.getColumnView(Class)

setReadOnly

public void setReadOnly(java.lang.String[] pColumnNames)
                 throws ModelException
Sets that specified columns as read only.

Specified by:
setReadOnly in interface IRowDefinition
Parameters:
pColumnNames - the names of all read only columns, null for all.
Throws:
ModelException - if any of the column names does not exist.
See Also:
IRowDefinition.getReadOnly()

getReadOnly

public java.lang.String[] getReadOnly()
Gets the names of the columns which are read only.

Specified by:
getReadOnly in interface IRowDefinition
Returns:
the names of the read only columns.
See Also:
IRowDefinition.setReadOnly(String[])

addControl

public void addControl(IControl pControl)
Adds the given IControl so that it is notified if the IRowDefinition changes.

Specified by:
addControl in interface IRowDefinition
Parameters:
pControl - the IControl to add.
See Also:
IRowDefinition.getControls(), IRowDefinition.removeControl(IControl)

removeControl

public void removeControl(IControl pControl)
Removes the given IControl.

Specified by:
removeControl in interface IRowDefinition
Parameters:
pControl - the IControl to remove.
See Also:
IRowDefinition.addControl(IControl), IRowDefinition.getControls()

getControls

public IControl[] getControls()
Returns all added IControls.

Specified by:
getControls in interface IRowDefinition
Returns:
all added IControls.
See Also:
IRowDefinition.addControl(IControl), IRowDefinition.removeControl(IControl)

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.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 java.lang.String[] getLinkReferenceColumnNames(java.lang.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(java.lang.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(java.lang.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(java.lang.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 java.lang.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(java.lang.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.