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

ConnectionTypeInfo.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.console.wizard.objects;
00026 
00027 import java.util.ArrayList;
00028 
00029 import org.objectweb.cjdbc.common.i18n.WizardTranslate;
00030 import org.objectweb.cjdbc.console.wizard.WizardConstants;
00031 
00032 /**
00033  * This class defines a ConnectionTypeInfo, that is all the connection manager
00034  * information.
00035  * 
00036  * @author <a href="mailto:Nicolas.Modrzyk@inria.fr">Nicolas Modrzyk </a>
00037  * @version 1.0
00038  */
00039 public class ConnectionTypeInfo
00040 {
00041 
00042   String            type     = WizardConstants.CONNECTION_MANAGERS[0];
00043   final Exception   badValue = new Exception("Bad Parameter");
00044   private ArrayList values   = new ArrayList();
00045 
00046   public String[] getAttributes()
00047   {
00048     if (type == WizardConstants.CONNECTION_MANAGERS[0])
00049       return new String[]{};
00050     if (type == WizardConstants.CONNECTION_MANAGERS[1])
00051       return new String[]{WizardTranslate.get("label.poolSize")};
00052     if (type == WizardConstants.CONNECTION_MANAGERS[2])
00053       return new String[]{WizardTranslate.get("label.poolSize"),
00054           WizardTranslate.get("label.timeout")};
00055     if (type == WizardConstants.CONNECTION_MANAGERS[3])
00056       return new String[]{WizardTranslate.get("label.initPoolSize"),
00057           WizardTranslate.get("label.minPoolSize"),
00058           WizardTranslate.get("label.maxPoolSize"),
00059           WizardTranslate.get("label.idleTimeout"),
00060           WizardTranslate.get("label.waitTimeout")};
00061     else
00062       return null;
00063   }
00064 
00065   /**
00066    * Returns the values value.
00067    * 
00068    * @return Returns the values.
00069    */
00070   public ArrayList getValues()
00071   {
00072     return values;
00073   }
00074 
00075   public int getValue(int index)
00076   {
00077     try
00078     {
00079       Object value = values.get(index);
00080       if (value instanceof String)
00081         return Integer.parseInt((String) value);
00082       else if (value instanceof Integer)
00083         return ((Integer) values.get(index)).intValue();
00084       else
00085         throw badValue;
00086     }
00087     catch (Exception e)
00088     {
00089       e.printStackTrace();
00090       return 0;
00091     }
00092   }
00093 
00094   /**
00095    * Sets the values value.
00096    * 
00097    * @param values The values to set.
00098    */
00099   public void setValues(ArrayList values)
00100   {
00101     this.values = values;
00102   }
00103 
00104   /**
00105    * Returns the type value.
00106    * 
00107    * @return Returns the type.
00108    */
00109   public String getType()
00110   {
00111     return type;
00112   }
00113 
00114   public String toString()
00115   {
00116     return type;
00117   }
00118 
00119   /**
00120    * Sets the type value.
00121    * 
00122    * @param type The type to set.
00123    */
00124   public void setType(String type)
00125   {
00126     this.type = type;
00127   }
00128 }

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