dlr         01/08/22 13:04:33

  Modified:    src/java/org/apache/torque/engine/database/model
                        Database.java
  Log:
  * Added database type instance variable.
  
  * Made setName() smarter.
  
  * Added getProperty() accessor for retrieving values from db.props.
  
  Revision  Changes    Path
  1.3       +37 -12    
jakarta-turbine-torque/src/java/org/apache/torque/engine/database/model/Database.java
  
  Index: Database.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-torque/src/java/org/apache/torque/engine/database/model/Database.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -u -r1.2 -r1.3
  --- Database.java     2001/08/21 00:12:28     1.2
  +++ Database.java     2001/08/22 20:04:33     1.3
  @@ -58,19 +58,25 @@
   import java.util.Hashtable;
   import java.util.Iterator;
   import java.util.List;
  +import java.util.Properties;
   
   import org.xml.sax.Attributes;
   
  +import org.apache.torque.Torque;
  +import org.apache.torque.TorqueException;
  +
   /**
    * A class for holding application data structures.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]>Leon Messerschmidt</a>
    * @author <a href="mailto:[EMAIL PROTECTED]>John McNally</a>
    * @author <a href="mailto:[EMAIL PROTECTED]>Martin Poeschl</a>
  - * @version $Id: Database.java,v 1.2 2001/08/21 00:12:28 dlr Exp $
  + * @author <a href="mailto:[EMAIL PROTECTED]>Daniel Rall</a>
  + * @version $Id: Database.java,v 1.3 2001/08/22 20:04:33 dlr Exp $
    */
   public class Database
   {
  +    private String databaseType = null;
       private List tableList = new ArrayList(100);
       private Column curColumn;
       private String name;
  @@ -83,7 +89,7 @@
       private Hashtable tablesByJavaName = new Hashtable();
   
       /**
  -     * Default Constructor
  +     * Creates a new instance with unset attributes.
        */
       public Database()
       {
  @@ -92,15 +98,9 @@
       /**
        * Load the database object from an xml tag.
        */
  -    public void loadFromXML (Attributes attrib)
  +    public void loadFromXML(Attributes attrib)
       {
  -        name = attrib.getValue("name");
  -        if ( name == null )
  -        {
  -            //!! Hard coding this for now. It should
  -            // be a property.
  -            name =  "default";
  -        }
  +        setName(attrib.getValue("name"));
           pkg = attrib.getValue("package");
           baseClass = attrib.getValue("baseClass");
           basePeer = attrib.getValue("basePeer");
  @@ -118,9 +118,9 @@
       /**
        * Set the name of the Database
        */
  -    public void setName(String newName)
  +    public void setName(String name)
       {
  -        name = newName;
  +        this.name = (name == null ? Torque.getDefaultDB() : name);
       }
   
       /**
  @@ -273,6 +273,31 @@
       public AppData getAppData()
       {
           return dbParent;
  +    }
  +
  +    protected String getDatabaseType()
  +    {
  +        return databaseType;
  +    }
  +
  +    public void setDatabaseType(String databaseType)
  +    {
  +        this.databaseType = databaseType;
  +    }
  +
  +    /**
  +     * Returns the value of the named property from this database's
  +     * <code>db.props</code> file.
  +     *
  +     * @param name The name of the property to retrieve the value of.
  +     * @return The value of the specified property.
  +     * @exception TorqueException Couldn't access properties.
  +     */
  +    protected String getProperty(String name)
  +        throws TorqueException
  +    {
  +        Properties p = getAppData().getIdiosyncrasies(databaseType);
  +        return (p == null ? null : p.getProperty(name));
       }
   
       /**
  
  
  

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

Reply via email to