org.sql.generation.api.grammar.factories
Interface DataTypeFactory

All Known Subinterfaces:
PgSQLDataTypeFactory

public interface DataTypeFactory

This is factory for creating SQL data types. Typically required when defining tables.

Author:
Stanislav Muhametsin
See Also:
TableDefinition

Method Summary
 BigInt bigInt()
          Creates data type representing BIGINT.
 SQLDate date()
          Creates a DATE type.
 SQLInterval dayTimeInterval(IntervalDataType startField, Integer startFieldPrecision, IntervalDataType endField, Integer secondFracs)
          Creates a new day-time INTERVAL.
 Decimal decimal()
           Creates plain DECIMAL type.
 Decimal decimal(Integer precision)
           Creates DECIMAL(p) type, where p is given precision.
 Decimal decimal(Integer precision, Integer scale)
           Creates DECIMAL(p,s) type, where p is given precision, and s is given scale.
 DoublePrecision doublePrecision()
          Creates data type representing DOUBLE PRECISION.
 SQLInteger integer()
          Creates new instance of INTEGER type.
 Numeric numeric()
           Creates plain NUMERIC type.
 Numeric numeric(Integer precision)
           Creates NUMERIC(p) type, where p is given precision.
 Numeric numeric(Integer precision, Integer scale)
           Creates NUMERIC(p,s) type, where p is given precision, and s is given scale.
 Real real()
          Creates data type representing REAL.
 SmallInt smallInt()
          Creates data type representing SMALLINT.
 SQLBoolean sqlBoolean()
          Creates data type representing BOOLEAN.
 SQLChar sqlChar()
          Creates a new CHARACTER type.
 SQLChar sqlChar(Integer length)
          Creates a new CHARACTER type.
 SQLFloat sqlFloat()
          Creates new instance of FLOAT type.
 SQLFloat sqlFloat(Integer precision)
          Creates new instance of FLOAT type.
 SQLChar sqlVarChar()
          Creates a new CHARACTER VARYING type.
 SQLChar sqlVarChar(Integer length)
          Creates a new CHARACTER VARYING type.
 SQLTime time()
          Creates TIME type with unspecified precision and unspecified value for including time zone.
 SQLTime time(Boolean withTimeZone)
          Creates TIME type with unspecified precision and given value for including time zone.
 SQLTime time(Integer precision)
          Creates TIME type with given precision and unspecified value for including time zone.
 SQLTime time(Integer precision, Boolean withTimeZone)
          Creates TIME type with given precision and whether to include time zone.
 SQLTimeStamp timeStamp()
          Creates TIMESTAMP type with unspecified precision and unspecified value for including time zone.
 SQLTimeStamp timeStamp(Boolean withTimeZone)
          Creates TIMESTAMP type with unspecified precision and given value for including time zone.
 SQLTimeStamp timeStamp(Integer precision)
          Creates TIMESTAMP type with given precision and unspecified value for including time zone.
 SQLTimeStamp timeStamp(Integer precision, Boolean withTimeZone)
          Creates TIMESTAMP type with given precision and whether to include time zone.
 UserDefinedType userDefined(String textualContent)
          Creates a user-defined type which will be inserted into SQL statement as-such.
 SQLInterval yearMonthInterval(IntervalDataType startField, Integer startFieldPrecision, IntervalDataType endField)
          Creates a new year-month INTERVAL.
 

Method Detail

bigInt

BigInt bigInt()
Creates data type representing BIGINT.

Returns:
Data type representing BIGINT.

decimal

Decimal decimal()

Creates plain DECIMAL type. Calling this method is equivalent to calling decimal(Integer, Integer) and passing null as both parameters.

The site http://intelligent-enterprise.informationweek.com/000626/celko.jhtml explains difference between NUMERIC and DECIMAL:
The difference between DECIMAL(s,p) and NUMERIC(s,p) is subtle in the SQL-92 Standard -- DECIMAL(s,p) must be exactly as precise as declared, while NUMERIC(s,p) must be at least as precise as declared.

Returns:
The new DECIMAL type.

decimal

Decimal decimal(Integer precision)

Creates DECIMAL(p) type, where p is given precision. Calling this method is equivalent to calling decimal(Integer, Integer) and passing null as second parameter.

The site http://intelligent-enterprise.informationweek.com/000626/celko.jhtml explains difference between NUMERIC and DECIMAL:
The difference between DECIMAL(s,p) and NUMERIC(s,p) is subtle in the SQL-92 Standard -- DECIMAL(s,p) must be exactly as precise as declared, while NUMERIC(s,p) must be at least as precise as declared.

Parameters:
precision - The precision for this DECIMAL. May be null to create plain DECIMAL type.
Returns:
The new DECIMAL type.

