pt.moredata.dao.util
Class DataTypes

java.lang.Object
  extended bypt.moredata.dao.util.DataTypes

public class DataTypes
extends java.lang.Object

DataTypeInfo.java Company MoreData

Version:
$Revision: 1.15 $
Author:
pcarmo

Field Summary
static int ARRAY
          The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type ARRAY.
static int BIGINT
          The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type BIGINT.
static int BINARY
          The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type BINARY.
static int BIT
          The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type BIT.
static int BLOB
          The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type BLOB.
static int BOOLEAN
          The constant in the Java programming language, somtimes referred to as a type code, that identifies the generic SQL type BOOLEAN.
static int CHAR
          The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type CHAR.
static int CLOB
          The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type CLOB.
static int DATALINK
          The constant in the Java programming language, somtimes referred to as a type code, that identifies the generic SQL type DATALINK.
static int DATE
          The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type DATE.
static int DECIMAL
          The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type DECIMAL.
static int DISTINCT
          The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type DISTINCT.
static int DOUBLE
          The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type DOUBLE.
static int FLOAT
          The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type FLOAT.
static int IMAGE
          The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type BLOB for a image.
static int INTEGER
          The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type INTEGER.
static int JAVA_OBJECT
          The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type JAVA_OBJECT.
static int LONGVARBINARY
          The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type LONGVARBINARY.
static int LONGVARCHAR
          The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type LONGVARCHAR.
static int NULL
          The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type NULL.
static int NUMERIC
          The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type NUMERIC.
static int OTHER
          The constant in the Java programming language that indicates that the SQL type is database-specific and gets mapped to a Java object that can be accessed via the methods getObject and setObject.
static int REAL
          The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type REAL.
static int REF
          The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type REF.
static int SMALLINT
          The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type SMALLINT.
static int STRUCT
          The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type STRUCT.
static int TIME
          The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type TIME.
static int TIMESTAMP
          The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type TIMESTAMP.
static int TINYINT
          The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type TINYINT.
static int VARBINARY
          The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type VARBINARY.
static int VARCHAR
          The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type VARCHAR.
 
Method Summary
static int getColLength(int _dataType, int _tamanho, java.lang.String _format)
          Retorna o número de colunas que o objecto irá ocupar depois de formatado
static int getColLength(int _dataType, java.lang.Object _object, java.lang.String _format)
          Retorna o número de colunas que o objecto irá ocupar depois de formatado
static int getColLength(java.lang.String _dataType, int _tamanho, java.lang.String _format)
          Retorna o número de colunas que o objecto irá ocupar depois de formatado
static java.lang.String getDataTypeDescription(int dataType)
          Devolve uma string representativa do tipo de dados convertido de inteiro para string
static DataTypeInfo getDataTypeInfo(int type)
          Devolve informacao diversa sobre um tipo de dados
static java.lang.String[] getDataTypes()
          Devolve um array que contem strings com todos os tipos de dados suportados.
static java.lang.String getFormatedNumber(int _dataType, java.lang.Object value, java.lang.String formato)
           
static java.lang.String getFormatedString(int _dataType, java.lang.Object value, java.lang.String formato)
          Devolve o valor enviado como string convertido para o objecto do tipo enviado como parametro
static java.lang.Object getObjectValue(int dataType, java.lang.String value, java.lang.String datePattern)
          Deprecated. Use method getObject(int, String, String, String) insted.
static java.lang.Object getObjectValue(int dataType, java.lang.String value, java.lang.String datePattern, java.lang.String numberPattern)
          Converts a String value into a more specific Object.
static long getSqlChars(int _dataType)
          Devolve o valor enviado para o maxValue do DDataField
static int getSqlDataType(java.lang.String strDataType)
          Devolve o identificador unico (inteiro) do tipo de dados a partir da string
static java.lang.String makeFormat(int type)
           
static java.lang.String makeFormat(int type, boolean separador)
           
static java.lang.String numberMask(int _nd, boolean separador)
           
static void validateObjectType(int _dataType, java.lang.Object value)
          Valida se o tipo de objecto enviado e compativel com o tipo de dados que se pensa estar a gerir
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BIT

public static final int BIT

The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type BIT.

See Also:
Constant Field Values

TINYINT

public static final int TINYINT

The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type TINYINT.

See Also:
Constant Field Values

SMALLINT

public static final int SMALLINT

The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type SMALLINT.

See Also:
Constant Field Values

INTEGER

public static final int INTEGER

The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type INTEGER.

See Also:
Constant Field Values

BIGINT

public static final int BIGINT

The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type BIGINT.

See Also:
Constant Field Values

FLOAT

public static final int FLOAT

The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type FLOAT.

See Also:
Constant Field Values

REAL

public static final int REAL

The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type REAL.

See Also:
Constant Field Values

DOUBLE

