mikeh       01/07/03 07:51:54

  Modified:    src/java/org/apache/turbine/torque/engine/database/model
                        ForeignKey.java
  Log:
  added javadoc and set methods for onDelete/onUpdate
  
  Revision  Changes    Path
  1.8       +37 -9     
jakarta-turbine/src/java/org/apache/turbine/torque/engine/database/model/ForeignKey.java
  
  Index: ForeignKey.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine/src/java/org/apache/turbine/torque/engine/database/model/ForeignKey.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ForeignKey.java   2001/07/02 19:10:52     1.7
  +++ ForeignKey.java   2001/07/03 14:51:47     1.8
  @@ -63,7 +63,7 @@
    * A Class for information about foreign keys of a table
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Fedor</a>
  - * @version $Id: ForeignKey.java,v 1.7 2001/07/02 19:10:52 mikeh Exp $
  + * @version $Id: ForeignKey.java,v 1.8 2001/07/03 14:51:47 mikeh Exp $
    */
   public class ForeignKey
   {
  @@ -74,7 +74,9 @@
       private List localColumns = new ArrayList(3);
       private List foreignColumns = new ArrayList(3);
   
  -    private final String NONE = "NONE";
  +    // the uppercase equivalent of the onDelete/onUpdate values in the dtd
  +    private final String NONE    = "NONE";
  +    private final String SETNULL = "SETNULL";
   
       /**
        * Default Constructor
  @@ -95,6 +97,10 @@
           onDelete = normalizeFKey(onDelete);
       }
   
  +    /**
  +     * normailizes the input of onDelete, onUpdate
  +     * attributes
  +     */
       private String normalizeFKey(String attrib)
       {
           if (attrib == null) 
  @@ -103,36 +109,63 @@
           }
   
           attrib = attrib.toUpperCase();
  -        if (attrib.equals("SETNULL"))
  +        if (attrib.equals(SETNULL))
           {
               attrib =  "SET NULL";
           }
           return attrib;
       }
   
  +    /**
  +     * returns whether or not the onUpdate attribute is set
  +     */
       public boolean hasOnUpdate()
       {
          return ! onUpdate.equals(NONE);
       }
   
  +    /**
  +     * returns whether or not the onDelete attribute is set
  +     */
       public boolean hasOnDelete()
       {
          return ! onDelete.equals(NONE);
       }
   
  +    /**
  +     * returns the onUpdate attribute
  +     */
       public String getOnUpdate()
       {
          return onUpdate;
       }
   
  +    /**
  +     * returns the onDelete attribute
  +     */
       public String getOnDelete()
       {
          return onDelete;
       }
   
       /**
  +     * sets the onDelete attribute
  +     */
  +    public void setOnDelete(String value)
  +    {
  +       onDelete = normalizeFKey(value);
  +    }
  +
  +    /**
  +     * sets the onUpdate attribute
  +     */
  +    public void setOnUpdate(String value)
  +    {
  +       onUpdate = normalizeFKey(value);
  +    }
  +
  +    /**
        * Get the foreignTableName of the FK
  -     *
        */
       public String getForeignTableName()
       {
  @@ -288,8 +321,3 @@
           return result.toString();
       }
   }
  -
  -
  -
  -
  -
  
  
  

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

Reply via email to