info.informatica.data
Class DataField

java.lang.Object
  extended by info.informatica.data.DataField
All Implemented Interfaces:
Validable
Direct Known Subclasses:
ForeignKeyDataEntity, KeyDataEntity

public class DataField
extends Object
implements Validable

Encapsulates the meta information describing a data entity.

Author:
amengual at informatica dot info

Constructor Summary
DataField(FieldName name)
           
DataField(FieldName name, DataType type)
          Builds a data entity of the given name
 
Method Summary
 Object getDefault()
          Get the default value of this data entity.
 FieldName getName()
          Gets the name of the data entity.
 DataType getType()
          Get the java.sql.Types type of this entity.
 boolean isAuto()
          Is this data entity automatic (autonumeric, "magic" date fields)?
 boolean isForeignKey()
          Is this data entity a DB foreign key or not?
 boolean isKey()
          Is this data entity a DB key or not?
 boolean isNullable()
          Is this data entity nullable or not?
 void setAuto()
          Set this data entity to be automatic.
 void setAuto(boolean b)
          Set this data entity to be automatic (or not).
 void setDefault(Object def)
          Sets the default value of this data entity.
 void setNullable()
          Equivalent of setNullable(true);
 void setNullable(boolean b)
          Sets this data entity to be nullable or not according to argument.
 void setType(DataType type)
          Sets the java.sql.Types data type of this entity.
 String toString()
          Gets the description of the data entity.
 Object validate(Object value)
          Validates the value.
 Object validate(Object value, Object helper)
          validates the value according to requirements of the Data Dictionary / Metadata, and using a helper object.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DataField

public DataField(FieldName name)

DataField

public DataField(FieldName name,
                 DataType type)
Builds a data entity of the given name

Method Detail

getName

public final FieldName getName()
Gets the name of the data entity.

Returns:
the name of the data entity

toString

public String toString()
Gets the description of the data entity.

Overrides:
toString in class Object
Returns:
the description of the data entity

setDefault

public void setDefault(Object def)
Sets the default value of this data entity.

Parameters:
def - the default value.

setType

public void setType(DataType type)
Sets the java.sql.Types data type of this entity.

Parameters:
type - the type of this entity.

setNullable

public void setNullable(boolean b)
Sets this data entity to be nullable or not according to argument.

Parameters:
b - true if you want the data entity to be nullable, false if cannot be null.

setNullable

public void setNullable()
Equivalent of setNullable(true);


setAuto

public void setAuto()
Set this data entity to be automatic. equivalent to setAuto(true).


setAuto

public void setAuto(boolean b)
Set this data entity to be automatic (or not).

Parameters:
b - true to set it to auto, false otherwise.

getDefault

public Object getDefault()
Get the default value of this data entity.

Returns:
the default value, or null if none.

isNullable

public boolean isNullable()
Is this data entity nullable or not?

Returns:
true if can be null, false if not.

isKey

public boolean isKey()
Is this data entity a DB key or not?

Returns:
true if is a key, false if not.

isForeignKey

public boolean isForeignKey()
Is this data entity a DB foreign key or not?

Returns:
true if is a foreign key, false if not.

isAuto

public boolean isAuto()
Is this data entity automatic (autonumeric, "magic" date fields)?

Returns:
true if is automatic, false if not.

getType

public DataType getType()
Get the java.sql.Types type of this entity.

Returns:
the datatype of this entity.

validate

public Object validate(Object value)
                throws DataException
Description copied from interface: Validable
Validates the value.

Specified by:
validate in interface Validable
Parameters:
value - the value to be verified/validated
Returns:
the validated version of the object (usually the unchanged value argument).
Throws:
DataException - TODO

validate

public Object validate(Object value,
                       Object helper)
                throws DataException
validates the value according to requirements of the Data Dictionary / Metadata, and using a helper object.

This method typically performs a heavier validation of the value, even when the helper object is null.

Specified by:
validate in interface Validable
Parameters:
value - the value to be verified.
helper - the helper object.
Returns:
the validated version of the object (usually the unchanged value argument).
Throws:
DataException - TODO