01: /**
02: * Sequoia: Database clustering technology.
03: * Copyright (C) 2002-2004 French National Institute For Research In Computer
04: * Science And Control (INRIA).
05: * Contact: sequoia@continuent.org
06: *
07: * Licensed under the Apache License, Version 2.0 (the "License");
08: * you may not use this file except in compliance with the License.
09: * You may obtain a copy of the License at
10: *
11: * http://www.apache.org/licenses/LICENSE-2.0
12: *
13: * Unless required by applicable law or agreed to in writing, software
14: * distributed under the License is distributed on an "AS IS" BASIS,
15: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16: * See the License for the specific language governing permissions and
17: * limitations under the License.
18: *
19: * Initial developer(s): Nicolas Modrzyk.
20: * Contributor(s):
21: */package org.continuent.sequoia.controller.backend;
22:
23: import org.continuent.sequoia.common.xml.DatabasesXmlTags;
24:
25: /**
26: * Mapping for dynamic schema gathering and validation
27: *
28: * @author <a href="mailto:Nicolas.Modrzyk@inrialpes.fr">Nicolas Modrzyk </a>
29: */
30: public abstract class DatabaseBackendSchemaConstants {
31: /** Static level no dynamic schema */
32: public static final int DynamicPrecisionStatic = 0;
33: /** Table level for dynamic schema */
34: public static final int DynamicPrecisionTable = 1;
35: /** Column level for dynamic schema */
36: public static final int DynamicPrecisionColumn = 2;
37: /** procedures names level for dynamic schema */
38: public static final int DynamicPrecisionProcedures = 3;
39: /** All level for dynamic schema, procedures parameters are retrieved */
40: public static final int DynamicPrecisionAll = 4;
41:
42: /**
43: * Get the dynamic schema level from string to int
44: *
45: * @param stringLevel as a string from <code>DatabaseXmlTags</code>
46: * @return an int
47: */
48: public static int getDynamicSchemaLevel(String stringLevel) {
49: if (stringLevel.equalsIgnoreCase(DatabasesXmlTags.VAL_static))
50: return DynamicPrecisionStatic;
51: else if (stringLevel
52: .equalsIgnoreCase(DatabasesXmlTags.VAL_table))
53: return DynamicPrecisionTable;
54: else if (stringLevel
55: .equalsIgnoreCase(DatabasesXmlTags.VAL_column))
56: return DynamicPrecisionColumn;
57: else if (stringLevel
58: .equalsIgnoreCase(DatabasesXmlTags.VAL_procedures))
59: return DynamicPrecisionProcedures;
60: else if (stringLevel.equalsIgnoreCase(DatabasesXmlTags.VAL_all))
61: return DynamicPrecisionAll;
62: else
63: throw new IllegalArgumentException(
64: "Invalid dynamic precision " + stringLevel);
65: }
66:
67: /**
68: * Get the dynamic schema level from int to string
69: *
70: * @param intLevel as an int
71: * @return string taken from <code>DatabaseXmlTags</code>
72: */
73: public static String getDynamicSchemaLevel(int intLevel) {
74: switch (intLevel) {
75: case DynamicPrecisionStatic:
76: return DatabasesXmlTags.VAL_static;
77: case DynamicPrecisionTable:
78: return DatabasesXmlTags.VAL_table;
79: case DynamicPrecisionColumn:
80: return DatabasesXmlTags.VAL_column;
81: case DynamicPrecisionProcedures:
82: return DatabasesXmlTags.VAL_procedures;
83: case DynamicPrecisionAll:
84: return DatabasesXmlTags.VAL_all;
85: default:
86: return DatabasesXmlTags.VAL_all;
87: }
88: }
89: }
|