Main Page | Packages | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

OctopusConstants.java

00001 /**
00002  * C-JDBC: Clustered JDBC.
00003  * Copyright (C) 2002-2004 French National Institute For Research In Computer
00004  * Science And Control (INRIA).
00005  * Contact: c-jdbc@objectweb.org
00006  * 
00007  * This library is free software; you can redistribute it and/or modify it
00008  * under the terms of the GNU Lesser General Public License as published by the
00009  * Free Software Foundation; either version 2.1 of the License, or any later
00010  * version.
00011  * 
00012  * This library is distributed in the hope that it will be useful, but WITHOUT
00013  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00014  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
00015  * for more details.
00016  * 
00017  * You should have received a copy of the GNU Lesser General Public License
00018  * along with this library; if not, write to the Free Software Foundation,
00019  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
00020  *
00021  * Initial developer(s): Nicolas Modrzyk 
00022  * Contributor(s):
00023  */
00024 
00025 package org.objectweb.cjdbc.controller.backup;
00026 
00027 import java.util.Hashtable;
00028 
00029 /**
00030  * Class to map useful values for octopus
00031  * 
00032  * @author <a href="mailto:Nicolas.Modrzyk@inrialpes.fr">Nicolas Modrzyk </a>
00033  */
00034 public final class OctopusConstants
00035 {
00036   static final int       FROM_URL   = 0;
00037   static final int       DRIVER     = 1;
00038   static final int       FULL_NAME  = 2;
00039   static final int       PREFIX_URL = 3;
00040 
00041   // four values ... this is REALLY dirty but I see no other way to deal with
00042   // octopus constants ...
00043   // 1. If we parse the url, what can describe the db we're dealing with
00044   // 2. In octopus specific conf file, <Driver name="hsql">
00045   // 3. In octopus general vendors file, what driver are we using ...
00046   // 4. the part of the url, octopus adds up automatically, from conf file
00047 
00048   static final String[]  HSQL       = {"hsqldb", "hsql", "HypersonicSQL",
00049       "jdbc:hsqldb:"                };
00050   static final String[]  CSV        = {"csv", "csv", "Csv", "jdbc:relique:csv:"};
00051   static final String[]  MYSQL      = {"mysql", "mm", "MySQL", "jdbc:mysql://"};
00052   static final String[]  POSTGRESQL = {"postgresql", "postgresql",
00053       "PostgreSQL", "jdbc:postgresql://"};
00054   static final String[]  ORACLE     = {"oracle", "oracle", "Oracle",
00055       "jdbc:oracle:thin:"           };
00056   static final String[]  JTURBO     = {"jTurbo", "jTurbo", "MSQL",
00057       "jdbc:JTurbo://"              };
00058   static final String[]  MSSQL      = {"microsoft", "microsoft", "MSQL",
00059       "jdbc:microsoft:sqlserver://" };
00060 
00061   static final Hashtable TYPES;
00062   static
00063   {
00064     TYPES = new Hashtable();
00065     TYPES.put(HSQL[0], HSQL);
00066     TYPES.put(CSV[0], CSV);
00067     TYPES.put(MYSQL[0], MYSQL);
00068     TYPES.put(ORACLE[0], ORACLE);
00069     TYPES.put(POSTGRESQL[0], POSTGRESQL);
00070     TYPES.put(JTURBO[0], JTURBO);
00071     TYPES.put(MSSQL[0], MSSQL);
00072   }
00073 
00074   /**
00075    * Get octopus type.
00076    * 
00077    * @param type from url
00078    * @return value from hashtable or null
00079    */
00080   public static String getOctopusType(String type)
00081   {
00082     if (type == null)
00083       return null;
00084     return ((String[]) TYPES.get(type))[FULL_NAME];
00085   }
00086 
00087   /**
00088    * Get octopus driver.
00089    * 
00090    * @param type from url
00091    * @return value from hashtable or null
00092    */
00093   public static String getOctopusDriver(String type)
00094   {
00095     if (type == null)
00096       return null;
00097     return ((String[]) TYPES.get(type))[DRIVER];
00098   }
00099 
00100   /**
00101    * Get Octopus url prefix
00102    * 
00103    * @param type from url
00104    * @return value from hashtable or null
00105    */
00106   public static String getUrlPrefix(String type)
00107   {
00108     if (type == null)
00109       return null;
00110     return ((String[]) TYPES.get(type))[PREFIX_URL];
00111   }
00112 
00113 }

Generated on Mon Apr 11 22:01:32 2005 for C-JDBC by  doxygen 1.3.9.1