Author: tfischer
Date: Sun Sep 12 20:16:39 2010
New Revision: 996381

URL: http://svn.apache.org/viewvc?rev=996381&view=rev
Log:
created an enum from target source attribute names and used an existing enum 
for source attribute names.

Added:
    
db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/InheritanceAttributeName.java
Modified:
    
db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/TorqueSchemaAttributeName.java
    
db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMInheritanceTransformer.java

Modified: 
db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/TorqueSchemaAttributeName.java
URL: 
http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/TorqueSchemaAttributeName.java?rev=996381&r1=996380&r2=996381&view=diff
==============================================================================
--- 
db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/TorqueSchemaAttributeName.java
 (original)
+++ 
db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/TorqueSchemaAttributeName.java
 Sun Sep 12 20:16:39 2010
@@ -79,7 +79,9 @@ public enum TorqueSchemaAttributeName im
     /** attribute scale. */
     SCALE("scale"),
     /** attribute filename. */
-    FILENAME("filename");
+    FILENAME("filename"),
+    /** attribute key */
+    KEY("key");
 
     /** The name of the attribute, not null. */
     private String name;

Added: 
db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/InheritanceAttributeName.java
URL: 
http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/InheritanceAttributeName.java?rev=996381&view=auto
==============================================================================
--- 
db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/InheritanceAttributeName.java
 (added)
+++ 
db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/InheritanceAttributeName.java
 Sun Sep 12 20:16:39 2010
@@ -0,0 +1,100 @@
+package org.apache.torque.templates.transformer.om;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.torque.generator.source.SourceAttributeName;
+
+/**
+ * Contains the attributes for a inheritance source element which are not
+ * defined in the Torque schema.
+ */
+public enum InheritanceAttributeName implements SourceAttributeName
+{
+    /**
+     * The name of the constant in the peer which contains the key
+     * for the processed inheritance class.
+     */
+    CLASSKEY_CONSTANT("classkeyConstant"),
+
+    /**
+     * The name of the constant in the peer which contains the name
+     * for the processed inheritance class.
+     */
+    CLASSNAME_CONSTANT("classnameConstant"),
+
+    /**
+     * The name of the constant in the peer which contains the class object
+     * for the processed inheritance class.
+     */
+    CLASS_CONSTANT("classConstant"),
+
+    /**
+     * The name of the class created from this inheritance element.
+     */
+    CLASS_NAME("className"),
+    /**
+     * The package of the class created from this inheritance element.
+     */
+    PACKAGE("package"),
+
+    /**
+     * The package of the bean class created from this inheritance element.
+     */
+    BEAN_PACKAGE("beanPackage"),
+
+    /**
+     * The base class of the bean class created from this inheritance element.
+     */
+    BEAN_EXTENDS("beanExtends"),
+
+    /**
+     * The class name of the bean class created from this inheritance element.
+     */
+    BEAN_CLASS_NAME("beanClassName");
+
+    /** The name of the source element attribute, not null. */
+    private String name;
+
+    /**
+     * Constructor.
+     *
+     * @param name the name of the source element attribute, not null.
+     */
+    private InheritanceAttributeName(String name)
+    {
+        this.name = name;
+    }
+
+    /**
+     * Returns the name of the referenced source element attribute.
+     *
+     * @return the name of the referenced source element attribute.
+     */
+    public String getName()
+    {
+        return name;
+    }
+
+    @Override
+    public String toString()
+    {
+        return name;
+    }
+}

Modified: 
db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMInheritanceTransformer.java
URL: 
http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMInheritanceTransformer.java?rev=996381&r1=996380&r2=996381&view=diff
==============================================================================
--- 
db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMInheritanceTransformer.java
 (original)
+++ 
db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMInheritanceTransformer.java
 Sun Sep 12 20:16:39 2010
@@ -30,16 +30,6 @@ import org.apache.torque.templates.Torqu
  */
 public class OMInheritanceTransformer
 {
-    private static final String INPUT_KEY_ATTRIBUTE = "key";
-    private static final String CLASSKEY_CONSTANT_ATTRIBUTE = 
"classkeyConstant";
-    private static final String CLASSNAME_CONSTANT_ATTRIBUTE = 
"classnameConstant";
-    private static final String CLASS_CONSTANT_ATTRIBUTE = "classConstant";
-    private static final String CLASS_NAME_ATTRIBUTE = "className";
-    private static final String PACKAGE_ATTRIBUTE = "package";
-    private static final String BEAN_PACKAGE_ATTRIBUTE = "beanPackage";
-    private static final String BEAN_EXTENDS_ATTRIBUTE = "beanExtends";
-    private static final String BEAN_CLASS_NAME_ATTRIBUTE = "beanClassName";
-
     public void transform(
             SourceElement inheritanceElement,
             ControllerState controllerState)
@@ -52,23 +42,28 @@ public class OMInheritanceTransformer
                     + inheritanceElement.getName());
         }
         String key = (String)
