org.sandev.generator
Interface StructMapper

All Known Implementing Classes:
DefaultSQLStructMapper, HSQLDBStructMapper, MySQLStructMapper, PostgreSQLStructMapper

public interface StructMapper

Provides a mapping of struct names, field types and field names for use in generators for persistence, serialization, or transformation code. This is outside of the struct declaration itself, since a single struct may have several mappings. The use of methods allows for both ad hoc "lookup table" mapping, and/or "policy-based" programmatic mapping strategies.

The methods are declared with ClassDoc/FieldDoc parameters, so that the mapping process can leverage any declared metadata.

Sample use of a StructMapper:

The XYZMain deployment (for the XYZ application) wants to map a struct representation to database table with different name.

  1. define sand/apps/XYZ/build/generate/.../generator/MainSQLStructMapper as a StructMapper implementation
  2. in sand/deploy/XYZMain/build/build.xml, set the SQLStructMapper property to be the MainSQLStructMapper full class name.

During the build process, the specified mapper is passed into the database generators. You can use an analogous approach for your own generators.


Method Summary
 java.lang.String getMappedFieldName(com.sun.javadoc.ClassDoc struct, com.sun.javadoc.FieldDoc field)
          Returns the mapped name for the field.
 java.lang.String getMappedFieldRelation(com.sun.javadoc.ClassDoc struct, com.sun.javadoc.FieldDoc field)
          Returns the mapped name for the relationship between the struct and the reference array field values.
 java.lang.String getMappedFieldRelationChild(com.sun.javadoc.ClassDoc struct, com.sun.javadoc.FieldDoc field)
          In the relation between the struct and the reference array field values, return the name of the field representing the array field value.
 java.lang.String getMappedFieldRelationIndex(com.sun.javadoc.ClassDoc struct, com.sun.javadoc.FieldDoc field)
          In the relation between the struct and the reference array field values, return the name of the field representing the ordering information for the array values.
 java.lang.String getMappedFieldRelationParent(com.sun.javadoc.ClassDoc struct, com.sun.javadoc.FieldDoc field)
          In the relation between the struct and the reference array field values, return the name of the field representing the struct instance.
 java.lang.String getMappedFieldType(com.sun.javadoc.ClassDoc struct, com.sun.javadoc.FieldDoc field)
          Returns the mapped type for the field.
 java.lang.String getMappedStructName(com.sun.javadoc.ClassDoc struct)
          Returns the mapped name for the struct.
 

Method Detail

getMappedStructName

java.lang.String getMappedStructName(com.sun.javadoc.ClassDoc struct)
Returns the mapped name for the struct.


getMappedFieldName

java.lang.String getMappedFieldName(com.sun.javadoc.ClassDoc struct,
                                    com.sun.javadoc.FieldDoc field)
Returns the mapped name for the field.


getMappedFieldType

java.lang.String getMappedFieldType(com.sun.javadoc.ClassDoc struct,
                                    com.sun.javadoc.FieldDoc field)
Returns the mapped type for the field.


getMappedFieldRelation

java.lang.String getMappedFieldRelation(com.sun.javadoc.ClassDoc struct,
                                        com.sun.javadoc.FieldDoc field)
Returns the mapped name for the relationship between the struct and the reference array field values. In SQL terms, this is the relation that holds the parent/child values where the parent is the struct instance and the child is the reference array value. In serialization terms, this would be the marker for the start and end of the array values.


getMappedFieldRelationParent

java.lang.String getMappedFieldRelationParent(com.sun.javadoc.ClassDoc struct,
                                              com.sun.javadoc.FieldDoc field)
In the relation between the struct and the reference array field values, return the name of the field representing the struct instance. This would typically return something like "parent".


getMappedFieldRelationChild

java.lang.String getMappedFieldRelationChild(com.sun.javadoc.ClassDoc struct,
                                             com.sun.javadoc.FieldDoc field)
In the relation between the struct and the reference array field values, return the name of the field representing the array field value. This is typically return something like "child".


getMappedFieldRelationIndex

java.lang.String getMappedFieldRelationIndex(com.sun.javadoc.ClassDoc struct,
                                             com.sun.javadoc.FieldDoc field)
In the relation between the struct and the reference array field values, return the name of the field representing the ordering information for the array values. This would typically return something like "index".