Package org.apache.torque.templates.transformer.om

## Class OMColumnJavaTransformer

- java.lang.Object
- - org.apache.torque.templates.transformer.om.OMColumnJavaTransformer

-     public class OMColumnJavaTransformer
      extends Object

  Does java related mappings.

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `OMColumnJavaTransformer()` |

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method | 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.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### OMColumnJavaTransformer

          public OMColumnJavaTransformer()

  - ### Method Detail

    - #### setJavaTypeAttribute

          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.
      Parameters:
        `columnElement` - the column element, not null.

    - #### setJavaNameAttribute

          protected void setJavaNameAttribute​(SourceElement columnElement)

      Sets the javaName attribute of the column element if it is not already set.
      Parameters:
        `columnElement` - the column element, not null.

    - #### setFieldNameAttribute

          protected void setFieldNameAttribute​(SourceElement columnElement)

      Sets the fieldName attribute of the column element if it is not already set. The javaName attribute of the column must be set.
      Parameters:
        `columnElement` - the column element, not null.

    - #### getDefaultValueWithDefaultSet

          protected String getDefaultValueWithDefaultSet​(JavaType javaType,
                                                         String defaultValue,
                                                         boolean useDatabaseDefaultValue,
                                                         SourceElement columnElement)
                                                  throws SourceTransformerException

      Calculates the java default value of a column in case a default value is set.
      Parameters:
        `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.
      Returns:
        The java default value.
      Throws:
        `SourceTransformerException` - if an illegal default value is used.

    - #### getDefaultValueAsDate

          public static Date getDefaultValueAsDate​(String defaultValue)
                                            throws SourceTransformerException

      Parses the default value String as Date.
      Parameters:
        `defaultValue` - the String to parse.
      Returns:
        the parsed date.
      Throws:
        `SourceTransformerException` - if the date cannot be parsed.

    - #### getDefaultValueWithoutDefaultSet

          protected String getDefaultValueWithoutDefaultSet​(JavaType javaType)
                                                     throws SourceTransformerException

      Calculates the java default value of a column in case a default value is not set.
      Parameters:
        `javaType` - The java type of the column.
      Returns:
        The java default value.
      Throws:
        `SourceTransformerException` - if the value cannot be found

    - #### setFieldJavaType

          protected JavaType setFieldJavaType​(SourceElement columnElement,
                                              SchemaType schemaType,
                                              String enumClassName)
                                       throws SourceTransformerException

      Returns the java type of the field representing a database column.
      Parameters:
        `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.
      Returns:
        the java type of the column
      Throws:
        `SourceTransformerException` - if error in transform

    - #### setEnumAttributes

          public 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. 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.
      Parameters:
        `columnElement` - the column element to set the elements in, not null.
        `controllerState` - the controller state, not null.
      Returns:
        the class name of the enum, or null if the column is not an enum column.

    - #### setEnumValueJavaNameAttribute

          protected void setEnumValueJavaNameAttribute​(SourceElement enumValueElement)
                                                throws SourceTransformerException

      Throws:
        `SourceTransformerException`

    - #### setEnumValueJavaValueAttribute

          protected void setEnumValueJavaValueAttribute​(SourceElement enumValueElement,
                                                        JavaType columnJavaType)
                                                 throws SourceTransformerException

      Throws:
        `SourceTransformerException`