-                inheritanceElement.getAttribute(INPUT_KEY_ATTRIBUTE);
+                inheritanceElement.getAttribute(TorqueSchemaAttributeName.KEY);
         if (key == null)
         {
             throw new IllegalArgumentException(
-                    "Attribute \"key\" not set in Element "
-                        + TorqueSchemaElementName.INHERITANCE.getName());
+                    "Attribute \""
+                        + TorqueSchemaAttributeName.KEY
+                        + "\" not set in Element "
+                        + TorqueSchemaElementName.INHERITANCE);
         }
         inheritanceElement.setAttribute(
-                CLASSKEY_CONSTANT_ATTRIBUTE, "CLASSKEY_" + key.toUpperCase());
+                InheritanceAttributeName.CLASSKEY_CONSTANT,
+                "CLASSKEY_" + key.toUpperCase());
         inheritanceElement.setAttribute(
-                CLASSNAME_CONSTANT_ATTRIBUTE, "CLASSNAME_" + 
key.toUpperCase());
+                InheritanceAttributeName.CLASSNAME_CONSTANT,
+                "CLASSNAME_" + key.toUpperCase());
         inheritanceElement.setAttribute(
-                CLASS_CONSTANT_ATTRIBUTE, "CLASS_" + key.toUpperCase());
+                InheritanceAttributeName.CLASS_CONSTANT,
+                "CLASS_" + key.toUpperCase());
 
         SourceElement tableElement
                 = inheritanceElement.getParent().getParent();
-        String className = (String)inheritanceElement.getAttribute(
+        String className = (String) inheritanceElement.getAttribute(
                 TorqueSchemaAttributeName.CLASS.getName());
         if (className == null)
         {
@@ -76,16 +71,16 @@ public class OMInheritanceTransformer
                     TableAttributeName.DB_OBJECT_CLASS_NAME);
         }
         inheritanceElement.setAttribute(
-                CLASS_NAME_ATTRIBUTE, className);
+                InheritanceAttributeName.CLASS_NAME, className);
         inheritanceElement.setAttribute(
-                PACKAGE_ATTRIBUTE,
+                InheritanceAttributeName.PACKAGE,
                 tableElement.getAttribute(
                         TableAttributeName.DB_OBJECT_PACKAGE));
         {
             String extendsAttribute = (String) inheritanceElement.getAttribute(
                     TorqueSchemaAttributeName.EXTENDS.getName());
             String beanExtends = (String) inheritanceElement.getAttribute(
-                    BEAN_EXTENDS_ATTRIBUTE);
+                    InheritanceAttributeName.BEAN_EXTENDS);
             if (extendsAttribute == null)
             {
                 extendsAttribute = (String) tableElement.getAttribute(
@@ -94,7 +89,7 @@ public class OMInheritanceTransformer
                         TorqueSchemaAttributeName.EXTENDS.getName(),
                         extendsAttribute);
                 inheritanceElement.setAttribute(
-                        BEAN_EXTENDS_ATTRIBUTE,
+                        InheritanceAttributeName.BEAN_EXTENDS,
                         tableElement.getAttribute(
                                 TableAttributeName.BEAN_CLASS_NAME));
             }
@@ -119,7 +114,7 @@ public class OMInheritanceTransformer
                         + controllerState.getOption(
                             "torque.om.className.beanClassNameSuffix");
                 inheritanceElement.setAttribute(
-                        BEAN_EXTENDS_ATTRIBUTE,
+                        InheritanceAttributeName.BEAN_EXTENDS,
                         beanExtends);
             }
         }
@@ -141,12 +136,12 @@ public class OMInheritanceTransformer
                     + controllerState.getOption(
                         "torque.om.className.beanClassNameSuffix");
             inheritanceElement.setAttribute(
-                    BEAN_CLASS_NAME_ATTRIBUTE,
+                    InheritanceAttributeName.BEAN_CLASS_NAME,
                     beanClassName);
 
         }
         inheritanceElement.setAttribute(
-                BEAN_PACKAGE_ATTRIBUTE,
+                InheritanceAttributeName.BEAN_PACKAGE,
                 tableElement.getAttribute(
                         TableAttributeName.BEAN_PACKAGE));
     }



---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscr...@db.apache.org
For additional commands, e-mail: torque-dev-h...@db.apache.org

Reply via email to