org.caleigo.core
Class FieldDescriptor

java.lang.Object
  extended byorg.caleigo.core.FieldDescriptor
All Implemented Interfaces:
IFieldDescriptor, java.io.Serializable
Direct Known Subclasses:
AbstractCalculatedFieldDescriptor, CustomFieldDescriptor

public class FieldDescriptor
extends java.lang.Object
implements IFieldDescriptor

Version:
1.00
Author:
Dennis Zikovic
See Also:
Serialized Form

Nested Class Summary
protected static class FieldDescriptor.Dezerializer
           
protected  class FieldDescriptor.FieldRelationIterator
           
 
Field Summary
 
Fields inherited from interface org.caleigo.core.IFieldDescriptor
AUTOGEN, HIDDEN_FIELD, HINT_FIELD, IDENTITY_FIELD, INDEXED, NAME_FIELD, NATURAL_ORDER, OVERVIEW_FIELD, READ_ONLY_FIELD, REQUIRED
 
Constructor Summary
protected FieldDescriptor(java.lang.String codeName, java.lang.String sourceName, java.lang.String displayName, java.lang.String entityDescriptorName, DataType dataType, int length, int flags, java.lang.Object defValue)
          The FieldDescriptor constructor has package scope to avoid missuse.
 
Method Summary
protected  void addValidator(IDataValidator dataValidator)
           
 boolean canValidate(IDataProvider dataProvider)
          This method returns true if the called field descriptor can validate data described by the field in the context of the provided IDataProvider object.
 java.lang.String getCodeName()
          Return the code name for the field.
 DataType getDataType()
          Returns the data type for the field.
 java.lang.Object getDefaultValue()
          Return the default value for the field or null if none is set.
 java.lang.String getDisplayName()
          Returns the display name for the field.
 IEntityDescriptor getEntityDescriptor()
          Access method that returns the entity descriptor that the described field is part of.
 java.util.Iterator getFieldRelations()
          Access method that returns an iterator for all IFieldRelation objects that the called field descripyor is a part of.
 int getLength()
          Returns the length of the data type if the type is a scalar type.
 IFieldRelation getReferenceFieldRelation()
          Access method that returns the field relation that the called field is a reference to.
 java.lang.String getSourceName()
          Returns the source name for the field.
 boolean isAutoGenerated()
          Access method that returns true if the field is autogenerated or not.
 boolean isHiddenField()
          Access method that returns true if the field is hidden, meaning that data of the fields type should never be displayed for the end-user.
 boolean isHintField()
          Access method that returns true if the field is a suitable hint field for the entity it is a part of for the end-user.
 boolean isIdentityField()
          Access method that returns true if the field is a part of the entity´s identity (primary key in a relational database).
 boolean isIndexed()
          Access method that returns true if the field is a preferred field to qualify on.
 boolean isNameField()
          Access method that returns true if the field is suitable name field to define the identify of the entity it is a part of for the end-user.
 boolean isNaturalOrder()
          Access method that returns true if the field is the natural order field for the entities it is a part of.
 boolean isOverviewField()
          Access method that returns true if the field is suitable for limited overview of the entity it is a part of.
 boolean isReadOnly()
          Access method that returns true if the field as read-only meaning that data of the fields type should never be edited by the end-user.
 boolean isReferenceField()
          Access method that returns true if the field is apart of an entity reference.
 boolean isRequired()
          Access method that returns true if the field is required and allows null values or not.
 ValidationResult performBaseValidation(java.lang.Object dataValue)
          Performs basic validations that are relevant for all fields like checking for null values in reguired field data.
 java.lang.String toString()
           
 ValidationResult validateData(java.lang.Object data, IDataProvider dataProvider)
          This method validates the provided data object as described by the called field descriptor in the context of the provided IDataProvider object.
protected  java.lang.Object writeReplace()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FieldDescriptor

protected FieldDescriptor(java.lang.String codeName,
                          java.lang.String sourceName,
                          java.lang.String displayName,
                          java.lang.String entityDescriptorName,
                          DataType dataType,
                          int length,
                          int flags,
                          java.lang.Object defValue)
The FieldDescriptor constructor has package scope to avoid missuse.

Method Detail

toString

public java.lang.String toString()

writeReplace

protected java.lang.Object writeReplace()
                                 throws java.io.ObjectStreamException
Throws:
java.io.ObjectStreamException

getCodeName

public java.lang.String getCodeName()
Description copied from interface: IFieldDescriptor
Return the code name for the field. The code name should be used for programitic identification. This is safer and recomended compared to the use of field indexes. The code name is also the name of the data property for the field in enities.

Specified by:
getCodeName in interface IFieldDescriptor

getSourceName

public java.lang.String getSourceName()
Description copied from interface: IFieldDescriptor
Returns the source name for the field. The source name is an identifier for the field in the data service layer.

Specified by:
getSourceName in interface IFieldDescriptor

getDisplayName

public java.lang.String getDisplayName()
Description copied from interface: IFieldDescriptor
Returns the display name for the field. The reurned value has been passed through the ResourceProvider to allow localisation.

Specified by:
getDisplayName in interface IFieldDescriptor

getDataType

public DataType getDataType()
Description copied from interface: IFieldDescriptor
Returns the data type for the field.

