KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > cjdbc > controller > backend > DatabaseBackendSchemaConstants


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.controller.backend;
26
27 import org.objectweb.cjdbc.common.xml.DatabasesXmlTags;
28
29 /**
30  * Mapping for dynamic schema gathering and validation
31  *
32  * @author <a HREF="mailto:Nicolas.Modrzyk@inrialpes.fr">Nicolas Modrzyk </a>
33  */

34 public abstract class DatabaseBackendSchemaConstants
35 {
36   /** Static level no dynamic schema */
37   public static final int DynamicPrecisionStatic = 0;
38   /** Table level for dynamic schema */
39   public static final int DynamicPrecisionTable = 1;
40   /** Column level for dynamic schema */
41   public static final int DynamicPrecisionColumn = 2;
42   /** procedures names level for dynamic schema */
43   public static final int DynamicPrecisionProcedures = 3;
44   /** All level for dynamic schema, procedures parameters are retrieved */
45   public static final int DynamicPrecisionAll = 4;
46
47   /**
48    * Get the dynamic schema level from string to int
49    *
50    * @param stringLevel as a string from <code>DatabaseXmlTags</code>
51    * @return an int
52    */

53   public static int getDynamicSchemaLevel(String JavaDoc stringLevel)
54   {
55     if (stringLevel.equalsIgnoreCase(DatabasesXmlTags.VAL_static))
56       return DynamicPrecisionStatic;
57     else if (stringLevel.equalsIgnoreCase(DatabasesXmlTags.VAL_table))
58       return DynamicPrecisionTable;
59     else if (stringLevel.equalsIgnoreCase(DatabasesXmlTags.VAL_column))
60       return DynamicPrecisionColumn;
61     else if (stringLevel.equalsIgnoreCase(DatabasesXmlTags.VAL_procedures))
62       return DynamicPrecisionProcedures;
63     else if (stringLevel.equalsIgnoreCase(DatabasesXmlTags.VAL_all))
64       return DynamicPrecisionAll;
65     else
66       throw new IllegalArgumentException JavaDoc("Invalid dynamic precision "
67           + stringLevel);
68   }
69
70   /**
71    * Get the dynamic schema level from int to string
72    *
73    * @param intLevel as an int
74    * @return string taken from <code>DatabaseXmlTags</code>
75    */

76   public static String JavaDoc getDynamicSchemaLevel(int intLevel)
77   {
78     switch (intLevel)
79     {
80       case DynamicPrecisionStatic :
81         return DatabasesXmlTags.VAL_static;
82       case DynamicPrecisionTable :
83         return DatabasesXmlTags.VAL_table;
84       case DynamicPrecisionColumn :
85         return DatabasesXmlTags.VAL_column;
86       case DynamicPrecisionProcedures :
87         return DatabasesXmlTags.VAL_procedures;
88       case DynamicPrecisionAll :
89         return DatabasesXmlTags.VAL_all;
90       default :
91         return DatabasesXmlTags.VAL_all;
92     }
93   }
94 }
Popular Tags