class generator not substituting formatVariableName correctly with custom supertemplate

From: Mike Kienenberger (mkienen..laska.net)
Date: Mon Sep 08 2003 - 20:31:02 EDT

  • Next message: Mike Kienenberger: "[SOLVED] (but not understood) class generator not substituting formatVariableName correctly with custom supertemplate"

    I've taken and extracted superclass.vm from cayenne.jar as my "Custom"
    superclass.vm.
    I'm using an unmodified version of superclass.vm, yet class generator is not
    substituting correctly with the custom supertemplate. The
    $classGen.formatVariableName() won't parse! If I replace formatVariableName
    with formatJavaType, it parses as through formatJavaType. Weird!

    jdk 1.4.2 in Eclipse 2.1.1 with ant 1.5.3 on w2k. cayenne-1.0rc2, of
    course.

    -Mike

    My ant configuration:
    ====================
        <!-- classpath for cayenne class generator -->
        <path id="generate.classpath">
            <pathelement path ="E:\java\cayenne-1.0rc2\lib\cayenne.jar"/>
        </path>

        <!-- Rebuild classes dependent on database model -->
        <target name="generate">
                    <taskdef name="cgen"
    classname="org.objectstyle.cayenne.tools.CayenneGenerator">
                         <classpath refid="generate.classpath"/>
                    </taskdef>
                    <cgen map="E:/Programming/Ebpp-struts/WEB-INF/OnlineBilling.map.xml"
                          destDir="E:/Programming/Ebpp-struts/WEB-INF/src"
                          makepairs="true"
                          template
    ="E:/Programming/Ebpp-struts/WEB-INF/src/support/ModelerTemplates/subclass.vm"
                          
    supertemplate="E:/Programming/Ebpp-struts/WEB-INF/src/support/ModelerTemplates/superclass.vm"
                          superpkg="com.gvea.cayenne.ebpp.entity.generated"
                          usepkgpath="true"/>
        </target>
    ====================

    Output with no supertemplate ant parameter:
    ====================
        public void setAccountCheckDigit(Integer accountCheckDigit) {
            writeProperty("accountCheckDigit", accountCheckDigit);
        }
        public Integer getAccountCheckDigit() {
            return (Integer)readProperty("accountCheckDigit");
        }
    ====================

    Output from "Custom" template (which is just the cayenne.jar
    dotemplate/superclass.vm template extracted)
    ====================
        public void setAccountCheckDigit(Integer
    $classGen.formatVariableName(${attr.Name})) {
            writeProperty("accountCheckDigit",
    $classGen.formatVariableName(${attr.Name}));
        }
        public Integer getAccountCheckDigit() {
            return (Integer)readProperty("accountCheckDigit");
        }
    ====================

    Contents of "Custom" superclass.vm so you can see that I didn't mess with
    it:
    ====================
    ## Create attribute set/get methods
    #foreach( $attr in ${classGen.Entity.Attributes} )
    #set( $classGen.Prop = $attr.Name )## let controller know about current
    property
        public void
    set${classGen.cappedProp}($classGen.formatJavaType(${attr.Type})
    $classGen.formatVariableName(${attr.Name})) {
            writeProperty("${attr.Name}",
    $classGen.formatVariableName(${attr.Name}));
        }
        public $classGen.formatJavaType(${attr.Type})
    get${classGen.cappedProp}() {
            return
    ($classGen.formatJavaType(${attr.Type}))readProperty("${attr.Name}");
        }
        
        
    #end
    ====================



    This archive was generated by hypermail 2.0.0 : Mon Sep 08 2003 - 20:28:21 EDT