public static final int DOUBLE

The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type DOUBLE.

See Also:
Constant Field Values

NUMERIC

public static final int NUMERIC

The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type NUMERIC.

See Also:
Constant Field Values

DECIMAL

public static final int DECIMAL

The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type DECIMAL.

See Also:
Constant Field Values

CHAR

public static final int CHAR

The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type CHAR.

See Also:
Constant Field Values

VARCHAR

public static final int VARCHAR

The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type VARCHAR.

See Also:
Constant Field Values

LONGVARCHAR

public static final int LONGVARCHAR

The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type LONGVARCHAR.

See Also:
Constant Field Values

DATE

public static final int DATE

The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type DATE.

See Also:
Constant Field Values

TIME

public static final int TIME

The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type TIME.

See Also:
Constant Field Values

TIMESTAMP

public static final int TIMESTAMP

The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type TIMESTAMP.

See Also:
Constant Field Values

BINARY

public static final int BINARY

The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type BINARY.

See Also:
Constant Field Values

VARBINARY

public static final int VARBINARY

The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type VARBINARY.

See Also:
Constant Field Values

LONGVARBINARY

public static final int LONGVARBINARY

The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type LONGVARBINARY.

See Also:
Constant Field Values

NULL

public static final int NULL

The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type NULL.

See Also:
Constant Field Values

OTHER

public static final int OTHER
The constant in the Java programming language that indicates that the SQL type is database-specific and gets mapped to a Java object that can be accessed via the methods getObject and setObject.

See Also:
Constant Field Values

JAVA_OBJECT

public static final int JAVA_OBJECT
The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type JAVA_OBJECT.

See Also:
Constant Field Values

DISTINCT

public static final int DISTINCT
The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type DISTINCT.

See Also:
Constant Field Values

STRUCT

public static final int STRUCT
The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type STRUCT.

See Also:
Constant Field Values

ARRAY

public static final int ARRAY
The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type ARRAY.

See Also:
Constant Field Values

BLOB

public static final int BLOB
The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type BLOB.

See Also:
Constant Field Values

CLOB

public static final int CLOB
The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type CLOB.

See Also:
Constant Field Values

REF

public static final int REF
The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type REF.

See Also:
Constant Field Values

DATALINK

public static final int DATALINK
The constant in the Java programming language, somtimes referred to as a type code, that identifies the generic SQL type DATALINK.

See Also:
Constant Field Values

BOOLEAN

public static final int BOOLEAN
The constant in the Java programming language, somtimes referred to as a type code, that identifies the generic SQL type BOOLEAN.

See Also:
Constant Field Values

IMAGE

public static final int IMAGE
The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type BLOB for a image.

See Also:
Constant Field Values
Method Detail

getSqlDataType

public static int getSqlDataType(java.lang.String strDataType)
                          throws java.lang.NullPointerException
Devolve o identificador unico (inteiro) do tipo de dados a partir da string

Parameters:
strDataType - nome do tipo de dados
Returns:
inteiro associado ao tipo de dados ??? Isto devia ser feito com outras estruturas de dados como uma Hash e a string deve ser convertida para minusculas antes de ir fazer a procura
Throws:
java.lang.NullPointerException - Se a string for nula.
java.lang.IllegalArgumentException - Se a string nao representar nenhum tipo de dados.

getDataTypeDescription

public static java.lang.String getDataTypeDescription(int dataType)
                                               throws java.lang.IllegalArgumentException
Devolve uma string representativa do tipo de dados convertido de inteiro para string

Parameters:
dataType - inteiro associado ao tipo de dados
Returns:
nome do tipo de dados
Throws:
java.lang.IllegalArgumentException

getDataTypes

public static java.lang.String[] getDataTypes()
Devolve um array que contem strings com todos os tipos de dados suportados.

Returns:
array com os tipos de dados suportados

getDataTypeInfo

public static DataTypeInfo getDataTypeInfo(int type)
Devolve informacao diversa sobre um tipo de dados

Parameters:
type - tipo de dados a procurar
Returns:
array de strings com a informacao associada ao tipo de dados

getObjectValue

public static java.lang.Object getObjectValue(int dataType,
                                              java.lang.String value,
                                              java.lang.String datePattern)
                                       throws java.text.ParseException,
                                              java.lang.NumberFormatException
Deprecated. Use method getObject(int, String, String, String) insted.

Converts a String value into a more specific Object. The following table show the dataTypes and the correspondig Java Objects that will be created:
Data Type Returned Object
TINYINT
SMALLINT
INTEGER
java.lang.Integer
BIGINT java.lang.Long
REAL java.lang.Float
FLOAT
DOUBLE
java.lang.Double
NUMERIC
DECIMAL
java.math.BigDecimal
DATE java.util.Date
TIME java.util.Time
TIMESTAMP java.util.TimeStamp
CHAR
VARCHAR
LONGVARCHAR
CLOB
the same java.lang.String
BINARY
VARBINARY
LONGVARBINARY
BLOB
IMAGE
the same java.lang.String
BIT
BOOLEAN
java.lang.Boolean
DATALINK java.net.URL
NULL null
OTHER
STRUCT
ARRAY
REF
JAVA_OBJECT
DISTINCT
the same java.lang.String

