info.informatica.data.field
Class DataType

java.lang.Object
  extended by info.informatica.data.field.DataType
Direct Known Subclasses:
BinaryField, DateField, DoubleField, FloatField, IntegerField, LongField, OperationMark, ShortField, StringField

public abstract class DataType
extends Object

Data type information.

Version:
1.03
Author:
amengual at informatica dot info

Field Summary
static String DEFAULT_TYPE
           
 
Method Summary
static DataType create(String entity_class)
          Creates an empty DataField object with name name and class entity_class.
static DataType createAs(Object data)
           
static int dataType(Object data)
          Gives the java.sql.Types type associated by default to a given Java class.
 boolean equals(Object obj)
           
static String getDefaultClassName(int type)
          Gets the appropriate default DataField subclass for the given java.sql.Types int type.
 info.informatica.text.ObjectFormat getFormat()
          Get the field format.
static int getIntType(String tipo)
          Maps the given data type name to its java.sql.Types index.
 int getJavaSQLType()
          Get the java.sql.Types type of this entity.
 String getName()
           
 int getSize()
          Get the field size.
static String getTypeName(int tipo)
          Gets the name of the given java.sql.Types int type.
 int hashCode()
           
abstract  Object objectValue(FieldName varname, String valor)
          Transforms a String value into the appropriate Java object, parsing as needed.
 Object sample()
          Provide a sample of this data type.
 void setFormat(info.informatica.text.ObjectFormat format)
          Sets the format.
 void setJavaSQLType(int type)
           
 void setSize(int i)
          Sets the field size for this data entity
 String toString()
          Gets the description of the data entity.
 Object validate(FieldName name, Object value)
          validates the value according to requirements of the Data Dictionary / Metadata.
 Object validate(FieldName name, 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
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_TYPE

public static final String DEFAULT_TYPE
See Also:
Constant Field Values
Method Detail

toString

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

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

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

setJavaSQLType

public void setJavaSQLType(int type)

setSize

public void setSize(int i)
             throws DataException
Sets the field size for this data entity

Parameters:
i - the field size.
Throws:
DataException

setFormat

public void setFormat(info.informatica.text.ObjectFormat format)
Sets the format.

Parameters:
format - the format of this entity.

getFormat

public info.informatica.text.ObjectFormat getFormat()
Get the field format.

Returns:
the format.

getJavaSQLType

public int getJavaSQLType()
Get the java.sql.Types type of this entity.

Returns:
the java.sql.Types type of this entity.

getSize

public int getSize()
Get the field size.

Returns:
the field size.

create

public static DataType create(String entity_class)
                       throws DataFieldException
Creates an empty DataField object with name name and class entity_class.

Parameters:
entity_class - the class of the required entity.
Returns:
the requested entity object. Cannot return null.
Throws:
DataFieldException

validate

public Object validate(FieldName name,
                       Object value)
                throws DataException
validates the value according to requirements of the Data Dictionary / Metadata.

Parameters:
value - the value to be verified.
Throws:
DataException - TODO

validate

public Object validate(FieldName name,
                       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.

Parameters:
value - the value to be verified.
helper - the helper object.
Throws:
DataException - TODO

sample

public Object sample()
Provide a sample of this data type. Should be reasonably random.

Returns:
the sample, or null if no suitable sample could be produced.

objectValue

public abstract Object objectValue(FieldName varname,
                                   String valor)
                            throws DataFieldException
Transforms a String value into the appropriate Java object, parsing as needed.

Parameters:
valor - the value to be parsed/transformed.
Throws:
DataFieldException

createAs

public static DataType createAs(Object data)

dataType

public static int dataType(Object data)
Gives the java.sql.Types type associated by default to a given Java class.

Parameters:
data - the Java object.
Returns:
the java.sql.Types type associated to the given object.

getTypeName

public static String getTypeName(int tipo)
Gets the name of the given java.sql.Types int type.

Returns:
the String representing the SQL data type, or null if unknown.

getIntType

public static int getIntType(String tipo)
Maps the given data type name to its java.sql.Types index.

Parameters:
tipo - a String containing the non-qualified data type name
Returns:
an integer with the java.sql.Types type for the requested type name

getDefaultClassName

public static String getDefaultClassName(int type)
Gets the appropriate default DataField subclass for the given java.sql.Types int type.


getName

public String getName()