Re: cayenne/src/cayenne/java/org/objectstyle/cayenne/tools CayenneGenerator.java,1.20,1.21

From: Erik Hatcher (eri..hatchersolutions.com)
Date: Fri May 13 2005 - 15:41:38 EDT

  • Next message: Mike Kienenberger: "Re: cayenne/src/cayenne/java/org/objectstyle/cayenne/tools CayenneGenerator.java,1.20,1.21"

    Mike,

    On May 13, 2005, at 3:32 PM, Mike Kienenberger wrote:
    > /**
    > + * Sets <code>version</code> property.
    > + *
    > + *..ince 1.2
    > + */
    > + public void setVersion(String versionString) {
    > + generator.setVersionString(versionString);
    > + }
    > +
    > + /**

    Another cool Ant'ism, check out the EnumeratedAttribute trick, like
    the <echo> task has:

         /**
          * Set the logging level. Level should be one of
          * <ul>
          * <li>error</li>
          * <li>warning</li>
          * <li>info</li>
          * <li>verbose</li>
          * <li>debug</li>
          * </ul>
          * <p>The default is &quot;warning&quot; to ensure that messages
    are
          * displayed by default when using the -quiet command line
    option.</p>
          *..aram echoLevel the logging level
          */
         public void setLevel(EchoLevel echoLevel) {
             logLevel = echoLevel.getLevel();
         }

         /**
          * The enumerated values for the level attribute.
          */
         public static class EchoLevel extends EnumeratedAttribute {
             /**
              *..ee EnumeratedAttribute#getValues
              *..eturn the strings allowed for the level attribute
              */
             public String[] getValues() {
                 return new String[] {
                     "error",
                     "warning",
                     "info",
                     "verbose",
                     "debug"};
             }

             /**
              * mapping of enumerated values to log levels
              */
             private static int[] levels = {
                 Project.MSG_ERR,
                 Project.MSG_WARN,
                 Project.MSG_INFO,
                 Project.MSG_VERBOSE,
                 Project.MSG_DEBUG
             };

             /**
              * get the level of the echo of the current value
              *..eturn the level
              */
             public int getLevel() {
                 return levels[getIndex()];
             }
         }

    It allows you to have the String values in one place, and then more
    rigidly typed than as String's.

    Just food for thought.

         Erik



    This archive was generated by hypermail 2.0.0 : Fri May 13 2005 - 15:42:14 EDT