Parameters:
dataType - The Object type to be created.
value - The String value.
datePattern - A pattern to be used with SimpleDateFormat. this is for parsing dates only. If is null no pattern will be used
Returns:
An object compatible with the dataType sepcified with the value represented by the String value. If the dataType is a CHAR or a similar type, the same String is return.
Throws:
java.lang.NumberFormatException - if the String does not contain a parsable number.
ParseEception - if the String cannot be parsed.
java.text.ParseException

getObjectValue

public static java.lang.Object getObjectValue(int dataType,
                                              java.lang.String value,
                                              java.lang.String datePattern,
                                              java.lang.String numberPattern)
                                       throws java.text.ParseException,
                                              java.lang.NumberFormatException
Converts a String value into a more specific Object. The following table show the dataTypes and the correspondig Java Objects that will be created:
Data Type Returned Object
TINYINT
SMALLINT
INTEGER
java.lang.Integer
BIGINT java.lang.Long
REAL java.lang.Float
FLOAT
DOUBLE
java.lang.Double
NUMERIC
DECIMAL
java.math.BigDecimal
DATE java.util.Date
TIME java.util.Time
TIMESTAMP java.util.TimeStamp
CHAR
VARCHAR
LONGVARCHAR
CLOB
the same java.lang.String
BINARY
VARBINARY
LONGVARBINARY
BLOB
IMAGE
the same java.lang.String
BIT
BOOLEAN
java.lang.Boolean
DATALINK java.net.URL
NULL null
OTHER
STRUCT
ARRAY
REF
JAVA_OBJECT
DISTINCT
the same java.lang.String

Parameters:
dataType - The Object type to be created.
value - The String value.
datePattern - A pattern to be used with SimpleDateFormat. this is for parsing dates only. If is null no pattern will be used
numberPattern - A pattern to be used with DecimalFormat. this is for parsing numbers only. If is null no pattern will be used
Returns:
An object compatible with the dataType sepcified with the value represented by the String value. If the dataType is a CHAR or a similar type, the same String is return.
Throws:
java.lang.NumberFormatException - if the String does not contain a parsable number.
ParseEception - if the String cannot be parsed.
java.text.ParseException

validateObjectType

public static void validateObjectType(int _dataType,
                                      java.lang.Object value)
Valida se o tipo de objecto enviado e compativel com o tipo de dados que se pensa estar a gerir


getFormatedNumber

public static java.lang.String getFormatedNumber(int _dataType,
                                                 java.lang.Object value,
                                                 java.lang.String formato)

getFormatedString

public static java.lang.String getFormatedString(int _dataType,
                                                 java.lang.Object value,
                                                 java.lang.String formato)
Devolve o valor enviado como string convertido para o objecto do tipo enviado como parametro


getSqlChars

public static long getSqlChars(int _dataType)
                        throws java.lang.IllegalArgumentException
Devolve o valor enviado para o maxValue do DDataField

Throws:
java.lang.IllegalArgumentException

makeFormat

public static java.lang.String makeFormat(int type)

makeFormat

public static java.lang.String makeFormat(int type,
                                          boolean separador)

numberMask

public static java.lang.String numberMask(int _nd,
                                          boolean separador)

getColLength

public static int getColLength(int _dataType,
                               java.lang.Object _object,
                               java.lang.String _format)
Retorna o número de colunas que o objecto irá ocupar depois de formatado

Parameters:
_dataType - Tipo de Dados do Objecto
_object - Objecto que deseja formatar
_format - Formato segundo o qual o Objectop vai ser formatado
Returns:
int Número de Colunas ocupadas

getColLength

public static int getColLength(int _dataType,
                               int _tamanho,
                               java.lang.String _format)
Retorna o número de colunas que o objecto irá ocupar depois de formatado

Parameters:
_dataType - Tipo de Dados do Objecto
_tamanho - Tamanho do Objecto que deseja formatar
_format - Formato segundo o qual o Objectop vai ser formatado
Returns:
int Número de Colunas ocupadas

getColLength

public static int getColLength(java.lang.String _dataType,
                               int _tamanho,
                               java.lang.String _format)
Retorna o número de colunas que o objecto irá ocupar depois de formatado

Parameters:
_dataType - Tipo de Dados do Objecto em String
_tamanho - Tamanho do Objecto que deseja formatar
_format - Formato segundo o qual o Objecto vai ser formatado
Returns:
O número de Colunas ocupadas.