decimal

Decimal decimal(Integer precision,
                Integer scale)

Creates DECIMAL(p,s) type, where p is given precision, and s is given scale.

The site http://intelligent-enterprise.informationweek.com/000626/celko.jhtml explains difference between NUMERIC and DECIMAL:
The difference between DECIMAL(s,p) and NUMERIC(s,p) is subtle in the SQL-92 Standard -- DECIMAL(s,p) must be exactly as precise as declared, while NUMERIC(s,p) must be at least as precise as declared.

Parameters:
precision - The precision for this DECIMAL. May be null to create plain DECIMAL.
scale - The scale for this DECIMAL. Is ignored if precision is null.
Returns:
The new DECIMAL type.

doublePrecision

DoublePrecision doublePrecision()
Creates data type representing DOUBLE PRECISION.

Returns:
Data type representing DOUBLE PRECISION.

numeric

Numeric numeric()

Creates plain NUMERIC type. Calling this method is equivalent to calling numeric(Integer, Integer) and passing null as both parameters.

The site http://intelligent-enterprise.informationweek.com/000626/celko.jhtml explains difference between NUMERIC and DECIMAL:
The difference between DECIMAL(s,p) and NUMERIC(s,p) is subtle in the SQL-92 Standard -- DECIMAL(s,p) must be exactly as precise as declared, while NUMERIC(s,p) must be at least as precise as declared.

Returns:
The new NUMERIC type.

numeric

Numeric numeric(Integer precision)

Creates NUMERIC(p) type, where p is given precision. Calling this method is equivalent to calling numeric(Integer, Integer) and passing null as second parameter.

The site http://intelligent-enterprise.informationweek.com/000626/celko.jhtml explains difference between NUMERIC and DECIMAL:
The difference between DECIMAL(s,p) and NUMERIC(s,p) is subtle in the SQL-92 Standard -- DECIMAL(s,p) must be exactly as precise as declared, while NUMERIC(s,p) must be at least as precise as declared.

Parameters:
precision - The precision for this NUMERIC. May be null to create plain NUMERIC type.
Returns:
The new NUMERIC type.

numeric

Numeric numeric(Integer precision,
                Integer scale)

Creates NUMERIC(p,s) type, where p is given precision, and s is given scale.

The site http://intelligent-enterprise.informationweek.com/000626/celko.jhtml explains difference between NUMERIC and DECIMAL:
The difference between DECIMAL(s,p) and NUMERIC(s,p) is subtle in the SQL-92 Standard -- DECIMAL(s,p) must be exactly as precise as declared, while NUMERIC(s,p) must be at least as precise as declared.

Parameters:
precision - The precision for this NUMERIC. May be null to create plain NUMERIC.
scale - The scale for this NUMERIC. Is ignored if precision is null.
Returns:
The new NUMERIC type.

real

Real real()
Creates data type representing REAL.

Returns:
Data type representing REAL.

smallInt

SmallInt smallInt()
Creates data type representing SMALLINT.

Returns:
Data type representing SMALLINT.

sqlBoolean

SQLBoolean sqlBoolean()
Creates data type representing BOOLEAN.

Returns:
Data type representing BOOLEAN.

sqlChar

SQLChar sqlChar()
Creates a new CHARACTER type. Calling this method is equivalent to calling sqlChar(Integer) and passing null as parameter.

Returns:
New CHARACTER type.

sqlChar

SQLChar sqlChar(Integer length)
Creates a new CHARACTER type.

Parameters:
length - The length for this CHARACTER. May be null.
Returns:
New CHARACTER type.

sqlVarChar

SQLChar sqlVarChar()
Creates a new CHARACTER VARYING type. Calling this method is equivalent to calling sqlVarChar(Integer) and passing null as parameter.

Returns:
New CHARACTER VARYING type.

sqlVarChar

SQLChar sqlVarChar(Integer length)
Creates a new CHARACTER VARYING type.

Parameters:
length - The length for this CHARACTER VARYING. May be null.
Returns:
New CHARACTER VARYING type.

date

SQLDate date()
Creates a DATE type.

Returns:
New DATE type.

sqlFloat

SQLFloat sqlFloat()
Creates new instance of FLOAT type. Calling this method is equivalent to calling sqlFloat(Integer) and passing null as argument.

Returns:
New FLOAt type.

sqlFloat

SQLFloat sqlFloat(Integer precision)
Creates new instance of FLOAT type.

Parameters:
precision - The precision for this FLOAT type. May be null.
Returns:
New FLOAT type.

integer

SQLInteger integer()
Creates new instance of INTEGER type.

Returns:
New INTEGER type.

yearMonthInterval

