001: /*
002: * Copyright 2006 Le Duc Bao, Ralf Joachim
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License"); you may not
005: * use this file except in compliance with the License. You may obtain a copy of
006: * the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
012: * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
013: * License for the specific language governing permissions and limitations under
014: * the License.
015: */
016: package org.castor.ddlgen.engine.sapdb;
017:
018: import org.apache.commons.logging.Log;
019: import org.apache.commons.logging.LogFactory;
020: import org.castor.ddlgen.AbstractTypeMapper;
021: import org.castor.ddlgen.DDLGenConfiguration;
022: import org.castor.ddlgen.typeinfo.NoParamType;
023: import org.castor.ddlgen.typeinfo.OptionalLengthType;
024: import org.castor.ddlgen.typeinfo.OptionalPrecisionDecimalsType;
025: import org.castor.ddlgen.typeinfo.RequiredLengthType;
026:
027: /**
028: * Final TypeMapper for SapDB database.
029: *
030: * @author <a href="mailto:leducbao AT gmail DOT com">Le Duc Bao</a>
031: * @author <a href="mailto:ralf DOT joachim AT syscon DOT eu">Ralf Joachim</a>
032: * @version $Revision: 5951 $ $Date: 2006-04-25 16:09:10 -0600 (Tue, 25 Apr 2006) $
033: * @since 1.1
034: */
035: public final class SapdbTypeMapper extends AbstractTypeMapper {
036: //--------------------------------------------------------------------------
037:
038: /** The <a href="http://jakarta.apache.org/commons/logging/">Jakarta Commons
039: * Logging </a> instance used for all logging. */
040: private static final Log LOG = LogFactory
041: .getLog(SapdbTypeMapper.class);
042:
043: //--------------------------------------------------------------------------
044:
045: /**
046: * Construct a TypeMapper for Sapdb database using given configuration to get default
047: * parameters for parameterized types.
048: *
049: * @param conf The configuration to get default parameter values from.
050: */
051: public SapdbTypeMapper(final DDLGenConfiguration conf) {
052: super (conf);
053: }
054:
055: //--------------------------------------------------------------------------
056:
057: /**
058: * {@inheritDoc}
059: */
060: protected void initialize(final DDLGenConfiguration conf) {
061: // numeric types
062: this .add(new NoParamType("bit", "BOOLEAN"));
063: LOG
064: .warn("SapDB does not support 'TINYINT' type, use SMALLINT instead.");
065: this .add(new NoParamType("tinyint", "SMALLINT"));
066: this .add(new NoParamType("smallint", "SMALLINT"));
067: this .add(new NoParamType("integer", "INTEGER"));
068: this .add(new NoParamType("int", "INTEGER"));
069: LOG
070: .warn("SapDB does not support 'BIGINT' type, use NUMERIC instead.");
071: this .add(new NoParamType("bigint", "NUMERIC"));
072:
073: this .add(new OptionalLengthType("float", "FLOAT", conf));
074: this .add(new NoParamType("double", "DOUBLE PRECISION"));
075: this .add(new NoParamType("real", "DOUBLE PRECISION"));
076: this .add(new OptionalPrecisionDecimalsType("numeric",
077: "NUMERIC", conf));
078: this .add(new OptionalPrecisionDecimalsType("decimal",
079: "DECIMAL", conf));
080:
081: // character types
082: this .add(new OptionalLengthType("char", "CHAR", conf));
083: this .add(new RequiredLengthType("varchar", "VARCHAR", conf));
084: LOG
085: .warn("SapDB does not support 'LONGVARCHAR' type, use LONG instead.");
086: this .add(new RequiredLengthType("longvarchar", "LONG", conf));
087:
088: // date and time types
089: this .add(new NoParamType("date", "DATE"));
090: this .add(new NoParamType("time", "TIME"));
091: this .add(new NoParamType("timestamp", "TIMESTAMP"));
092:
093: // other types
094: LOG
095: .warn("SapDB does not support 'BINARY' type, use BLOB instead.");
096: this .add(new NoParamType("binary", "BLOB"));
097: LOG
098: .warn("SapDB does not support 'VARBINARY' type, use BLOB instead.");
099: this .add(new NoParamType("varbinary", "BLOB"));
100: LOG
101: .warn("SapDB does not support 'LONGVARBINARY' type, use BLOB instead.");
102: this .add(new NoParamType("longvarbinary", "BLOB"));
103:
104: this .add(new NoParamType("other", "BLOB"));
105: this .add(new NoParamType("javaobject", "BLOB"));
106: this .add(new NoParamType("blob", "BLOB"));
107: this .add(new NoParamType("clob", "CLOB"));
108: }
109:
110: //--------------------------------------------------------------------------
111: }
|