fedor       01/05/22 01:50:33

  Modified:    src/java/org/apache/turbine/torque TorqueDataDTDTask.java
                        TorqueDataDumpTask.java TorqueDataSQLTask.java
  Log:
  javadocs
  
  Revision  Changes    Path
  1.2       +29 -24    
jakarta-turbine/src/java/org/apache/turbine/torque/TorqueDataDTDTask.java
  
  Index: TorqueDataDTDTask.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine/src/java/org/apache/turbine/torque/TorqueDataDTDTask.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TorqueDataDTDTask.java    2001/05/04 21:58:54     1.1
  +++ TorqueDataDTDTask.java    2001/05/22 08:50:17     1.2
  @@ -25,13 +25,13 @@
    *    Alternately, this acknowledgment may appear in the software itself,
    *    if and wherever such third-party acknowledgments normally appear.
    *
  - * 4. The names "Apache" and "Apache Software Foundation" and 
  - *    "Apache Turbine" must not be used to endorse or promote products 
  - *    derived from this software without prior written permission. For 
  + * 4. The names "Apache" and "Apache Software Foundation" and
  + *    "Apache Turbine" must not be used to endorse or promote products
  + *    derived from this software without prior written permission. For
    *    written permission, please contact [EMAIL PROTECTED]
    *
    * 5. Products derived from this software may not be called "Apache",
  - *    "Apache Turbine", nor may "Apache" appear in their name, without 
  + *    "Apache Turbine", nor may "Apache" appear in their name, without
    *    prior written permission of the Apache Software Foundation.
    *
    * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  @@ -53,7 +53,6 @@
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
    */
  -
   import java.util.Date;
   
   import org.apache.velocity.context.Context;
  @@ -64,50 +63,55 @@
   import org.apache.turbine.torque.engine.database.transform.XmlToAppData;
   
   /**
  - * An extended Texen task used for generating SQL source from
  - * an XML schema describing a database structure.
  + *  An extended Texen task used for generating data DTD from
  + *  an XML schema describing a database structure.
    *
  - * @author <a href="mailto:[EMAIL PROTECTED]>Fedor Karpelevitch</a>
  - * @version $Id: TorqueDataDTDTask.java,v 1.1 2001/05/04 21:58:54 fedor Exp $
  + * @author   <a href="mailto:[EMAIL PROTECTED]";> Fedor Karpelevitch </a>
  + * @version  $Id: TorqueDataDTDTask.java,v 1.2 2001/05/22 08:50:17 fedor Exp $
    */
   public class TorqueDataDTDTask extends TexenTask
   {
       /**
  -     * Application model. In this case a database model.
  +     *  Application model. In this case a database model.
        */
       private AppData app;
   
       /**
  -     * XML that describes the database model, this is transformed
  -     * into the application model object.
  +     *  XML that describes the database model, this is transformed
  +     *  into the application model object.
        */
       private String xmlFile;
  -    
  +
  +
       /**
  -     * Get the xml schema describing the application
  -     * model.
  +     *  Get the xml schema describing the application
  +     *  model.
        *
  -     * @return String xml schema file.
  +     * @return  String xml schema file.
        */
  -    public String getXmlFile ()
  +    public String getXmlFile()
       {
           return xmlFile;
       }
   
  +
       /**
  -     * Set the xml schema describing the application
  -     * model.
  +     *  Set the xml schema describing the application
  +     *  model.
        *
  -     * @param String xml schema file.
  +     * @param  v The new XmlFile value
        */
       public void setXmlFile(String v)
       {
           xmlFile = v;
       }
   
  +
       /**
  -     * Set up the initialial context for generating the
  -     * SQL from the XML schema.
  +     *  Set up the initialial context for generating the
  +     *  SQL from the XML schema.
  +     *
  +     * @return  Description of the Returned Value
        */
       public Context initControlContext()
       {
  @@ -115,14 +119,14 @@
            * Create a new Velocity context.
            */
           Context context = new VelocityContext();
  -        
  +
           /*
            * Transform the XML database schema into an
            * object that represents our model.
            */
           XmlToAppData xmlParser = new XmlToAppData();
           app = xmlParser.parseFile(xmlFile);
  -        
  +
           /*
            * Place our model in the context.
            */
  @@ -131,3 +135,4 @@
           return context;
       }
   }
  +
  
  
  
  1.3       +124 -61   