Specified by:
getDataType in interface IFieldDescriptor

getLength

public int getLength()
Description copied from interface: IFieldDescriptor
Returns the length of the data type if the type is a scalar type.

Specified by:
getLength in interface IFieldDescriptor

getDefaultValue

public java.lang.Object getDefaultValue()
Description copied from interface: IFieldDescriptor
Return the default value for the field or null if none is set. This defayult value will automaticalli be set as the default value for created entities tha the field is part of.

Specified by:
getDefaultValue in interface IFieldDescriptor

isIdentityField

public boolean isIdentityField()
Description copied from interface: IFieldDescriptor
Access method that returns true if the field is a part of the entity´s identity (primary key in a relational database). Note that an entity can have multiple identity fields. All entities in the cel framework must have atleast one identity field.

Specified by:
isIdentityField in interface IFieldDescriptor

isReferenceField

public boolean isReferenceField()
Description copied from interface: IFieldDescriptor
Access method that returns true if the field is apart of an entity reference.

Specified by:
isReferenceField in interface IFieldDescriptor

isRequired

public boolean isRequired()
Description copied from interface: IFieldDescriptor
Access method that returns true if the field is required and allows null values or not. The view layer will for instance use this flag to validate the data null values according to this flag.

Specified by:
isRequired in interface IFieldDescriptor

isIndexed

public boolean isIndexed()
Description copied from interface: IFieldDescriptor
Access method that returns true if the field is a preferred field to qualify on. It is normally used to state if the underlaying database has an index on the field.

Specified by:
isIndexed in interface IFieldDescriptor

isAutoGenerated

public boolean isAutoGenerated()
Description copied from interface: IFieldDescriptor
Access method that returns true if the field is autogenerated or not. Fields with this flag should never have values edited by the end-user.

Specified by:
isAutoGenerated in interface IFieldDescriptor

isNameField

public boolean isNameField()
Description copied from interface: IFieldDescriptor
Access method that returns true if the field is suitable name field to define the identify of the entity it is a part of for the end-user. If no name field is defined the identity field then no reference mapping will be done for the end-user in the view layer. An etity may only have one name field.

Specified by:
isNameField in interface IFieldDescriptor

isOverviewField

public boolean isOverviewField()
Description copied from interface: IFieldDescriptor
Access method that returns true if the field is suitable for limited overview of the entity it is a part of. It is used in the view layer to define what fields that by default should be displayed in lists and in qualifier views. An entity should normally have less the five overview fields.

Specified by:
isOverviewField in interface IFieldDescriptor

isHintField

public boolean isHintField()
Description copied from interface: IFieldDescriptor
Access method that returns true if the field is a suitable hint field for the entity it is a part of for the end-user. If no hint field is defined then no hints will be automatically displayed for the end-user in the view layer. An etity may only have one hint field.

Specified by:
isHintField in interface IFieldDescriptor

isHiddenField

public boolean isHiddenField()
Description copied from interface: IFieldDescriptor
Access method that returns true if the field is hidden, meaning that data of the fields type should never be displayed for the end-user.

Specified by:
isHiddenField in interface IFieldDescriptor

isReadOnly

public boolean isReadOnly()
Description copied from interface: IFieldDescriptor
Access method that returns true if the field as read-only meaning that data of the fields type should never be edited by the end-user.

Specified by:
isReadOnly in interface IFieldDescriptor

isNaturalOrder

public boolean isNaturalOrder()
Description copied from interface: IFieldDescriptor
Access method that returns true if the field is the natural order field for the entities it is a part of. If no natural order field is defined the identity field will be used for natural order.

Specified by:
isNaturalOrder in interface IFieldDescriptor

getEntityDescriptor

public IEntityDescriptor getEntityDescriptor()
Description copied from interface: IFieldDescriptor
Access method that returns the entity descriptor that the described field is part of.

Specified by:
getEntityDescriptor in interface IFieldDescriptor

canValidate

public boolean canValidate(IDataProvider dataProvider)
This method returns true if the called field descriptor can validate data described by the field in the context of the provided IDataProvider object. The minimum requiriment is that described field data can be provided but in some cases other data resources is also required.

Specified by:
canValidate in interface IFieldDescriptor

validateData

public ValidationResult validateData(java.lang.Object data,
                                     IDataProvider dataProvider)
This method validates the provided data object as described by the called field descriptor in the context of the provided IDataProvider object.

Specified by:
validateData in interface IFieldDescriptor

getReferenceFieldRelation

public IFieldRelation getReferenceFieldRelation()
Access method that returns the field relation that the called field is a reference to. If the called field descriptor is not a reference field then null is returned.

Specified by:
getReferenceFieldRelation in interface IFieldDescriptor

getFieldRelations

public java.util.Iterator getFieldRelations()
Access method that returns an iterator for all IFieldRelation objects that the called field descripyor is a part of.

Specified by:
getFieldRelations in interface IFieldDescriptor

addValidator

protected void addValidator(IDataValidator dataValidator)

performBaseValidation

public ValidationResult performBaseValidation(java.lang.Object dataValue)
Performs basic validations that are relevant for all fields like checking for null values in reguired field data.



Copyright © 2005 Caleigo. All Rights Reserved.