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.derby;
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.LobType;
023: import org.castor.ddlgen.typeinfo.NoParamType;
024: import org.castor.ddlgen.typeinfo.OptionalLengthType;
025: import org.castor.ddlgen.typeinfo.OptionalPrecisionDecimalsType;
026: import org.castor.ddlgen.typeinfo.OptionalPrecisionType;
027: import org.castor.ddlgen.typeinfo.RequiredLengthType;
028:
029: /**
030: * Final TypeMapper for Derby database.
031: *
032: * @author <a href="mailto:leducbao AT gmail DOT com">Le Duc Bao</a>
033: * @author <a href="mailto:ralf DOT joachim AT syscon DOT eu">Ralf Joachim</a>
034: * @version $Revision: 5951 $ $Date: 2006-04-25 16:09:10 -0600 (Tue, 25 Apr 2006) $
035: * @since 1.1
036: */
037: public final class DerbyTypeMapper extends AbstractTypeMapper {
038: //--------------------------------------------------------------------------
039:
040: /** The <a href="http://jakarta.apache.org/commons/logging/">Jakarta Commons
041: * Logging </a> instance used for all logging. */
042: private static final Log LOG = LogFactory
043: .getLog(DerbyTypeMapper.class);
044:
045: //--------------------------------------------------------------------------
046:
047: /**
048: * Construct a TypeMapper for Derby database using given configuration to get default
049: * parameters for parameterized types.
050: *
051: * @param conf The configuration to get default parameter values from.
052: */
053: public DerbyTypeMapper(final DDLGenConfiguration conf) {
054: super (conf);
055: }
056:
057: //--------------------------------------------------------------------------
058:
059: /**
060: * {@inheritDoc}
061: */
062: protected void initialize(final DDLGenConfiguration conf) {
063: // numeric types
064: this .add(new NoParamType("bit", "CHAR FOR BIT DATA"));
065: LOG
066: .warn("Derby does not support 'TINY' type, use SMALLINT instead.");
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: this .add(new NoParamType("bigint", "BIGINT"));
072:
073: this .add(new OptionalPrecisionType("float", "FLOAT", conf));
074: this .add(new NoParamType("double", "DOUBLE"));
075: this .add(new NoParamType("real", "REAL"));
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: this .add(new NoParamType("longvarchar", "LONG VARCHAR"));
085:
086: // date and time types
087: this .add(new NoParamType("date", "DATE"));
088: this .add(new NoParamType("time", "TIME"));
089: this .add(new NoParamType("timestamp", "TIMESTAMP"));
090:
091: // other types
092: this .add(new OptionalLengthType("binary", "CHAR",
093: " FOR BIT DATA", conf));
094: this .add(new RequiredLengthType("varbinary", "VARCHAR",
095: " FOR BIT DATA", conf));
096: this .add(new NoParamType("longvarbinary",
097: "LONG VARCHAR FOR BIT DATA"));
098:
099: this .add(new LobType("other", "BLOB", conf));
100: this .add(new LobType("javaobject", "BLOB", conf));
101: this .add(new LobType("blob", "BLOB", conf));
102: this .add(new LobType("clob", "CLOB", conf));
103: }
104:
105: //--------------------------------------------------------------------------
106: }
|