jakarta-turbine/src/java/org/apache/turbine/torque/TorqueDataDumpTask.java
  
  Index: TorqueDataDumpTask.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine/src/java/org/apache/turbine/torque/TorqueDataDumpTask.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TorqueDataDumpTask.java   2001/05/20 22:54:08     1.2
  +++ TorqueDataDumpTask.java   2001/05/22 08:50:20     1.3
  @@ -25,13 +25,13 @@
    *    Alternately, this acknowledgment may appear in the software itself,
    *    if and wherever such third-party acknowledgments normally appear.
    *
  - * 4. The names "Apache" and "Apache Software Foundation" and 
  - *    "Apache Turbine" must not be used to endorse or promote products 
  - *    derived from this software without prior written permission. For 
  + * 4. The names "Apache" and "Apache Software Foundation" and
  + *    "Apache Turbine" must not be used to endorse or promote products
  + *    derived from this software without prior written permission. For
    *    written permission, please contact [EMAIL PROTECTED]
    *
    * 5. Products derived from this software may not be called "Apache",
  - *    "Apache Turbine", nor may "Apache" appear in their name, without 
  + *    "Apache Turbine", nor may "Apache" appear in their name, without
    *    prior written permission of the Apache Software Foundation.
    *
    * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  @@ -53,7 +53,6 @@
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
    */
  -
   import java.util.Date;
   import java.util.Iterator;
   import java.util.Properties;
  @@ -73,170 +72,185 @@
   import org.apache.turbine.torque.engine.database.transform.XmlToAppData;
   
   /**
  - * An extended Texen task used for dumping data from db into XML
  + *  An extended Texen task used for dumping data from db into XML
    *
  - * @author <a href="mailto:[EMAIL PROTECTED]>Fedor Karpelevitch</a>
  - * @version $Id: TorqueDataDumpTask.java,v 1.2 2001/05/20 22:54:08 jvanzyl Exp $
  + * @author   <a href="mailto:[EMAIL PROTECTED]";>  Fedor Karpelevitch  </a>
  + * @version  $Id: TorqueDataDumpTask.java,v 1.3 2001/05/22 08:50:20 fedor Exp $
    */
   public class TorqueDataDumpTask extends TexenTask
   {
       /**
  -     * Application model. In this case a database model.
  +     *  Application model. In this case a database model.
        */
       private AppData app;
   
       private String databaseName;
   
       /**
  -     * XML that describes the database model, this is transformed
  -     * into the application model object.
  +     *  XML that describes the database model, this is transformed
  +     *  into the application model object.
        */
       private String xmlFile;
   
       /**
  -     * Database URL used for JDBC connection.
  +     *  Database URL used for JDBC connection.
        */
       private String databaseUrl;
  -    
  +
       /**
  -     * Database driver used for JDBC connection.
  +     *  Database driver used for JDBC connection.
        */
       private String databaseDriver;
  -    
  +
       /**
  -     * Database user used for JDBC connection.
  +     *  Database user used for JDBC connection.
        */
       private String databaseUser;
  -    
  +
       /**
  -     * Database password used for JDBC connection.
  +     *  Database password used for JDBC connection.
        */
       private String databasePassword;
   
  +
       /**
  -     * Get the xml schema describing the application
  -     * model.
  +     *  Get the xml schema describing the application
  +     *  model.
        *
  -     * @return String xml schema file.
  +     * @return  String xml schema file.
        */
  -    public String getXmlFile ()
  +    public String getXmlFile()
       {
           return xmlFile;
       }
   
  +
       /**
  -     * Set the xml schema describing the application
  -     * model.
  +     *  Set the xml schema describing the application
  +     *  model.
        *
  -     * @param String xml schema file.
  +     * @param  v The new XmlFile value
        */
       public void setXmlFile(String v)
       {
           xmlFile = v;
       }
   
  +
       /**
        *  Get the database name to dump
        *
  -     * @param String database to dump
  +     * @return  The DatabaseName value
        */
  -    public String getDatabaseName ()
  +    public String getDatabaseName()
       {
           return databaseName;
       }
   
  +
       /**
  -     * Set the database name
  +     *  Set the database name
        *
  -     * @param String database name
  +     * @param  v The new DatabaseName value
        */
       public void setDatabaseName(String v)
       {
           databaseName = v;
       }
   
  +
       /**
  -     * Get the database url
  +     *  Get the database url
        *
  -     * @param String database url
  +     * @return  The DatabaseUrl value
        */
       public String getDatabaseUrl()
       {
           return databaseUrl;
       }
   
  +
       /**
  -     * Set the database url
  +     *  Set the database url
        *
  -     * @param String database url
  +     * @param  v The new DatabaseUrl value
        */
       public void setDatabaseUrl(String v)
       {
           databaseUrl = v;
       }
   
  +
       /**
  -     * Get the database driver name
  +     *  Get the database driver name
        *
  -     * @return String database driver name
  +     * @return  String database driver name
        */
       public String getDatabaseDriver()
       {
           return databaseDriver;
       }
  -    
  +
  +
       /**
  -     * Set the database driver name
  +     *  Set the database driver name
        *
  -     * @param String database driver name
  +     * @param  v The new DatabaseDriver value
        */
       public void setDatabaseDriver(String v)
       {
           databaseDriver = v;
       }
   
  +
       /**
  -     * Get the database user
  +     *  Get the database user
        *
  -     * @return String database user
  +     * @return  String database user
        */
       public String getDatabaseUser()
       {
           return databaseUser;
       }
   
  +
       /**
  -     * Set the database user
  +     *  Set the database user
        *
  -     * @param String database user
  +     * @param  v The new DatabaseUser value
        */
       public void setDatabaseUser(String v)
       {
           databaseUser = v;
       }
   
  +
       /**
        *  Get the database password
        *
  -     * @return String database password
  +     * @return  String database password
        */
       public String getDatabasePassword()
       {
           return databasePassword;
       }
   
  +
       /**
  -     * Set the database password
  +     *  Set the database password
        *
  -     * @param String database password
  +     * @param  v The new DatabasePassword value
        */
       public void setDatabasePassword(String v)
       {
           databasePassword = v;
       }
   
  +
       /**
        *  Initializes initial context
  +     *
  +     * @return  Description of the Returned Value
        */
       public Context initControlContext()
       {
  @@ -256,7 +270,7 @@
            * Place our model in the context.
            */
           Database dbm = app.getDatabase(databaseName);
  -        if (dbm==null)
  +        if (dbm == null)
           {
               dbm = app.getDatabases()[0];
           }
  @@ -265,11 +279,11 @@
           context.put("dataset", "all");
   
           System.err.println("Your DB settings are:");
  -        System.err.println("driver : "+databaseDriver);
  -        System.err.println("URL : "+databaseUrl);
  -        System.err.println("user : "+databaseUser);
  -        System.err.println("password : "+databasePassword);
  -        
  +        System.err.println("driver : " + databaseDriver);
  +        System.err.println("URL : " + databaseUrl);
  +        System.err.println("user : " + databaseUser);
  +        System.err.println("password : " + databasePassword);
  +
           try
           {
               Class.forName(databaseDriver);
  @@ -278,8 +292,8 @@
               // Attemtp to connect to a database.
   
               Connection conn = DriverManager.getConnection(
  -                databaseUrl, databaseUser, databasePassword);
  -            
  +                    databaseUrl, databaseUser, databasePassword);
  +
               System.err.println("DB connection established");
               context.put("tableTool", new TableTool(conn));
           }
  @@ -297,13 +311,16 @@
           return context;
       }
   
  +
       /**
        *  A nasty do-it-all tool class. It serves as:
        *  <ul>
  -     *      <li>context tool to fetch a table iterator</li>
  -     *      <li>the abovenamed iterator which iterates over the table</li>
  -     *      <li>getter for the table fields</li>
  +     *  <li>context tool to fetch a table iterator</li>
  +     *  <li>the abovenamed iterator which iterates over the table</li>
  +     *  <li>getter for the table fields</li>
        *  </ul>
  +     *
  +     * @author  fedor
        */
       public class TableTool implements Iterator
       {
  @@ -311,33 +328,58 @@
           private ResultSet rs;
           private boolean isEmpty;
   
  +
  +        /**
  +         *  Constructor for the TableTool object
  +         *
  +         * @param  conn Description of Parameter
  +         */
           public TableTool(Connection conn)
           {
               this.conn = conn;
           }
   
  +
  +        /**
  +         *  Constructor for the TableTool object
  +         *
  +         * @param  rs Description of Parameter
  +         * @exception  SQLException Description of Exception
  +         */
           public TableTool(ResultSet rs) throws SQLException
           {
               this.rs = rs;
               this.isEmpty = !rs.isBeforeFirst();
           }
   
  +
  +        /**
  +         *  Description of the Method
  +         *
  +         * @param  tableName Description of Parameter
  +         * @return  Description of the Returned Value
  +         * @exception  SQLException Description of Exception
  +         */
           public TableTool fetch(String tableName) throws SQLException
           {
               System.err.println();
               System.err.print("fetching table " + tableName);
               return
  -                new TableTool(conn
  -                    .createStatement()
  -                        .executeQuery("SELECT * FROM "+tableName));
  +                    new TableTool(conn.createStatement()
  +                    .executeQuery("SELECT * FROM " + tableName));
           }
   
   
  +        /**
  +         *  Description of the Method
  +         *
  +         * @return  Description of the Returned Value
  +         */
           public boolean hasNext()
           {
               try
               {
  -                return ! (rs.isLast() || this.isEmpty);
  +                return !(rs.isLast() || this.isEmpty);
               }
               catch (SQLException se)
               {
  @@ -347,6 +389,13 @@
               return false;
           }
   
  +
  +        /**
  +         *  Description of the Method
  +         *
  +         * @return  Description of the Returned Value
  +         * @exception  NoSuchElementException Description of Exception
  +         */
           public Object next() throws NoSuchElementException
           {
               try
  @@ -363,6 +412,13 @@
               return this;
           }
   
  +
  +        /**
  +         *  Description of the Method
  +         *
  +         * @param  columnName Description of Parameter
  +         * @return  Description of the Returned Value
  +         */
           public String get(String columnName)
           {
               try
  @@ -372,14 +428,21 @@
               catch (SQLException se)
               {
                   System.err.println("SQLException fetching value " +
  -                    columnName+":"+ se.getMessage());
  +                        columnName + ":" + se.getMessage());
               }
               return null;
           }
   
  +
  +        /**
  +         *  Description of the Method
  +         *
  +         * @exception  UnsupportedOperationException Description of Exception
  +         */
           public void remove() throws UnsupportedOperationException
           {
               throw new UnsupportedOperationException();
           }
       }
   }
  +
  
  
  
  1.2       +85 -43    
