| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| Platform |
|
| 1.0;1 |
| 1 | package org.apache.torque.engine.platform; | |
| 2 | ||
| 3 | /* | |
| 4 | * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE | |
| 5 | * file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file | |
| 6 | * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the | |
| 7 | * License. You may obtain a copy of the License at | |
| 8 | * | |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 | |
| 10 | * | |
| 11 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | |
| 12 | * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | |
| 13 | * specific language governing permissions and limitations under the License. | |
| 14 | */ | |
| 15 | ||
| 16 | import java.sql.Connection; | |
| 17 | import java.sql.DatabaseMetaData; | |
| 18 | import java.sql.SQLException; | |
| 19 | import java.util.List; | |
| 20 | ||
| 21 | import org.apache.torque.engine.database.model.Domain; | |
| 22 | import org.apache.torque.engine.database.model.SchemaType; | |
| 23 | ||
| 24 | /** | |
| 25 | * Interface for RDBMS platform specific behaviour. | |
| 26 | * | |
| 27 | * @author <a href="mailto:mpoeschl@marmot.at">Martin Poeschl</a> | |
| 28 | * @version $Id: Platform.java,v 1.1.6.2 2008-04-18 17:04:37 jkeller Exp $ | |
| 29 | */ | |
| 30 | public interface Platform { | |
| 31 | /** constant for native id method */ | |
| 32 | String IDENTITY = "identity"; | |
| 33 | /** constant for native id method */ | |
| 34 | String SEQUENCE = "sequence"; | |
| 35 | ||
| 36 | /** | |
| 37 | * Given a JDBC url return a url that can connect directly to the database server itself. ie no database specified | |
| 38 | */ | |
| 39 | String getServerUrl(String url); | |
| 40 | ||
| 41 | /** | |
| 42 | * Given an artifact id, return a string a schema name based on the artifact id that is allowed by the db vendor | |
| 43 | */ | |
| 44 | String getSchemaName(String artifactId); | |
| 45 | ||
| 46 | /** | |
| 47 | * Returns the native IdMethod (sequence|identity) | |
| 48 | * | |
| 49 | * @return the native IdMethod | |
| 50 | */ | |
| 51 | String getNativeIdMethod(); | |
| 52 | ||
| 53 | /** | |
| 54 | * Returns the max column length supported by the db. | |
| 55 | * | |
| 56 | * @return the max column length | |
| 57 | */ | |
| 58 | int getMaxColumnNameLength(); | |
| 59 | ||
| 60 | /** | |
| 61 | * Returns the db specific domain for a jdbcType. | |
| 62 | * | |
| 63 | * @param jdbcType | |
| 64 | * the jdbcType name | |
| 65 | * @return the db specific domain | |
| 66 | */ | |
| 67 | Domain getDomainForSchemaType(SchemaType jdbcType); | |
| 68 | ||
| 69 | /** | |
| 70 | * @return The RDBMS-specific SQL fragment for <code>NULL</code> or <code>NOT NULL</code>. | |
| 71 | */ | |
| 72 | String getNullString(boolean notNull); | |
| 73 | ||
| 74 | /** | |
| 75 | * @return The RDBMS-specific SQL fragment for autoincrement. | |
| 76 | */ | |
| 77 | String getAutoIncrement(); | |
| 78 | ||
| 79 | /** | |
| 80 | * Returns if the RDBMS-specific SQL type has a size attribute. | |
| 81 | * | |
| 82 | * @param sqlType | |
| 83 | * the SQL type | |
| 84 | * @return true if the type has a size attribute | |
| 85 | */ | |
| 86 | boolean hasSize(String sqlType); | |
| 87 | ||
| 88 | /** | |
| 89 | * Returns if the RDBMS-specific SQL type has a scale attribute. | |
| 90 | * | |
| 91 | * @param sqlType | |
| 92 | * the SQL type | |
| 93 | * @return true if the type has a scale attribute | |
| 94 | */ | |
| 95 | boolean hasScale(String sqlType); | |
| 96 | ||
| 97 | /** | |
| 98 | * Returns whether the "not null part" of the definition of a column should be generated before the | |
| 99 | * "autoincrement part" in a "create table" statement. | |
| 100 | * | |
| 101 | * @return true if the "not null part" should be first, false if the "autoincrement part" should be first in a | |
| 102 | * "create table" statement. | |
| 103 | */ | |
| 104 | boolean createNotNullBeforeAutoincrement(); | |
| 105 | ||
| 106 | String filterInvalidDefaultValues(String defaultValue); | |
| 107 | ||
| 108 | public boolean isSpecialDefault(String defaultValue); | |
| 109 | ||
| 110 | String getViewDefinition(Connection con, String schema, String viewName); | |
| 111 | ||
| 112 | Long getSequenceNextVal(Connection con, String schema, String sequenceName); | |
| 113 | ||
| 114 | public List<String> getPrimaryKeys(DatabaseMetaData dbMeta, String dbSchema, String tableName) throws SQLException; | |
| 115 | ||
| 116 | public List<String> getTableNames(DatabaseMetaData dbMeta, String databaseSchema) throws SQLException; | |
| 117 | } |