domainType,
controllerState,
ObjectUtils.toString(size, null),
ObjectUtils.toString(scale, null),
ObjectUtils.toString(defaultValue, null));
Platform platform = getPlatform(controllerState);
List<String> resultList = new ArrayList<String>();
String sqlTypeName = sqlType.getSqlTypeName();
if (platform.hasSize(sqlTypeName))
{
sqlTypeName += sqlType.printSize(
platform.getSizeSuffix(sqlTypeName));
}
resultList.add(sqlTypeName);
if (StringUtils.isNotEmpty(sqlType.getDefaultValue()))
{
resultList.add("default");
if ((SchemaType.DATE == schemaType
|| SchemaType.TIME == schemaType
|| SchemaType.TIMESTAMP == schemaType))
{
if (sqlType.getDefaultValue().startsWith("CURRENT_"))
{
resultList.add(sqlType.getDefaultValue());
}
else
{
Date defaultDate
= OMColumnTransformer.getDefaultValueAsDate(
sqlType.getDefaultValue());
if (SchemaType.DATE == schemaType)
{
resultList.add(platform.getDateString(defaultDate));
}
else if (SchemaType.TIME == schemaType)
{
resultList.add(platform.getTimeString(defaultDate));
}
else
{
resultList.add(platform.getTimestampString(
defaultDate));
}
}
}
else if (TypeMap.isTextType(schemaType))
{
resultList.add(platform.quoteAndEscape(
sqlType.getDefaultValue()));
}
else
{
resultList.add(sqlType.getDefaultValue());
}
}
boolean primaryKey;
{
String primaryKeyString = (String) columnElement.getAttribute(
TorqueSchemaAttributeName.PRIMARY_KEY);
primaryKey = Boolean.parseBoolean(primaryKeyString);
}
boolean required;
{
String requiredString = (String) columnElement.getAttribute(
TorqueSchemaAttributeName.REQUIRED);
required = Boolean.parseBoolean(requiredString);
}
boolean isNotNull = primaryKey || required;
String isNotNullString = platform.getNullString(isNotNull);
if (platform.createNotNullBeforeAutoincrement()
&& StringUtils.isNotEmpty(isNotNullString))
{
resultList.add(isNotNullString);
}
// if idMethod was not set explicitly by the user,
// the transformTable() method sets the attribute from the
// defaultIdMethod of the database, so this always returns
// the id method
Object idMethod = columnElement.getParent().getAttribute(
TorqueSchemaAttributeName.ID_METHOD);
if (primaryKey
&& TorqueSchemaIdMethod.NATIVE.getName().equals(idMethod))
{
String autoIncrement = platform.getAutoIncrement();
if (StringUtils.isNotEmpty(autoIncrement))
{
resultList.add(autoIncrement);
}
}
if (!platform.createNotNullBeforeAutoincrement()
&& StringUtils.isNotEmpty(isNotNullString))
{
resultList.add(isNotNullString);
}
return StringUtils.join(resultList.iterator(), ' ');