You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by dl...@apache.org on 2001/06/14 03:38:21 UTC

cvs commit: jakarta-turbine/src/java/org/apache/turbine/torque/engine/database/model Table.java

dlr         01/06/13 18:38:21

  Modified:    src/java/org/apache/turbine/torque/engine/database/model
                        Table.java
  Log:
  * Added constant for the new "native" ID method.
  
  * Doing early initialization of all instance members in the ctor for
  consistancy.
  
  * LARGE CHANGE: Deprecated the values "autoincrement" and "sequence"
  for XML schemas in favor of "native".  Leave it to the Java code and
  emplates to sort out database-specific implementations of the same
  damn thing.
  
  * Added curly braces as per the Turbine coding conventions.
  
  * Remove extra opening JavaDoc comments.
  
  * Added documentation to addIdMethodParameter(IdMethodParameter).
  
  * Clarified some evaluations.
  
  * Refactored getSequenceName() slightly for cleaner code.
  
  * Brought JavaDoc brevity to toString() instance method.
  
  Revision  Changes    Path
  1.18      +40 -15    jakarta-turbine/src/java/org/apache/turbine/torque/engine/database/model/Table.java
  
  Index: Table.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine/src/java/org/apache/turbine/torque/engine/database/model/Table.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- Table.java	2001/05/31 00:59:46	1.17
  +++ Table.java	2001/06/14 01:38:20	1.18
  @@ -58,19 +58,30 @@
   import java.util.Hashtable;
   import java.util.Iterator;
   import java.util.List;
  +
  +import org.apache.turbine.util.Log;
  +
   import org.apache.velocity.util.StringUtils;
  +
   import org.xml.sax.Attributes;
   
   /**
  - * A Class for holding data about a table used in an Application.
  + * Data about a table used in an application.
    *
    * @author <a href="mailto:leon@opticode.co.za">Leon Messerschmidt</a>
    * @author <a href="mailto:jvanzyl@periapt.com">Jason van Zyl</a>
    * @author <a href="mailto:mpoeschl@marmot.at>Martin Poeschl</a>
  - * @version $Id: Table.java,v 1.17 2001/05/31 00:59:46 jmcnally Exp $
  + * @author <a href="mailto:jmcnally@collab.net>John McNally</a>
  + * @author <a href="mailto:dlr@collab.net>Daniel Rall</a>
  + * @version $Id: Table.java,v 1.18 2001/06/14 01:38:20 dlr Exp $
    */
   public class Table
   {
  +    /**
  +     * A value indicating that the database-specific native ID method
  +     * should be used for this table.
  +     */
  +    private static final String NATIVE_ID_METHOD = "native";
   
       //private AttributeListImpl attributes;
       private List columnList;
  @@ -92,8 +103,8 @@
       // private String pkg;
       private String baseClass;
       private String basePeer;
  -    private Hashtable columnsByName = new Hashtable();
  -    private Hashtable columnsByJavaName = new Hashtable();
  +    private Hashtable columnsByName;
  +    private Hashtable columnsByJavaName;
   
       /**
        * Default Constructor
  @@ -113,6 +124,8 @@
           foreignKeys = new ArrayList(5);
           indices = new ArrayList(5);
           unices = new ArrayList(5);
  +        columnsByName = new Hashtable();
  +        columnsByJavaName = new Hashtable();
       }
   
       /**
  @@ -127,6 +140,15 @@
           {
               idMethod = defaultIdMethod;
           }
  +        else if ("autoincrement".equals(idMethod) ||
  +                 "sequence".equals(idMethod))
  +        {
  +            Log.warn("The value '" + idMethod + "' for Torque's " +
  +                     "table.idMethod attribute has been deprecated in favor " +
  +                     "of '" + NATIVE_ID_METHOD + "'.  Please adjust your " +
  +                     "Torque XML schema accordingly.");
  +            idMethod = NATIVE_ID_METHOD;
  +        }
           skipSql = "true".equals(attrib.getValue("skipSql"));
           // pkg = attrib.getValue("package");
           abstractValue = "true".equals(attrib.getValue("abstract"));
  @@ -266,7 +288,9 @@
       public void addReferrer(ForeignKey fk)
       {
           if (referrers == null)
  +        {
               referrers = new ArrayList(5);
  +        }
           referrers.add(fk);
       }
   
  @@ -326,7 +350,6 @@
       }
   
       /**
  -    /**
        * A utility function to create a new id method parameter
        * from attrib and add it to this table.
        */
  @@ -339,8 +362,11 @@
       }
   
       /**
  -     * Adds a new id method parameter to the vector and set the
  -     * parent table of the column to the current table
  +     * Adds a new ID method parameter to the list and sets the parent
  +     * table of the column associated with the supplied parameter to
  +     * this table.
  +     *
  +     * @param imp The column to add as an ID method parameter.
        */
       public void addIdMethodParameter(IdMethodParameter imp)
       {
  @@ -466,7 +492,7 @@
        */
       public boolean isSkipSql()
       {
  -        return skipSql || isAlias();
  +        return (skipSql || isAlias());
       }
   
       /**
  @@ -494,7 +520,7 @@
        */
       public boolean isAlias()
       {
  -        return alias != null;
  +        return (alias != null);
       }
   
       /**
  @@ -586,16 +612,16 @@
       public String getSequenceName()
       {
           String result = null;
  -        if ( getIdMethod().equals("sequence"))
  +        if ( getIdMethod().equals(NATIVE_ID_METHOD))
           {
  -            if (getIdMethodParameters() == null)
  +            List idMethodParams = getIdMethodParameters();
  +            if (idMethodParams == null)
               {
                   result = getName() + "_SEQ";
               }
               else
               {
  -                result = ((IdMethodParameter)getIdMethodParameters().get(0))
  -                    .getValue();
  +                result = ((IdMethodParameter)idMethodParams.get(0)).getValue();
               }
           }
           return result;
  @@ -699,8 +725,7 @@
       }
   
       /**
  -     * Creates a string representation of this table. This
  -     * is an xml representation.
  +     * Returns a XML representation of this table.
        */
       public String toString()
       {
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org