org.sandev.generator
Class DefaultSQLStructMapper

java.lang.Object
  extended byorg.sandev.generator.DefaultSQLStructMapper
All Implemented Interfaces:
StructMapper
Direct Known Subclasses:
HSQLDBStructMapper, MySQLStructMapper, PostgreSQLStructMapper

public class DefaultSQLStructMapper
extends java.lang.Object
implements StructMapper

A default StructMapper with minimal tranformations, for mapping to relational database tables. This is provided as an example, and as a default for relational storage when no mapping is specified.


Constructor Summary
DefaultSQLStructMapper()
           
 
Method Summary
 java.lang.String getMappedFieldName(com.sun.javadoc.ClassDoc struct, com.sun.javadoc.FieldDoc field)
          Use the field name as the table column name.
 java.lang.String getMappedFieldRelation(com.sun.javadoc.ClassDoc struct, com.sun.javadoc.FieldDoc field)
          An array relation is the parent struct name, followed by an underscore, followed by the field name.
 java.lang.String getMappedFieldRelationChild(com.sun.javadoc.ClassDoc struct, com.sun.javadoc.FieldDoc field)
          In an array relation, the child object column is named child.
 java.lang.String getMappedFieldRelationIndex(com.sun.javadoc.ClassDoc struct, com.sun.javadoc.FieldDoc field)
          In an array relation, the ordering column would be called index, except that tends to be a reserved word, so its called aindex.
 java.lang.String getMappedFieldRelationParent(com.sun.javadoc.ClassDoc struct, com.sun.javadoc.FieldDoc field)
          In an array relation, the parent object column is named parent.
 java.lang.String getMappedFieldType(com.sun.javadoc.ClassDoc struct, com.sun.javadoc.FieldDoc field)
          Return the corresponding type for the field.
 java.lang.String getMappedStructName(com.sun.javadoc.ClassDoc struct)
          Use the base struct name as the name of the table.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultSQLStructMapper

public DefaultSQLStructMapper()
Method Detail

getMappedStructName

public java.lang.String getMappedStructName(com.sun.javadoc.ClassDoc struct)
Use the base struct name as the name of the table.

Specified by:
getMappedStructName in interface StructMapper

getMappedFieldName

public java.lang.String getMappedFieldName(com.sun.javadoc.ClassDoc struct,
                                           com.sun.javadoc.FieldDoc field)
Use the field name as the table column name.

Specified by:
getMappedFieldName in interface StructMapper

getMappedFieldType

public java.lang.String getMappedFieldType(com.sun.javadoc.ClassDoc struct,
                                           com.sun.javadoc.FieldDoc field)
Return the corresponding type for the field.

Specified by:
getMappedFieldType in interface StructMapper

getMappedFieldRelation

public java.lang.String getMappedFieldRelation(com.sun.javadoc.ClassDoc struct,
                                               com.sun.javadoc.FieldDoc field)
An array relation is the parent struct name, followed by an underscore, followed by the field name.

Specified by:
getMappedFieldRelation in interface StructMapper

getMappedFieldRelationParent

public java.lang.String getMappedFieldRelationParent(com.sun.javadoc.ClassDoc struct,
                                                     com.sun.javadoc.FieldDoc field)
In an array relation, the parent object column is named parent.

Specified by:
getMappedFieldRelationParent in interface StructMapper

getMappedFieldRelationChild

public java.lang.String getMappedFieldRelationChild(com.sun.javadoc.ClassDoc struct,
                                                    com.sun.javadoc.FieldDoc field)
In an array relation, the child object column is named child.

Specified by:
getMappedFieldRelationChild in interface StructMapper

getMappedFieldRelationIndex

public java.lang.String getMappedFieldRelationIndex(com.sun.javadoc.ClassDoc struct,
                                                    com.sun.javadoc.FieldDoc field)
In an array relation, the ordering column would be called index, except that tends to be a reserved word, so its called aindex. That requires converting any existing databases forward.

Specified by:
getMappedFieldRelationIndex in interface StructMapper