net.datacrow.core.objects
Class DcField

java.lang.Object
  extended by net.datacrow.core.objects.DcField
All Implemented Interfaces:
java.io.Serializable

public class DcField
extends java.lang.Object
implements java.io.Serializable

Fields are part of a Data Crow module. A field defines how it is represented in the UI, which label is used to describe it, if it can be searched on, if it is editable, the maximum length of its content and so on.

Author:
Robert Jan van der Waals
See Also:
Serialized Form

Constructor Summary
DcField(int index, int module, java.lang.String label, boolean uiOnly, boolean enabled, boolean readonly, boolean searchable, int maximumLength, int fieldType, int modRef, int valueType, java.lang.String databaseFieldName)
          Creates a new field.
DcField(XmlField field, int module)
          Creates a new field based on a XML definition.
 
Method Summary
 void addValueEnhancer(IValueEnhancer enhancer)
          Register a new value enhancer.
 java.lang.String getDatabaseFieldName()
          Set the database column name.
 java.lang.String getDataBaseFieldType()
          Calculates the database field type definition.
 DcFieldDefinition getDefinition()
           
 int getFieldType()
          The component type.
 int getIndex()
          The unique field index.
 java.lang.String getLabel()
          The display label.
 int getMaximumLength()
          Returns the maximum field length (characters positions).
 int getModule()
          The module to which this field belongs.
 java.lang.String getOriginalLabel()
           
 int getReferenceIdx()
          The module reference index.
 java.lang.String getResourceKey()
          The key used for setting the value in the resources.
 int getSourceModuleIdx()
          The source module index.
 java.lang.String getSystemName()
          The system name of this field.
 IValueEnhancer[] getValueEnhancers()
          Retrieves all the registered value enhancers.
 int getValueType()
          The value type.
 boolean isEnabled()
          Indicates if the field is enabled.
 boolean isReadOnly()
          Indicates if the value belonging to this field can be edited.
 boolean isRequired()
          Mark the field as required.
 boolean isSearchable()
          Indicates if the user can search on this field.
 boolean isUiOnly()
          When a field is marked as UI only its value will not be stored in the database.
 void removeEnhancers()
          Remove all the registered value enhancers.
 void setDatabaseFieldName(java.lang.String s)
          Sets the database column name.
 void setEnabled(boolean enabled)
          Indicates if this field is enabled by default.
 void setFieldType(int index)
          Sets the component type.
 void setIndex(int index)
          Sets the unique field index.
 void setMaximumLength(int i)
          The maximum length of the value of this field.
 void setModule(int module)
          Set the module to which this field belongs.
 void setReadOnly(boolean b)
          Indicate if the value of this field can edited.
 void setRequired(boolean b)
          Mark the field as required.
 void setSearchable(boolean searchable)
          Indicate if the user is allowed to search on this field.
 void setSourceModuleIdx(int modRef)
          Sets the source module index.
 void setUiOnly(boolean uiOnly)
          When a field is marked as UI only its value will not be stored in the database.
 void setValueType(int index)
          Sets the value type.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DcField

public DcField(XmlField field,
               int module)
Creates a new field based on a XML definition.

Parameters:
field - XML definition.
module - The module index to which this field belongs.

DcField

public DcField(int index,
               int module,
               java.lang.String label,
               boolean uiOnly,
               boolean enabled,
               boolean readonly,
               boolean searchable,
               int maximumLength,
               int fieldType,
               int modRef,
               int valueType,
               java.lang.String databaseFieldName)
Creates a new field.

Parameters:
index - The unique field index.
module - The module to which this field belongs.
label - The display label.
uiOnly - Indicates if this field is represented by a database column.
enabled - Indicates if the field will be used. Can be overridden by the user.
readonly - Indicates if the field can be edited.
searchable - Tells if the user can search on this field.
techinfo - Holds technical information?
maximumLength - The maximum value length.
fieldType - The (component) field type.
modRef - The module reference.
valueType - The value type DcRepository.ValueTypes
databaseFieldName - The database column name.
Method Detail

setSourceModuleIdx

public void setSourceModuleIdx(int modRef)
Sets the source module index.

Parameters:
modRef - The module index.

getSourceModuleIdx

public int getSourceModuleIdx()
The source module index.


getReferenceIdx

public int getReferenceIdx()
The module reference index.


setIndex

public void setIndex(int index)
Sets the unique field index.

Parameters:
index -

getIndex

public int getIndex()
The unique field index.


setModule

public void setModule(int module)
Set the module to which this field belongs.

Parameters:
module - The module index.

getModule

public int getModule()
The module to which this field belongs.


setUiOnly

public void setUiOnly(boolean uiOnly)
When a field is marked as UI only its value will not be stored in the database.

Parameters:
uiOnly -

isUiOnly

public boolean isUiOnly()
When a field is marked as UI only its value will not be stored in the database.


setEnabled

public void setEnabled(boolean enabled)
Indicates if this field is enabled by default. This setting can be overridden by the user.

Parameters:
enabled -

isEnabled

public boolean isEnabled()
Indicates if the field is enabled. Depends on both the settings and the permissions of the user.


setSearchable

public void setSearchable(boolean searchable)
Indicate if the user is allowed to search on this field.

Parameters:
searchable -

getDatabaseFieldName

public java.lang.String getDatabaseFieldName()
Set the database column name.


getFieldType

public int getFieldType()
The component type.


getValueType

public int getValueType()
The value type.

See Also:
DcRepository.ValueTypes

getOriginalLabel

public java.lang.String getOriginalLabel()

getLabel

public java.lang.String getLabel()
The display label. - If the field definitions (field settings) have a custom label defined this value will be used. - If not the field label will be retrieved using the resources. - Else the original label will be used.


getDefinition

public DcFieldDefinition getDefinition()

getResourceKey

public java.lang.String getResourceKey()
The key used for setting the value in the resources.


getSystemName

public java.lang.String getSystemName()
The system name of this field.


isRequired

public boolean isRequired()
Mark the field as required.


isReadOnly

public boolean isReadOnly()
Indicates if the value belonging to this field can be edited. Depends on both the settings and the permissions of the user.


isSearchable

public boolean isSearchable()
Indicates if the user can search on this field.

Returns:

getMaximumLength

public int getMaximumLength()
Returns the maximum field length (characters positions). In case the field is of type long text field the maximum value will be the maximum integer (Integer.MAX_VALUE) value (maximum field setting is thus overruled).


setReadOnly

public void setReadOnly(boolean b)
Indicate if the value of this field can edited.


setRequired

public void setRequired(boolean b)
Mark the field as required.

Parameters:
b -

setMaximumLength

public void setMaximumLength(int i)
The maximum length of the value of this field.

Parameters:
i -

setFieldType

public void setFieldType(int index)
Sets the component type.

Parameters:
index -

setValueType

public void setValueType(int index)
Sets the value type.

Parameters:
index -
See Also:
DcRepository.ValueTypes

setDatabaseFieldName

public void setDatabaseFieldName(java.lang.String s)
Sets the database column name.

Parameters:
s -

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

removeEnhancers

public void removeEnhancers()
Remove all the registered value enhancers.


addValueEnhancer

public void addValueEnhancer(IValueEnhancer enhancer)
Register a new value enhancer.

Parameters:
enhancer -

getValueEnhancers

public IValueEnhancer[] getValueEnhancers()
Retrieves all the registered value enhancers.

Returns:

getDataBaseFieldType

public java.lang.String getDataBaseFieldType()
Calculates the database field type definition.