jakarta-turbine/src/java/org/apache/turbine/torque/TorqueDataSQLTask.java
  
  Index: TorqueDataSQLTask.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine/src/java/org/apache/turbine/torque/TorqueDataSQLTask.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TorqueDataSQLTask.java    2001/05/04 21:58:54     1.1
  +++ TorqueDataSQLTask.java    2001/05/22 08:50:22     1.2
  @@ -25,13 +25,13 @@
    *    Alternately, this acknowledgment may appear in the software itself,
    *    if and wherever such third-party acknowledgments normally appear.
    *
  - * 4. The names "Apache" and "Apache Software Foundation" and 
  - *    "Apache Turbine" must not be used to endorse or promote products 
  - *    derived from this software without prior written permission. For 
  + * 4. The names "Apache" and "Apache Software Foundation" and
  + *    "Apache Turbine" must not be used to endorse or promote products
  + *    derived from this software without prior written permission. For
    *    written permission, please contact [EMAIL PROTECTED]
    *
    * 5. Products derived from this software may not be called "Apache",
  - *    "Apache Turbine", nor may "Apache" appear in their name, without 
  + *    "Apache Turbine", nor may "Apache" appear in their name, without
    *    prior written permission of the Apache Software Foundation.
    *
    * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  @@ -53,7 +53,6 @@
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
    */
  -
   import java.util.Date;
   import java.util.List;
   
  @@ -67,114 +66,158 @@
   import org.apache.turbine.torque.engine.database.transform.XmlToData;
   
   /**
  - * An extended Texen task used for generating SQL source from
  - * an XML schema describing a database structure.
  + *  An extended Texen task used for generating SQL source from
  + *  an XML data file
    *
  - * @author <a href="mailto:[EMAIL PROTECTED]";>Jason van Zyl</a>
  - * @author <a href="mailto:[EMAIL PROTECTED]>John McNally</a>
  - * @author <a href="mailto:[EMAIL PROTECTED]>Fedor Karpelevitch</a>
  - * @version $Id: TorqueDataSQLTask.java,v 1.1 2001/05/04 21:58:54 fedor Exp $
  + * @author   <a href="mailto:[EMAIL PROTECTED]";> Jason van Zyl </a>
  + * @author   <a href="mailto:[EMAIL PROTECTED]";> John McNally </a>
  + * @author   <a href="mailto:[EMAIL PROTECTED]";> Fedor Karpelevitch </a>
  + * @version  $Id: TorqueDataSQLTask.java,v 1.2 2001/05/22 08:50:22 fedor Exp $
    */
   public class TorqueDataSQLTask extends TexenTask
   {
       /**
  -     * Application model. In this case a database model.
  +     *  Application model. In this case a database model.
        */
       private AppData app;
   
       /**
  -     * XML that describes the database model, this is transformed
  -     * into the application model object.
  +     *  XML that describes the database model, this is transformed
  +     *  into the application model object.
        */
       private String xmlFile;
       private String dataXmlFile;
       private String dataDTD;
   
       /**
  -     * The target database(s) we are generating SQL
  -     * for. Right now we can only deal with a single
  -     * target, but we will support multiple targets
  -     * soon.
  +     *  The target database(s) we are generating SQL
  +     *  for. Right now we can only deal with a single
  +     *  target, but we will support multiple targets
  +     *  soon.
        */
       private String targetDatabase;
   
       private String databaseName;
   
  +
       /**
  -     * Get the xml schema describing the application
  -     * model.
  +     *  Get the xml schema describing the application
  +     *  model.
        *
  -     * @return String xml schema file.
  +     * @return  String xml schema file.
        */
  -    public String getXmlFile ()
  +    public String getXmlFile()
       {
           return xmlFile;
       }
   
  +
       /**
  -     * Set the xml schema describing the application
  -     * model.
  +     *  Set the xml schema describing the application
  +     *  model.
        *
  -     * @param String xml schema file.
  +     * @param  v The new XmlFile value
        */
       public void setXmlFile(String v)
       {
           xmlFile = v;
       }
   
  +
  +    /**
  +     *  Sets the DataXmlFile attribute of the TorqueDataSQLTask object
  +     *
  +     * @param  v The new DataXmlFile value
  +     */
       public void setDataXmlFile(String v)
       {
           dataXmlFile = v;
       }
   
  -    public String getDataXmlFile ()
  +
  +    /**
  +     *  Gets the DataXmlFile attribute of the TorqueDataSQLTask object
  +     *
  +     * @return  The DataXmlFile value
  +     */
  +    public String getDataXmlFile()
       {
           return dataXmlFile;
       }
  +
  +
       /**
  -     * Get the current target database.
  +     *  Get the current target database.
        *
  -     * @return String target database(s)
  +     * @return  String target database(s)
        */
  -    public String getTargetDatabase ()
  +    public String getTargetDatabase()
       {
           return targetDatabase;
       }
   
  +
       /**
  -     * Set the current target database.  This is where
  -     * generated java classes will live.
  +     *  Set the current target database.  This is where
  +     *  generated java classes will live.
        *
  -     * @param String target database(s)
  +     * @param  v The new TargetDatabase value
        */
  -    public void setTargetDatabase (String v)
  +    public void setTargetDatabase(String v)
       {
           targetDatabase = v;
       }
  +
   
  -    public String getDatabaseName ()
  +    /**
  +     *  Gets the DatabaseName attribute of the TorqueDataSQLTask object
  +     *
  +     * @return  The DatabaseName value
  +     */
  +    public String getDatabaseName()
       {
           return databaseName;
       }
  +
   
  -    public void setDatabaseName (String v)
  +    /**
  +     *  Sets the DatabaseName attribute of the TorqueDataSQLTask object
  +     *
  +     * @param  v The new DatabaseName value
  +     */
  +    public void setDatabaseName(String v)
       {
           databaseName = v;
       }
   
  -    public String getDataDTD ()
  +
  +    /**
  +     *  Gets the DataDTD attribute of the TorqueDataSQLTask object
  +     *
  +     * @return  The DataDTD value
  +     */
  +    public String getDataDTD()
       {
           return dataDTD;
       }
   
  -    public void setDataDTD (String v)
  +
  +    /**
  +     *  Sets the DataDTD attribute of the TorqueDataSQLTask object
  +     *
  +     * @param  v The new DataDTD value
  +     */
  +    public void setDataDTD(String v)
       {
           dataDTD = v;
       }
   
  +
       /**
  -     * Set up the initialial context for generating the
  -     * SQL from the XML schema.
  +     *  Set up the initialial context for generating the
  +     *  SQL from the XML schema.
  +     *
  +     * @return  Description of the Returned Value
        */
       public Context initControlContext()
       {
  @@ -182,7 +225,7 @@
            * Create a new Velocity context.
            */
           Context context = new VelocityContext();
  -        
  +
           /*
            * Transform the XML database schema into an
            * object that represents our model.
  @@ -191,13 +234,13 @@
           app = xmlParser.parseFile(xmlFile);
   
           Database db = app.getDatabase(databaseName);
  -        if (db==null)
  +        if (db == null)
           {
               db = app.getDatabases()[0];
           }
           try
           {
  -            XmlToData dataXmlParser = new XmlToData(db,dataDTD);
  +            XmlToData dataXmlParser = new XmlToData(db, dataDTD);
               List data = dataXmlParser.parseFile(dataXmlFile);
               context.put("data", data);
           }
  @@ -219,6 +262,5 @@
           return context;
       }
   }
  -
   
   
  
  
  

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

Reply via email to