SQLInterval yearMonthInterval(IntervalDataType startField,
                              Integer startFieldPrecision,
                              IntervalDataType endField)
Creates a new year-month INTERVAL.

Parameters:
startField - The type of start field for this INTERVAL. Must be either IntervalDataType.YEAR or IntervalDataType.MONTH.
startFieldPrecision - The precision for the start field. May be null if none specified.
endField - The type of end field for this INTERVAL. May be null for single date interval. If it is not null, must be either IntervalDataType.YEAR or IntervalDataType.MONTH .
Returns:
The new INTERVAL with specified values.
Throws:
NullArgumentException - If startField is null.
IllegalArgumentException - If requirements for startField or endField fail.

dayTimeInterval

SQLInterval dayTimeInterval(IntervalDataType startField,
                            Integer startFieldPrecision,
                            IntervalDataType endField,
                            Integer secondFracs)
Creates a new day-time INTERVAL.

Parameters:
startField - The type of start field for this INTERVAL. Must not be IntervalDataType.YEAR nor IntervalDataType.MONTH.
startFieldPrecision - The precision for the start field. May null if none specified.
endField - The type of end field for this INTERVAL. May be null for single day-time interval. If it is not null, it must not be IntervalDataType.YEAR nor IntervalDataType.MONTH.
secondFracs - The fractional precision for when end field is IntervalDataType.SECOND or when this is single day-time interval and start field is IntervalDataType.SECOND. Otherwise this value is ignored.
Returns:
The new INTERVAL.
Throws:
NullArgumentException - If startField is null.
IllegalArgumentException - If requirements for startField or endField fail, or if when using single day-time interval with type IntervalDataType.SECOND, and secondFracs is specified, but startFieldPrecision is not specified.

time

SQLTime time()
Creates TIME type with unspecified precision and unspecified value for including time zone. Calling this method is equivalent to calling time(Integer, Boolean) and pass null as both parameters.

Returns:
TIME type without precision and unspecified value for including time zone.

time

SQLTime time(Integer precision)
Creates TIME type with given precision and unspecified value for including time zone. Calling this method is equivalent to calling time(Integer, Boolean) and pass null as second parameter.

Parameters:
precision - The precision for TIME. May be null.
Returns:
TIME type with given precision and unspecified value for including time zone.

time

SQLTime time(Boolean withTimeZone)
Creates TIME type with unspecified precision and given value for including time zone. Calling this method is equivalent to calling time(Integer, Boolean) and pass null as first parameter.

Parameters:
withTimeZone - Whether to include time zone. May be null if no decision is wanted.
Returns:
TIME type with unspecified precision and given value for including time zone.

time

SQLTime time(Integer precision,
             Boolean withTimeZone)
Creates TIME type with given precision and whether to include time zone.

Parameters:
precision - The precision for TIME. May be null.
withTimeZone - Whether to include time zone. May be null if no decision is wanted.
Returns:
TIME type with given precision and whether to include time zone.

timeStamp

SQLTimeStamp timeStamp()
Creates TIMESTAMP type with unspecified precision and unspecified value for including time zone. Calling this method is equivalent to calling timeStamp(Integer, Boolean) and pass null as both parameters.

Returns:
TIMESTAMP type without precision and unspecified value for including time zone.

timeStamp

SQLTimeStamp timeStamp(Integer precision)
Creates TIMESTAMP type with given precision and unspecified value for including time zone. Calling this method is equivalent to calling timeStamp(Integer, Boolean) and pass null as second parameter.

Parameters:
precision - The precision for TIME. May be null.
Returns:
TIMESTAMP type with given precision and unspecified value for including time zone.

timeStamp

SQLTimeStamp timeStamp(Boolean withTimeZone)
Creates TIMESTAMP type with unspecified precision and given value for including time zone. Calling this method is equivalent to calling timeStamp(Integer, Boolean) and pass null as first parameter.

Parameters:
withTimeZone - Whether to include time zone. May be null if no decision is wanted.
Returns:
TIMESTAMP type with unspecified precision and given value for including time zone.

timeStamp

SQLTimeStamp timeStamp(Integer precision,
                       Boolean withTimeZone)
Creates TIMESTAMP type with given precision and whether to include time zone.

Parameters:
precision - The precision for TIMESTAMP. May be null.
withTimeZone - Whether to include time zone. May be null if no decision is wanted.
Returns:
TIMESTAMP type with given precision and whether to include time zone.

userDefined

UserDefinedType userDefined(String textualContent)
Creates a user-defined type which will be inserted into SQL statement as-such.

Parameters:
textualContent - The textual contents for user-defined type.
Returns:
Syntax element for user defined type.


Copyright © 2010-2012. All Rights Reserved.