KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > cjdbc > console > wizard > objects > ConnectionTypeInfo


1 /**
2  * C-JDBC: Clustered JDBC.
3  * Copyright (C) 2002-2004 French National Institute For Research In Computer
4  * Science And Control (INRIA).
5  * Contact: c-jdbc@objectweb.org
6  *
7  * This library is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU Lesser General Public License as published by the
9  * Free Software Foundation; either version 2.1 of the License, or any later
10  * version.
11  *
12  * This library is distributed in the hope that it will be useful, but WITHOUT
13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
15  * for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public License
18  * along with this library; if not, write to the Free Software Foundation,
19  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
20  *
21  * Initial developer(s): Nicolas Modrzyk.
22  * Contributor(s): ______________________.
23  */

24
25 package org.objectweb.cjdbc.console.wizard.objects;
26
27 import java.util.ArrayList JavaDoc;
28
29 import org.objectweb.cjdbc.common.i18n.WizardTranslate;
30 import org.objectweb.cjdbc.console.wizard.WizardConstants;
31
32 /**
33  * This class defines a ConnectionTypeInfo, that is all the connection manager
34  * information.
35  *
36  * @author <a HREF="mailto:Nicolas.Modrzyk@inria.fr">Nicolas Modrzyk </a>
37  * @version 1.0
38  */

39 public class ConnectionTypeInfo
40 {
41
42   String JavaDoc type = WizardConstants.CONNECTION_MANAGERS[0];
43   final Exception JavaDoc badValue = new Exception JavaDoc("Bad Parameter");
44   private ArrayList JavaDoc values = new ArrayList JavaDoc();
45
46   /**
47    * Get the connection manager attributes.
48    *
49    * @return list of attributes
50    */

51   public String JavaDoc[] getAttributes()
52   {
53     if (type == WizardConstants.CONNECTION_MANAGERS[0])
54       return new String JavaDoc[]{};
55     if (type == WizardConstants.CONNECTION_MANAGERS[1])
56       return new String JavaDoc[]{WizardTranslate.get("label.poolSize")};
57     if (type == WizardConstants.CONNECTION_MANAGERS[2])
58       return new String JavaDoc[]{WizardTranslate.get("label.poolSize"),
59           WizardTranslate.get("label.timeout")};
60     if (type == WizardConstants.CONNECTION_MANAGERS[3])
61       return new String JavaDoc[]{WizardTranslate.get("label.initPoolSize"),
62           WizardTranslate.get("label.minPoolSize"),
63           WizardTranslate.get("label.maxPoolSize"),
64           WizardTranslate.get("label.idleTimeout"),
65           WizardTranslate.get("label.waitTimeout")};
66     else
67       return null;
68   }
69
70   /**
71    * Returns the values value.
72    *
73    * @return Returns the values.
74    */

75   public ArrayList JavaDoc getValues()
76   {
77     return values;
78   }
79
80   /**
81    * Get the index'th value.
82    *
83    * @param index the value index to look for
84    * @return the value
85    */

86   public int getValue(int index)
87   {
88     try
89     {
90       Object JavaDoc value = values.get(index);
91       if (value instanceof String JavaDoc)
92         return Integer.parseInt((String JavaDoc) value);
93       else if (value instanceof Integer JavaDoc)
94         return ((Integer JavaDoc) values.get(index)).intValue();
95       else
96         throw badValue;
97     }
98     catch (Exception JavaDoc e)
99     {
100       e.printStackTrace();
101       return 0;
102     }
103   }
104
105   /**
106    * Sets the values value.
107    *
108    * @param values The values to set.
109    */

110   public void setValues(ArrayList JavaDoc values)
111   {
112     this.values = values;
113   }
114
115   /**
116    * Returns the type value.
117    *
118    * @return Returns the type.
119    */

120   public String JavaDoc getType()
121   {
122     return type;
123   }
124
125   /**
126    * @see java.lang.Object#toString()
127    */

128   public String JavaDoc toString()
129   {
130     return type;
131   }
132
133   /**
134    * Sets the type value.
135    *
136    * @param type The type to set.
137    */

138   public void setType(String JavaDoc type)
139   {
140     this.type = type;
141   }
142 }
Popular Tags