Re: cgen class/package attributes

From: Mike Kienenberger (mkienen..laska.net)
Date: Fri May 13 2005 - 10:30:09 EDT

  • Next message: Mike Kienenberger: "Re: namespace for new templates"

    > Andrus Adamchik <andru..bjectstyle.org> wrote:
    > > could you post some examples of what variables you'd have
    > > in the context of a superclass and subclass template?

    Terminology:
            Base class - super superclass of entity, ie,
    org.objectstyle.cayenne.CayenneDataObject or MyBaseClass
        Super class - super-class of entity, ie,
    org.objectstyle.cayenne.art.auto._Artist
            Sub class - class of entity, ie, org.objectstyle.cayenne.art.Artist

    This is what I'm currently planning to have in the context by default.

    objEntity - the ObjEntity class.
    stringUtils - class for string "helper" functions
    entityUtils - class for entity "helper" functions.
    importUtils - class for import statement management. (not written yet)

    stringUtils contains:

        public String formatVariableName(String variableName) - mangles name to
    remove conflict with reserved keywords
        public String stripPackageName(String aString) - removes the package
    name from a fully-qualified class
        public String stripClass(String aString) - removes the class, leaving
    the package name from a fully-qualified class
        public String capitalized(String name) - uppercases first letter.
        public static String uncapitalized(String aString) - lowercases first
    letter
        public String capitalizedAsConstant(String name) - changes aJavaVar into
    A_JAVA_VAR (better name needed? also in cayenne source as JavaToUnderscored
    which makes more sense to me)

    entityUtils contains:

        public String getSubClassName() - Returns class name (w/o package) of
    the sub class public String getSuperClassName() - Returns the super class
    (w/o package) of the data object class
        public String getBaseClassName() - Returns the base class (w/o package)
    of the data object class

    ----------->I'm now thinking that entityUtils.getSuperPrefix() is
    unnecessary and should be removed.
        public String getSuperPrefix() - Returns prefix used to distinguish
    between superclass and subclass when generating classes in pairs.
        
        public String getSubPackageName() - Returns Java package name of the
    subclass
        public String getSuperPackageName() - Returns superPackageName property
    that defines the superclass's package name.
        public String getBasePackageName() - Returns basePackageName property
    that defines the baseclass's package name.

    -----------> Not sure about the use case for the following yet.
        public boolean isUsingBasePackage() - Returns true if the superclass
    class is located in a package.
        public boolean isUsingSuperPackage() - Returns true if the superclass
    class is located in a package.
        public boolean isUsingSubPackage() - Returns true if the subclass is
    located in a package.

        public boolean hasToManyRelationships() - Returns true if current entity
    contains at least one toMany relationship.
        public boolean hasToOneRelationships() - Returns true if current entity
    contains at least one toOne relationship.

    importUtils might contains:

            public void add() -- register a java type needed by this template
            public void generate() -- output all registered java type import
    statements.
            public string formatJavaType(String type) -- output type without package
    name if registered or leave unchanged otherwise



    This archive was generated by hypermail 2.0.0 : Fri May 13 2005 - 10:28:13 EDT