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.pointbase;
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: import org.castor.ddlgen.typeinfo.RequiredPrecisionType;
027:
028: /**
029: * Final TypeMapper for PointBase database.
030: *
031: * @author <a href="mailto:leducbao AT gmail DOT com">Le Duc Bao</a>
032: * @author <a href="mailto:ralf DOT joachim AT syscon DOT eu">Ralf Joachim</a>
033: * @version $Revision: 5951 $ $Date: 2006-04-25 16:09:10 -0600 (Tue, 25 Apr 2006) $
034: * @since 1.1
035: */
036: public final class PointBaseTypeMapper extends AbstractTypeMapper {
037: //--------------------------------------------------------------------------
038:
039: /** The <a href="http://jakarta.apache.org/commons/logging/">Jakarta Commons
040: * Logging </a> instance used for all logging. */
041: private static final Log LOG = LogFactory
042: .getLog(PointBaseTypeMapper.class);
043:
044: //--------------------------------------------------------------------------
045:
046: /**
047: * Construct a TypeMapper for PointBase database using given configuration to
048: * get default parameters for parameterized types.
049: *
050: * @param conf The configuration to get default parameter values from.
051: */
052: public PointBaseTypeMapper(final DDLGenConfiguration conf) {
053: super (conf);
054: }
055:
056: //--------------------------------------------------------------------------
057:
058: /**
059: * {@inheritDoc}
060: * <br/>
061: * Refer to http://www.ipd.uka.de/~oosem/mobiledb/pb/docs/server_embedded/html
062: * /htmlfiles/dev_datatypesandconversionsFIN.html#1027969.
063: */
064: protected void initialize(final DDLGenConfiguration conf) {
065: // numeric types
066: this .add(new NoParamType("bit", "BOOLEAN"));
067: this .add(new NoParamType("tinyint", "SMALLINT"));
068: this .add(new NoParamType("smallint", "SMALLINT"));
069: this .add(new NoParamType("integer", "INTEGER"));
070: this .add(new NoParamType("int", "INTEGER"));
071: LOG
072: .warn("PointBase does not support 'BIGINT' type, use NUMERIC instead.");
073: this .add(new OptionalPrecisionDecimalsType("bigint", "NUMERIC",
074: conf));
075:
076: this .add(new RequiredPrecisionType("float", "FLOAT", conf));
077: this .add(new NoParamType("double", "DOUBLE PRECISION"));
078: this .add(new NoParamType("real", "REAL"));
079: this .add(new OptionalPrecisionDecimalsType("numeric",
080: "NUMERIC", conf));
081: this .add(new OptionalPrecisionDecimalsType("decimal",
082: "DECIMAL", conf));
083:
084: // character types
085: this .add(new OptionalLengthType("char", "CHAR", conf));
086: this .add(new RequiredLengthType("varchar", "VARCHAR", conf));
087: LOG
088: .warn("PointBase does not support 'LOGVARCHAR' type, use CLOB instead.");
089: this .add(new OptionalLengthType("longvarchar", "CLOB", conf));
090:
091: // date and time types
092: this .add(new NoParamType("date", "DATE"));
093: this .add(new NoParamType("time", "TIME"));
094: this .add(new NoParamType("timestamp", "TIMESTAMP"));
095:
096: // other types
097: this .add(new OptionalLengthType("binary", "BLOB", conf));
098: this .add(new OptionalLengthType("varbinary", "BLOB", conf));
099: LOG
100: .warn("PointBase does not support 'LONGVARBINARY' type, use BLOB instead.");
101: this .add(new OptionalLengthType("longvarbinary", "BLOB", conf));
102:
103: this .add(new OptionalLengthType("other", "BLOB", conf));
104: this .add(new OptionalLengthType("javaobject", "BLOB", conf));
105: this .add(new OptionalLengthType("blob", "BLOB", conf));
106: this .add(new OptionalLengthType("clob", "CLOB", conf));
107: }
108:
109: //--------------------------------------------------------------------------
110: }
|