dlr         01/06/13 17:53:20

  Modified:    src/java/org/apache/turbine/torque/engine/database/model
                        Column.java
  Log:
  * Misc. whitespace clean up.
  
  * Performed some operations with more brevity.
  
  * Tweaked getFullyQualifiedName() implementation to be cheaper and
  more readable.
  
  * Used the convenience method getForeignKey() where appropriate.
  
  * Added brace as per the coding conventions.
  
  * Reduced pointless implicit String and StringBuffer creation in the
  toString() instance method.
  
  Revision  Changes    Path
  1.6       +34 -33    
jakarta-turbine/src/java/org/apache/turbine/torque/engine/database/model/Column.java
  
  Index: Column.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine/src/java/org/apache/turbine/torque/engine/database/model/Column.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- Column.java       2001/05/15 16:53:34     1.5
  +++ Column.java       2001/06/14 00:53:19     1.6
  @@ -58,7 +58,9 @@
   import java.util.Date;
   import java.util.Hashtable;
   import java.util.List;
  +
   import org.apache.velocity.util.StringUtils;
  +
   import org.xml.sax.Attributes;
   
   /**
  @@ -68,7 +70,7 @@
    * @author <a href="mailto:[EMAIL PROTECTED]";>Jason van Zyl</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Jon S. Stevens</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Daniel Rall</a>
  - * @version $Id: Column.java,v 1.5 2001/05/15 16:53:34 mikeh Exp $
  + * @version $Id: Column.java,v 1.6 2001/06/14 00:53:19 dlr Exp $
    */
   public class Column
   {
  @@ -102,6 +104,7 @@
        */
       public Column()
       {
  +        this(null);
       }
   
       /**
  @@ -148,25 +151,18 @@
           torqueType = attrib.getValue("type");
   
           inheritanceType = attrib.getValue("inheritance");
  -        if ( inheritanceType != null && !inheritanceType.equals("false") )
  -        {
  -            isInheritance = true;
  -        }
  -        else
  -        {
  -            isInheritance = false;
  -        }
  +        isInheritance = 
  +            ( inheritanceType != null && !inheritanceType.equals("false") );
   
           this.inputValidator = attrib.getValue("inputValidator");
       }
   
  -
       /**
        * Returns table.column
        */
       public String getFullyQualifiedName()
       {
  -        return parentTable.getName()+"."+name;
  +        return (parentTable.getName() + '.' + name);
       }
   
       /**
  @@ -189,7 +185,6 @@
       /**
        * Get name to use in Java sources
        */
  -
       public String getJavaName()
       {
           if (javaName == null)
  @@ -205,7 +200,6 @@
       /**
        * Set name to use in Java sources
        */
  -
       public void setJavaName(String javaName)
       {
           this.javaName = javaName;
  @@ -291,7 +285,6 @@
           return inheritanceList;
       }
   
  -
       /**
        * Determine if this column is a normal property or specifies a 
        * the classes that are represented in the table containing this column.
  @@ -363,7 +356,7 @@
        */
       public boolean isForeignKey()
       {
  -        return (parentTable.getForeignKey (this.name) != null);
  +        return (getForeignKey() != null);
       }
   
       /**
  @@ -372,7 +365,7 @@
        */
       public boolean isMultipleFK()
       {
  -        ForeignKey fk1 = parentTable.getForeignKey(this.name);
  +        ForeignKey fk1 = getForeignKey();
           if (fk1 != null) 
           {
               ForeignKey[] fks = parentTable.getForeignKeys();
  @@ -407,9 +400,8 @@
        */
       public String getRelatedTableName()
       {
  -        ForeignKey fk = parentTable.getForeignKey (this.name);
  -        if (fk == null) return null;
  -        return fk.getForeignTableName();
  +        ForeignKey fk = getForeignKey();
  +        return (fk == null ? null : fk.getForeignTableName());
       }
   
   
  @@ -420,7 +412,7 @@
        */
       public String getRelatedColumnName()
       {
  -        ForeignKey fk = parentTable.getForeignKey (this.name);
  +        ForeignKey fk = getForeignKey();
           if (fk == null)
           {
               return null;
  @@ -438,7 +430,9 @@
       public void addReferrer(ForeignKey fk)
       {
           if (referrers == null)
  +        {
               referrers = new ArrayList(5);
  +        }
           referrers.add(fk);
       }
   
  @@ -448,10 +442,11 @@
       public List getReferrers()
       {
           if (referrers == null)
  +        {
               referrers = new ArrayList(5);
  +        }
           return referrers;
       }      
  -                
   
       /**
        * Returns the colunm type
  @@ -492,17 +487,16 @@
       public String toString()
       {
           StringBuffer result = new StringBuffer();
  -        result.append("    <column name=\""+name+"\"");
  +        result.append("    <column name=\"").append(name).append('"');
   
           if (javaName != null)
           {
  -            result.append(" javaName=\""+javaName+"\"");
  +            result.append(" javaName=\"").append(javaName).append('"');
           }
   
  -
           if (isPrimaryKey)
           {
  -            result.append(" primaryKey=\""+isPrimaryKey+"\"");
  +            result.append(" primaryKey=\"").append(isPrimaryKey).append('"');
           }
   
           if (isNotNull)
  @@ -514,19 +508,27 @@
               result.append(" required=\"false\"");
           }
   
  -        result.append(" type=\"").append (torqueType).append("\"");
  +        result.append(" type=\"").append (torqueType).append('"');
           
           if (size != null)
  -            result.append(" size=\""+size+"\"");
  +        {
  +            result.append(" size=\"").append(size).append('"');
  +        }
   
           if (defaultValue != null)
  -            result.append(" default=\"" + defaultValue + "\"");
  +        {
  +            result.append(" default=\"").append(defaultValue).append('"');
  +        }
   
           if (isInheritance())
  -            result.append(" inheritance=\"" + inheritanceType + "\"");
  -        
  -        result.append(">");
  -        result.append("</column>\n");
  +        {
  +            result.append(" inheritance=\"").append(inheritanceType)
  +                .append('"');
  +        }
  +
  +        // Close the column.
  +        result.append(" />\n");
  +
           return result.toString();
       }
   
  @@ -545,7 +547,6 @@
       {
           size = newSize;
       }
  -
   
       /**
        * Return the size in brackets for use in an sql
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to