mpoeschl    02/04/14 05:59:27

  Modified:    src/java/org/apache/torque/engine/database/model Column.java
                        Table.java
               src/java/org/apache/torque/engine/database/transform
                        SQLToAppData.java XmlToData.java
  Log:
  code formatting and javadocs
  (no functional changes)
  
  Revision  Changes    Path
  1.20      +3 -2      
jakarta-turbine-torque/src/java/org/apache/torque/engine/database/model/Column.java
  
  Index: Column.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-torque/src/java/org/apache/torque/engine/database/model/Column.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- Column.java       12 Apr 2002 17:22:10 -0000      1.19
  +++ Column.java       14 Apr 2002 12:59:27 -0000      1.20
  @@ -71,7 +71,7 @@
    * @author <a href="mailto:[EMAIL PROTECTED]";>Jon S. Stevens</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Daniel Rall</a>
    * @author <a href="mailto:byron_foster@[EMAIL PROTECTED]>Byron Foster</a>
  - * @version $Id: Column.java,v 1.19 2002/04/12 17:22:10 mpoeschl Exp $
  + * @version $Id: Column.java,v 1.20 2002/04/14 12:59:27 mpoeschl Exp $
    */
   public class Column
   {
  @@ -115,6 +115,8 @@
   
       /**
        * Creates a new column and set the name
  +     * 
  +     * @param name column name
        */
       public Column(String name)
       {
  @@ -305,7 +307,6 @@
       {
           this.position = v;
       }
  -
   
       /**
        * Set the parent Table of the column
  
  
  
  1.28      +43 -21    
jakarta-turbine-torque/src/java/org/apache/torque/engine/database/model/Table.java
  
  Index: Table.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-torque/src/java/org/apache/torque/engine/database/model/Table.java,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- Table.java        11 Apr 2002 22:02:06 -0000      1.27
  +++ Table.java        14 Apr 2002 12:59:27 -0000      1.28
  @@ -75,10 +75,11 @@
    * @author <a href="mailto:[EMAIL PROTECTED]>John McNally</a>
    * @author <a href="mailto:[EMAIL PROTECTED]>Daniel Rall</a>
    * @author <a href="mailto:byron_foster@[EMAIL PROTECTED]>Byron Foster</a>
  - * @version $Id: Table.java,v 1.27 2002/04/11 22:02:06 mpoeschl Exp $
  + * @version $Id: Table.java,v 1.28 2002/04/14 12:59:27 mpoeschl Exp $
    */
   public class Table implements IDMethod
   {
  +    /** enables debug output */
       private static final boolean DEBUG = false;
   
       //private AttributeListImpl attributes;
  @@ -120,6 +121,8 @@
   
       /**
        * Constructs a table object with a name
  +     * 
  +     * @param name table name
        */
       public Table(String name)
       {
  @@ -134,6 +137,9 @@
   
       /**
        * Load the table object from an xml tag.
  +     * 
  +     * @param attrib xml attributes
  +     * @param defaultIdMethod defined at db level
        */
       public void loadFromXML(Attributes attrib, String defaultIdMethod)
       {
  @@ -153,8 +159,7 @@
           {
               idMethod = defaultIdMethod;
           }
  -        if ("autoincrement".equals(idMethod) ||
  -                 "sequence".equals(idMethod))
  +        if ("autoincrement".equals(idMethod) || "sequence".equals(idMethod))
           {
               System.out.println("The value '" + idMethod + "' for Torque's " +
                        "table.idMethod attribute has been deprecated in favor " +
  @@ -246,7 +251,8 @@
        */
       private void doNaming()
       {
  -        int i, size;
  +        int i;
  +        int size;
           String name;
   
           // Assure names are unique across all databases.
  @@ -287,9 +293,14 @@
   
       /**
        * Macro to a constraint name.
  +     * 
  +     * @param nameType constraint type
  +     * @param nbr unique number for this constraint type
  +     * @return unique name for constraint
  +     * @throws TorqueException
        */
       private final String acquireConstraintName(String nameType, int nbr)
  -        throws TorqueException
  +            throws TorqueException
       {
           List inputs = new ArrayList(4);
           inputs.add(getDatabase());
  @@ -360,8 +371,11 @@
       }
   
       /**
  -     * A utility function to create a new column
  -     * from attrib and add it to this table.
  +     * A utility function to create a new column from attrib and add it to this
  +     * table.
  +     * 
  +     * @param attrib xml attributes for the column to add
  +     * @return the added column
        */
       public Column addColumn(Attributes attrib)
       {
  @@ -375,6 +389,8 @@
       /**
        * Adds a new column to the column vector and set the
        * parent table of the column to the current table
  +     * 
  +     * @param col the column to add
        */
       public void addColumn(Column col)
       {
  @@ -425,7 +441,7 @@
           List names = new ArrayList(children.size());
           for ( int i = 0; i < children.size(); i++ )
           {
  -            names.add( ((Inheritance)children.get(i)).getClassName() );
  +            names.add( ((Inheritance) children.get(i)).getClassName() );
           }
           return names;
       }
  @@ -769,7 +785,7 @@
           Column[] tbls = new Column[size];
           for (int i = 0; i < size; i++)
           {
  -            tbls[i] = (Column)columnList.get(i);
  +            tbls[i] = (Column) columnList.get(i);
           }
           return tbls;
       }
  @@ -791,7 +807,7 @@
           ForeignKey[] tbls = new ForeignKey[size];
           for (int i = 0; i < size; i++)
           {
  -            tbls[i] = (ForeignKey)foreignKeys.get(i);
  +            tbls[i] = (ForeignKey) foreignKeys.get(i);
           }
           return tbls;
       }
  @@ -820,7 +836,7 @@
               }
               else
               {
  -                result = ((IdMethodParameter)idMethodParams.get(0)).getValue();
  +                result = ((IdMethodParameter) idMethodParams.get(0)).getValue();
               }
           }
           return result;
  @@ -835,7 +851,7 @@
           Index[] tbls = new Index[size];
           for (int i = 0; i < size; i++)
           {
  -            tbls[i] = (Index)indices.get(i);
  +            tbls[i] = (Index) indices.get(i);
           }
           return tbls;
       }
  @@ -849,7 +865,7 @@
           Unique[] tbls = new Unique[size];
           for (int i = 0; i < size; i++)
           {
  -            tbls[i] = (Unique)unices.get(i);
  +            tbls[i] = (Unique) unices.get(i);
           }
           return tbls;
       }
  @@ -860,7 +876,7 @@
        */
       public Column getColumn(String name)
       {
  -        return (Column)columnsByName.get(name);
  +        return (Column) columnsByName.get(name);
       }
   
       /**
  @@ -869,7 +885,7 @@
        */
       public Column getColumnByJavaName(String javaName)
       {
  -        return (Column)columnsByJavaName.get(javaName);
  +        return (Column) columnsByJavaName.get(javaName);
       }
   
       /**
  @@ -883,7 +899,7 @@
           for (Iterator iter = foreignKeys.iterator(); iter.hasNext(); )
           {
               ForeignKey key = (ForeignKey) iter.next();
  -            if (key.getLocalColumns().contains (col))
  +            if (key.getLocalColumns().contains(col))
               {
                   return key;
               }
  @@ -892,23 +908,25 @@
       }
   
       /**
  -     * Returns true if the table contains a spesified column
  +     * Returns true if the table contains a specified column
        */
       public boolean containsColumn(Column col)
       {
  -        return columnList.contains (col);
  +        return columnList.contains(col);
       }
   
       /**
  -     * Returns true if the table contains a spesified column
  +     * Returns true if the table contains a specified column
        */
       public boolean containsColumn(String name)
       {
  -        return (getColumn (name) != null);
  +        return (getColumn(name) != null);
       }
   
       /**
        * Set the parent of the table
  +     * 
  +     * @param parent the parant database
        */
       public void setDatabase(Database parent)
       {
  @@ -917,6 +935,8 @@
   
       /**
        * Get the parent of the table
  +     * 
  +     * @return the parant database
        */
       public Database getDatabase()
       {
  @@ -925,6 +945,8 @@
   
       /**
        * Returns a XML representation of this table.
  +     * 
  +     * @return XML representation of this table
        */
       public String toString()
       {
  @@ -1021,7 +1043,7 @@
           Iterator iter = columnList.iterator();
           while (iter.hasNext())
           {
  -            Column col = (Column)iter.next();
  +            Column col = (Column) iter.next();
               if (col.isPrimaryKey())
               {
                   pk.add(col);
  
  
  
  1.4       +84 -37    
jakarta-turbine-torque/src/java/org/apache/torque/engine/database/transform/SQLToAppData.java
  
  Index: SQLToAppData.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-torque/src/java/org/apache/torque/engine/database/transform/SQLToAppData.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- SQLToAppData.java 6 Mar 2002 02:59:07 -0000       1.3
  +++ SQLToAppData.java 14 Apr 2002 12:59:27 -0000      1.4
  @@ -57,9 +57,6 @@
   import java.io.BufferedReader;
   import java.io.FileReader;
   import java.io.IOException;
  -import java.io.PrintStream;
  -import java.io.Reader;
  -import java.util.List;
   import java.util.Vector;
   import org.apache.torque.engine.database.model.AppData;
   import org.apache.torque.engine.database.model.Column;
  @@ -76,11 +73,10 @@
    * structure.  The class makes use of SQL Scanner to get
    * sql tokens and the parses these to create the AppData
    * class. SQLToAppData is in effect a simplified sql parser.
  - *
    * 
    * @author <a href="mailto:[EMAIL PROTECTED]";>Leon Messerschmidt</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Jon S. Stevens</a>
  - * @version $Id: SQLToAppData.java,v 1.3 2002/03/06 02:59:07 jmcnally Exp $
  + * @version $Id: SQLToAppData.java,v 1.4 2002/04/14 12:59:27 mpoeschl Exp $
    */
   public class SQLToAppData
   {
  @@ -155,7 +151,7 @@
       private void err (String name) throws ParseException
       {
           throw new ParseException (name + " at [ line: " + token.getLine() + 
  -            " col: "+token.getCol()+" ]");
  +            " col: " + token.getCol() + " ]");
       }
   
       /**
  @@ -186,12 +182,15 @@
           next();
           String tableName = token.getStr(); // name of the table
           next();
  -        if (!token.getStr().equals("(")) err ("( expected");
  +        if (! token.getStr().equals("(")) 
  +        {
  +            err("( expected");
  +        }
           next();
   
           Table tbl = new Table (tableName);
           //tbl.setIdMethod("none");
  -        while (!token.getStr().equals(";"))
  +        while (! token.getStr().equals(";"))
           {
               Create_Table_Column(tbl);
           }
  @@ -204,8 +203,6 @@
           {
               tbl.setIdMethod(IDMethod.NO_ID_METHOD);
           }
  -             
  -        
           appDataDB.addTable (tbl);
       }
   
  @@ -219,16 +216,26 @@
           // which is the name of the column or
           // PRIMARY/FOREIGN/UNIQUE
           if (token.getStr().equals(","))
  +        {
               next();
  +        }
           
           if (token.getStr().toUpperCase().equals("PRIMARY"))
  +        {
               Create_Table_Column_Primary (tbl);
  +        }
           else if (token.getStr().toUpperCase().equals("FOREIGN"))
  +        {
               Create_Table_Column_Foreign (tbl);
  +        }
           else if (token.getStr().toUpperCase().equals("UNIQUE"))
  +        {
               Create_Table_Column_Unique (tbl);
  +        }
           else
  +        {
               Create_Table_Column_Data (tbl);
  +        }
       }
   
       /**
  @@ -238,15 +245,22 @@
       {
           next();
           if (!token.getStr().toUpperCase().equals("KEY"))
  +        {
               err ("KEY expected");
  +        }
           next();
           if (!token.getStr().toUpperCase().equals("("))
  +        {
               err ("( expected");
  +        }
           next();
   
           String colName = token.getStr();
           Column c = tbl.getColumn(colName);
  -        if (c == null) err ("Invalid column name: "+colName);
  +        if (c == null)
  +        {
  +            err("Invalid column name: " + colName);
  +        }
           c.setPrimaryKey(true);
           next();
           while (token.getStr().equals(","))
  @@ -254,24 +268,31 @@
               next();
               colName = token.getStr();
               c = tbl.getColumn(colName);
  -            if (c == null) err ("Invalid column name: "+colName);
  +            if (c == null)
  +            {
  +                err("Invalid column name: " + colName);
  +            }
               c.setPrimaryKey(true);
               next();
           }
   
  -        if (!token.getStr().toUpperCase().equals(")"))
  -            err (") expected");
  +        if (! token.getStr().toUpperCase().equals(")"))
  +        {
  +            err(") expected");
  +        }
           next(); // skip the )
       }
   
       /**
        * Parses UNIQUE (NAME,FOO,BAR) statement
        */
  -    private void Create_Table_Column_Unique (Table tbl) throws ParseException
  +    private void Create_Table_Column_Unique(Table tbl) throws ParseException
       {
           next();
  -        if (!token.getStr().toUpperCase().equals("("))
  -            err ("( expected");
  +        if (! token.getStr().toUpperCase().equals("("))
  +        {
  +            err("( expected");
  +        }
           next();
           while (!token.getStr().equals(")"))
           {
  @@ -279,13 +300,18 @@
               {
                   String colName = token.getStr();
                   Column c = tbl.getColumn(colName);
  -                if (c == null) err ("Invalid column name: "+colName);
  -                    c.setUnique(true);
  +                if (c == null)
  +                {
  +                    err("Invalid column name: " + colName);
  +                }
  +                c.setUnique(true);
               }
               next();
           }
  -        if (!token.getStr().toUpperCase().equals(")"))
  -            err (") expected got: " + token.getStr());
  +        if (! token.getStr().toUpperCase().equals(")"))
  +        {
  +            err(") expected got: " + token.getStr());
  +        }
   
           next(); // skip the )
       }
  @@ -296,11 +322,15 @@
       private void Create_Table_Column_Foreign (Table tbl) throws ParseException
       {
           next();
  -        if (!token.getStr().toUpperCase().equals("KEY"))
  -            err ("KEY expected");
  +        if (! token.getStr().toUpperCase().equals("KEY"))
  +        {
  +            err("KEY expected");
  +        }
           next();
  -        if (!token.getStr().toUpperCase().equals("("))
  -            err ("( expected");
  +        if (! token.getStr().toUpperCase().equals("("))
  +        {
  +            err("( expected");
  +        }
           next();
   
           ForeignKey fk = new ForeignKey();
  @@ -317,13 +347,17 @@
               localColumns.add(colName);
               next();
           }
  -        if (!token.getStr().toUpperCase().equals(")"))
  -            err (") expected");
  +        if (! token.getStr().toUpperCase().equals(")"))
  +        {
  +            err(") expected");
  +        }
   
           next();
   
  -        if (!token.getStr().toUpperCase().equals("REFERENCES"))
  -            err ("REFERENCES expected");
  +        if (! token.getStr().toUpperCase().equals("REFERENCES"))
  +        {
  +            err("REFERENCES expected");
  +        }
   
           next();
   
  @@ -334,7 +368,7 @@
           if (token.getStr().toUpperCase().equals("("))
           {
               next();
  -            int i=0;
  +            int i = 0;
               fk.addReference((String)localColumns.get(i++),token.getStr());
               next();
               while (token.getStr().equals(","))
  @@ -343,8 +377,10 @@
                   fk.addReference((String)localColumns.get(i++),token.getStr());
                   next();
               }
  -            if (!token.getStr().toUpperCase().equals(")"))
  -                err (") expected");
  +            if (! token.getStr().toUpperCase().equals(")"))
  +            {
  +                err(") expected");
  +            }
               next();
           }
       }
  @@ -359,13 +395,14 @@
           String columnDefault = null;
           boolean inEnum = false;
   
  -
           String columnName = token.getStr();
           next();
           String columnType = token.getStr();
   
           if (columnName.equals(")") && columnType.equals(";"))
  +        {
               return;
  +        }
   
           next();
   
  @@ -375,12 +412,12 @@
           {
               inEnum = true;
               next(); // skip (
  -            while (!token.getStr().equals(")"))
  +            while (! token.getStr().equals(")"))
               {
                   // skip until )
                   next();
               }
  -            while (!token.getStr().equals(","))
  +            while (! token.getStr().equals(","))
               {
                   if (token.getStr().toUpperCase().equals("DEFAULT"))
                   {
  @@ -423,7 +460,9 @@
   
           Column col = new Column (columnName);
           if (columnPrecision != null)
  +        {
               columnSize = columnSize + columnPrecision;
  +        }
           col.setTypeFromString (columnType,columnSize);
           tbl.addColumn (col);
           
  @@ -442,16 +481,20 @@
                   if (token.getStr().toUpperCase().equals("NOT"))
                   {
                       next();
  -                    if (!token.getStr().toUpperCase().equals("NULL")) 
  +                    if (! token.getStr().toUpperCase().equals("NULL")) 
  +                    {
                           err ("NULL expected after NOT");
  +                    }
                       col.setNotNull(true);
                       next();
                   }
                   else if (token.getStr().toUpperCase().equals("PRIMARY"))
                   {
                       next();
  -                    if (!token.getStr().toUpperCase().equals("KEY")) 
  +                    if (! token.getStr().toUpperCase().equals("KEY")) 
  +                    {
                           err ("KEY expected after PRIMARY");
  +                    }
                       col.setPrimaryKey(true);
                       next();
                   }
  @@ -510,14 +553,18 @@
           while (hasTokens())
           {
               if (token == null)
  +            {
                   next();
  +            }
   
               if (token.getStr().toUpperCase().equals("CREATE"))
               {
                   Create();
               }
               if (hasTokens())
  +            {
                   next();
  +            }
           }
   
           return appData;
  
  
  
  1.6       +6 -15     
jakarta-turbine-torque/src/java/org/apache/torque/engine/database/transform/XmlToData.java
  
  Index: XmlToData.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-torque/src/java/org/apache/torque/engine/database/transform/XmlToData.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- XmlToData.java    16 Feb 2002 16:54:15 -0000      1.5
  +++ XmlToData.java    14 Apr 2002 12:59:27 -0000      1.6
  @@ -58,9 +58,6 @@
   import java.io.File;
   import java.io.FileReader;
   import java.io.IOException;
  -import java.io.InputStream;
  -import java.io.PrintStream;
  -import java.io.Reader;
   import java.net.MalformedURLException;
   import java.net.URL;
   import java.util.List;
  @@ -75,11 +72,8 @@
   import org.apache.torque.engine.database.model.Table;
   
   import org.xml.sax.Attributes;
  -import org.xml.sax.ContentHandler;
   import org.xml.sax.EntityResolver;
  -import org.xml.sax.ErrorHandler;
   import org.xml.sax.InputSource;
  -import org.xml.sax.SAXException;
   import org.xml.sax.SAXParseException;
   import org.xml.sax.helpers.DefaultHandler;
   
  @@ -92,7 +86,7 @@
    * @author <a href="mailto:[EMAIL PROTECTED]";>Jason van Zyl</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Martin Poeschl</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Fedor Karpelevitch</a>
  - * @version $Id: XmlToData.java,v 1.5 2002/02/16 16:54:15 mpoeschl Exp $
  + * @version $Id: XmlToData.java,v 1.6 2002/04/14 12:59:27 mpoeschl Exp $
    */
   public class XmlToData extends DefaultHandler implements EntityResolver
   {
  @@ -115,8 +109,8 @@
       /**
        * Default custructor
        */
  -    public XmlToData(Database database, String dtdFilePath) throws
  -            MalformedURLException, IOException
  +    public XmlToData(Database database, String dtdFilePath) 
  +            throws MalformedURLException, IOException
       {
           this.database = database;
           dtdFile = new File(dtdFilePath);
  @@ -196,8 +190,7 @@
       /**
        * Warning callback.
        *
  -     * @exception spe The parse exception that caused the callback to be
  -     *                invoked.
  +     * @param spe The parse exception that caused the callback to be invoked.
        */
       public void warning(SAXParseException spe)
       {
  @@ -209,8 +202,7 @@
       /**
        * Error callback.
        *
  -     * @exception spe The parse exception that caused the callback to be
  -     *                invoked.
  +     * @param spe The parse exception that caused the callback to be invoked.
        */
       public void error(SAXParseException spe)
       {
  @@ -222,8 +214,7 @@
       /**
        * Fatal error callback.
        *
  -     * @exception spe The parse exception that caused the callback to be
  -     *                invoked.
  +     * @param spe The parse exception that caused the callback to be invoked.
        */
       public void fatalError(SAXParseException spe)
       {
  
  
  

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

Reply via email to