You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by pr...@apache.org on 2002/12/01 03:23:40 UTC

cvs commit: jakarta-commons-sandbox/periodicity/src/plugins-build/database/src/java/org/apache/commons/periodicity/database DatabaseMetaDataImpl.java

prickett    2002/11/30 18:23:40

  Modified:    periodicity/src/plugins-build/database/src/java/org/apache/commons/periodicity/database
                        DatabaseMetaDataImpl.java
  Log:
  Removed the setUrl method because getUrl is going to be computed
  
  Added code to set the default driver in the constructor
  
  Added code in getDriver to return the default driver if driver is null
  
  Added code in getProtocol to return the default protocol if protocol is null
  
  Added getDefaultDriver() and setDefaultDriver() methods
  
  Added a computed getScheme() field
  
  Revision  Changes    Path
  1.10      +87 -22    jakarta-commons-sandbox/periodicity/src/plugins-build/database/src/java/org/apache/commons/periodicity/database/DatabaseMetaDataImpl.java
  
  Index: DatabaseMetaDataImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/periodicity/src/plugins-build/database/src/java/org/apache/commons/periodicity/database/DatabaseMetaDataImpl.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- DatabaseMetaDataImpl.java	1 Dec 2002 00:28:38 -0000	1.9
  +++ DatabaseMetaDataImpl.java	1 Dec 2002 02:23:40 -0000	1.10
  @@ -66,6 +66,9 @@
   
   public class DatabaseMetaDataImpl implements DatabaseMetaData
   {
  +
  +    public static final String DEFAULT_DRIVER_NAME_EXTENSION = ".default";
  +
       /** A variable to hold the name of the database */
       private String name = null;
   
  @@ -101,7 +104,9 @@
   
       /** A variable to hold the database path */
       private String databasePath = null;
  -    
  +
  +    /** A variable to hold the default driver name */
  +    private String defaultDriverName = null;
   
       /**
        * The purpose of this method is to create a new database meta data
  @@ -114,6 +119,10 @@
           if(newType != null)
           {
               setType(newType);
  +            StringBuffer buffy = new StringBuffer();
  +            buffy.append(getType());
  +            buffy.append(DEFAULT_DRIVER_NAME_EXTENSION);
  +            setDefaultDriver(buffy.toString());
           }
           else if(newType == null)
           {
  @@ -195,22 +204,6 @@
       }
   
       /**
  -     * The purpose of this method is to set the url of the database.
  -     * @param newval The new value of the url as a string.
  -     */
  -    private void setUrl(String newval) throws Exception
  -    {
  -        if(newval != null)
  -        {
  -            dbUrl = newval;
  -        }
  -        else
  -        {
  -            throw new Exception("newval == null");
  -        }
  -    }
  -
  -    /**
        * The purpose of this method is to return the short description 
        * of the database.
        * @return The short description of the database as a string.
  @@ -276,7 +269,14 @@
        */
       public String getDriver()
       {
  -        return driverName;
  +        if(driverName != null)
  +        {
  +            return driverName;
  +        }
  +        else
  +        {
  +            return getDefaultDriver(); 
  +        }    
       }
   
       /**
  @@ -296,7 +296,14 @@
        */
       public String getProtocol()
       {
  -        return protocolName;
  +        if(protocolName != null)
  +        {
  +            return protocolName;
  +        }
  +        else
  +        {
  +            return DriverProtocol.DEFAULT_PROTOCOL_NAME;
  +        }    
       }
   
       /**
  @@ -387,6 +394,64 @@
       public void setDatabasePath(String newval)
       {
           databasePath = newval;
  +    }    
  +
  +    /**
  +     * The purpose of this method is to get the default driver for this
  +     * type of database.
  +     * @return The default driver name as a string.
  +     */
  +    public String getDefaultDriver()
  +    {
  +        return defaultDriverName;
  +    }
  +
  +    /**
  +     * The purpose of this method is set the default driver for this type of
  +     * database.
  +     * @param newval The new value for the default driver as a string.
  +     */
  +    void setDefaultDriver(String newval)
  +    {
  +        defaultDriverName = newval;
  +    }
  +
  +    /**
  +     * The purpose of this method is to return the scheme of the database.
  +     * @return The scheme of the database as a string.
  +     */
  +    public String getScheme() throws Exception
  +    {
  +        DriverMetaDataImpl dmeta = 
  +               (DriverMetaDataImpl) PeriodicityDrivers.getMetaData(getDriver());
  +        if(dmeta != null && getProtocol() != null)
  +        {
  +            DriverProtocol protocol = dmeta.getProtocol(getProtocol());
  +            if(protocol != null)
  +            {
  +                return protocol.getScheme();
  +            }
  +            else if(protocol == null)
  +            {
  +                throw new Exception("protocol == null");
  +            }
  +            else
  +            {
  +                throw new Exception("UNEXPECTED EXCEPTION");
  +            }
  +        }
  +        else if(dmeta == null)
  +        {
  +            throw new Exception("dmeta == null");
  +        }
  +        else if(getProtocol() == null)
  +        {
  +            throw new Exception("getProtocol() == null");
  +        }
  +        else
  +        {
  +            throw new Exception("UNEXPECTED EXCEPTION");
  +        }    
       }    
   
       public String toString()
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>