public class OMColumnJavaTransformer extends Object
Constructor and Description |
---|
OMColumnJavaTransformer() |
Modifier and Type | Method and Description |
---|---|
static Date |
getDefaultValueAsDate(String defaultValue)
Parses the default value String as Date.
|
protected String |
getDefaultValueWithDefaultSet(JavaType javaType,
String defaultValue,
boolean useDatabaseDefaultValue,
SourceElement columnElement)
Calculates the java default value of a column in case a default value
is set.
|
protected String |
getDefaultValueWithoutDefaultSet(JavaType javaType)
Calculates the java default value of a column in case a default value
is not set.
|
static String |
setEnumAttributes(SourceElement columnElement,
ControllerState controllerState)
Sets the enumClassName, enumPackage and generateEnum Attributes
if either enumValue child elements (xml element
enum-value ) are present or the enumType
attribute is set on the column. |
protected void |
setEnumValueJavaNameAttribute(SourceElement enumValueElement) |
protected void |
setEnumValueJavaValueAttribute(SourceElement enumValueElement,
JavaType columnJavaType) |
protected JavaType |
setFieldJavaType(SourceElement columnElement,
SchemaType schemaType,
String enumClassName)
Returns the java type of the field representing a database column.
|
protected void |
setFieldNameAttribute(SourceElement columnElement)
Sets the fieldName attribute of the column element if it is not
already set.
|
protected void |
setJavaNameAttribute(SourceElement columnElement)
Sets the javaName attribute of the column element if it is not
already set.
|
protected void |
setJavaTypeAttribute(SourceElement columnElement)
Sets the javaType attribute of the column element
if it is not already set and a default value is set.
|
protected void setJavaTypeAttribute(SourceElement columnElement)
columnElement
- the column element, not null.protected void setJavaNameAttribute(SourceElement columnElement)
columnElement
- the column element, not null.protected void setFieldNameAttribute(SourceElement columnElement)
columnElement
- the column element, not null.protected String getDefaultValueWithDefaultSet(JavaType javaType, String defaultValue, boolean useDatabaseDefaultValue, SourceElement columnElement) throws SourceTransformerException
javaType
- The java type of the column.defaultValue
- The default value from the schema.useDatabaseDefaultValue
- whether the database default value should
be used.columnElement
- the current column element for which
the default value should be calculated.SourceTransformerException
- if an illegal default value is used.public static Date getDefaultValueAsDate(String defaultValue) throws SourceTransformerException
defaultValue
- the String to parse.SourceTransformerException
- if the date cannot be parsed.protected String getDefaultValueWithoutDefaultSet(JavaType javaType) throws SourceTransformerException
javaType
- The java type of the column.SourceTransformerException
- if the value cannot be foundprotected JavaType setFieldJavaType(SourceElement columnElement, SchemaType schemaType, String enumClassName) throws SourceTransformerException
columnElement
- the column element, not null.schemaType
- the schema type, not null.enumClassName
- the class name of the enum, or null if the column is not an enum.SourceTransformerException
- if error in transformpublic static String setEnumAttributes(SourceElement columnElement, ControllerState controllerState)
enum-value
) are present or the enumType
attribute is set on the column.
Afterwards, the enumClassName attribute contains the unqualified name
of the enum, the enumPackage attribute contains the enum package,
and the generateEnum attribute contains "true" if the enum needs
to be generated.
This requires that the javaName attribute is set on the column
and that the dbObjectPackage element is set on the table.columnElement
- the column element to set the elements in, not null.controllerState
- the controller state, not null.protected void setEnumValueJavaNameAttribute(SourceElement enumValueElement) throws SourceTransformerException
SourceTransformerException
protected void setEnumValueJavaValueAttribute(SourceElement enumValueElement, JavaType columnJavaType) throws SourceTransformerException
SourceTransformerException
Copyright © 2000–2020 The Apache Software Foundation. All rights reserved.