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.sybase;
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.OptionalPrecisionDecimalsType;
024: import org.castor.ddlgen.typeinfo.RequiredLengthType;
025: import org.castor.ddlgen.typeinfo.RequiredPrecisionType;
026:
027: /**
028: * Final TypeMapper for Sybase 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 SybaseTypeMapper 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(SybaseTypeMapper.class);
042:
043: //--------------------------------------------------------------------------
044:
045: /**
046: * Construct a TypeMapper for Sybase database using given configuration to
047: * get default parameters for parameterized types.
048: *
049: * @param conf The configuration to get default parameter values from.
050: */
051: public SybaseTypeMapper(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", "BIT"));
063: this .add(new NoParamType("tinyint", "TINYINT"));
064: this .add(new NoParamType("smallint", "SMALLINT"));
065: this .add(new NoParamType("integer", "INTEGER"));
066: this .add(new NoParamType("int", "INTEGER"));
067: LOG
068: .warn("Sybase does not support 'BIGINT' type, use NUMERIC instead.");
069: this .add(new NoParamType("bigint", "NUMERIC"));
070:
071: this .add(new RequiredPrecisionType("float", "FLOAT", conf));
072: this .add(new NoParamType("double", "DOUBLE PRECISION"));
073: this .add(new NoParamType("real", "REAL"));
074: this .add(new OptionalPrecisionDecimalsType("numeric",
075: "NUMERIC", conf));
076: this .add(new OptionalPrecisionDecimalsType("decimal",
077: "DECIMAL", conf));
078:
079: // character types
080: this .add(new RequiredLengthType("char", "CHAR", conf));
081: this .add(new RequiredLengthType("varchar", "VARCHAR", conf));
082: LOG
083: .warn("Sybase does not support 'LONGVARCHAR' type, use TEXT instead.");
084: this .add(new NoParamType("longvarchar", "TEXT"));
085:
086: // date and time types
087: this .add(new NoParamType("date", "DATETIME"));
088: this .add(new NoParamType("time", "DATETIME"));
089: this .add(new NoParamType("timestamp", "TIMESTAMP"));
090:
091: // other types
092: this .add(new RequiredLengthType("binary", "BINARY", conf));
093: this
094: .add(new RequiredLengthType("varbinary", "VARBINARY",
095: conf));
096: LOG
097: .warn("Sybase does not support 'LONGVARBINARY' type, use VARBINARY instead.");
098: this .add(new RequiredLengthType("longvarbinary", "VARBINARY",
099: conf));
100:
101: this .add(new NoParamType("other", "IMAGE"));
102: this .add(new NoParamType("javaobject", "IMAGE"));
103: this .add(new NoParamType("blob", "IMAGE"));
104: this .add(new NoParamType("clob", "TEXT"));
105: }
106:
107: //--------------------------------------------------------------------------
108: }
|