db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tfisc...@apache.org
Subject svn commit: r910600 [18/29] - in /db/torque/torque4/trunk: maven-torque-gf-plugin/ maven-torque-gf-plugin/src/ maven-torque-gf-plugin/src/main/ maven-torque-gf-plugin/src/main/java/ maven-torque-gf-plugin/src/main/java/org/ maven-torque-gf-plugin/src/m...
Date Tue, 16 Feb 2010 17:16:02 GMT
Added: db/torque/torque4/trunk/torque-generator/src/test/site/gettingStarted/src/main/torque-gf/templates/keyField.vm
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/site/gettingStarted/src/main/torque-gf/templates/keyField.vm?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/site/gettingStarted/src/main/torque-gf/templates/keyField.vm (added)
+++ db/torque/torque4/trunk/torque-generator/src/test/site/gettingStarted/src/main/torque-gf/templates/keyField.vm Tue Feb 16 17:15:43 2010
@@ -0,0 +1,19 @@
+## Licensed to the Apache Software Foundation (ASF) under one
+## or more contributor license agreements.  See the NOTICE file
+## distributed with this work for additional information
+## regarding copyright ownership.  The ASF licenses this file
+## to you under the Apache License, Version 2.0 (the
+## "License"); you may not use this file except in compliance
+## with the License.  You may obtain a copy of the License at
+##
+##   http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing,
+## software distributed under the License is distributed on an
+## "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+## KIND, either express or implied.  See the License for the
+## specific language governing permissions and limitations
+## under the License.
+##
+    /** The property key. */
+    private String key;

Added: db/torque/torque4/trunk/torque-generator/src/test/site/gettingStarted/src/main/torque-gf/templates/toString.vm
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/site/gettingStarted/src/main/torque-gf/templates/toString.vm?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/site/gettingStarted/src/main/torque-gf/templates/toString.vm (added)
+++ db/torque/torque4/trunk/torque-generator/src/test/site/gettingStarted/src/main/torque-gf/templates/toString.vm Tue Feb 16 17:15:43 2010
@@ -0,0 +1,22 @@
+## Licensed to the Apache Software Foundation (ASF) under one
+## or more contributor license agreements.  See the NOTICE file
+## distributed with this work for additional information
+## regarding copyright ownership.  The ASF licenses this file
+## to you under the Apache License, Version 2.0 (the
+## "License"); you may not use this file except in compliance
+## with the License.  You may obtain a copy of the License at
+##
+##   http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing,
+## software distributed under the License is distributed on an
+## "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+## KIND, either express or implied.  See the License for the
+## specific language governing permissions and limitations
+## under the License.
+##
+    @Override
+    public String toString()
+    {
+        return key;
+    }

Added: db/torque/torque4/trunk/torque-generator/src/test/site/gettingStarted/target/generated-sources/org/apache/torque/gf/example/gettingstarted/PropertyKeys.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/site/gettingStarted/target/generated-sources/org/apache/torque/gf/example/gettingstarted/PropertyKeys.java?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/site/gettingStarted/target/generated-sources/org/apache/torque/gf/example/gettingstarted/PropertyKeys.java (added)
+++ db/torque/torque4/trunk/torque-generator/src/test/site/gettingStarted/target/generated-sources/org/apache/torque/gf/example/gettingstarted/PropertyKeys.java Tue Feb 16 17:15:43 2010
@@ -0,0 +1,61 @@
+package org.apache.torque.gf.example.gettingstarted;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * Contains all keys in the property file.
+ */
+public enum PropertyKeys 
+{
+    /** Key for torque.sample.property */
+    TORQUE_SAMPLE_PROPERTY("torque.sample.property"),
+
+    /** Key for torque.some.other.property */
+    TORQUE_SOME_OTHER_PROPERTY("torque.some.other.property");
+
+    /** The property key. */
+    private String key;
+
+    /**
+     * Constructor.
+     *
+     * @param key the key of the property. 
+     */
+    private PropertyKeys(String key)
+    {
+        this.key = key;
+    }
+
+    /**
+     * Returns the property key.
+     *
+     * @return the property key.
+     */
+    public String getKey() 
+    {
+        return key;
+    }
+
+    @Override
+    public String toString()
+    {
+        return key;
+    }
+}

Added: db/torque/torque4/trunk/torque-templates/pom.xml
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/pom.xml?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/pom.xml (added)
+++ db/torque/torque4/trunk/torque-templates/pom.xml Tue Feb 16 17:15:43 2010
@@ -0,0 +1,88 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License.  You may obtain a copy of the License at
+
+   http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied.  See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<project 
+    xmlns="http://maven.apache.org/POM/4.0.0" 
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache.torque</groupId>
+  <artifactId>templates-4-0</artifactId>
+  <packaging>jar</packaging>
+  <version>0.2-SNAPSHOT</version>
+  <name>Torque Templates</name>
+  <url>http://db.apache.org/torque</url>
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.torque</groupId>
+      <artifactId>torque-gf</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>commons-lang</groupId>
+      <artifactId>commons-lang</artifactId>
+      <version>2.1</version>
+    </dependency>
+    <dependency>
+      <groupId>commons-logging</groupId>
+      <artifactId>commons-logging</artifactId>
+      <version>1.0.4</version>
+    </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>4.4</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <configuration>
+          <source>1.5</source>
+          <target>1.5</target>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-eclipse-plugin</artifactId>
+        <configuration>
+          <downloadSources>true</downloadSources>
+       </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.rat</groupId>
+        <artifactId>apache-rat-plugin</artifactId>
+      </plugin>
+    </plugins>
+  </build>
+
+  <reporting>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-plugin-plugin</artifactId>
+      </plugin>
+    </plugins>
+  </reporting>
+</project>
\ No newline at end of file

Added: db/torque/torque4/trunk/torque-templates/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/changes/changes.xml?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/changes/changes.xml (added)
+++ db/torque/torque4/trunk/torque-templates/src/changes/changes.xml Tue Feb 16 17:15:43 2010
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License.  You may obtain a copy of the License at
+
+   http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied.  See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<document>
+  <properties>
+    <title>Changes</title>
+  </properties>
+
+  <body>
+  <release version="4.0-SNAPSHOT" date="in SVN">
+    <action type="change" dev="tfischer">
+       Renamed the option 
+       torque.addIntakeRetrievable to torque:addBaseDbObjectInterface and 
+       torque.retrievableInterface to torque:baseDbObjectInterface
+    </action>
+    <action type="remove" dev="tfischer">
+       Removed the alias attribute on the table element.
+    </action>
+    <action type="remove" dev="tfischer">
+       Removed checks if the javaType of a column is a Key 
+       (NumberKey, StringKey, DateKey) because this cannot happen anyway.
+    </action>
+  </release>
+  </body>
+</document>
+

Added: db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/TemplateOptionName.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/TemplateOptionName.java?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/TemplateOptionName.java (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/TemplateOptionName.java Tue Feb 16 17:15:43 2010
@@ -0,0 +1,157 @@
+package org.apache.torque.templates;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.torque.gf.control.ControllerState;
+import org.apache.torque.gf.option.OptionName;
+import org.apache.torque.gf.source.transform.SourceTransformerException;
+
+/**
+ * The option names which are used in the java code of the templates.
+ * Other options may exist which are not used in the java code of the
+ * templates.
+ *
+ * $Id: $
+ */
+public enum TemplateOptionName implements OptionName
+{
+    /** The database vendor. See the schema for possible values.*/
+    DATABASE("torque.database", true),
+
+    /** The base package of the OM classes.*/
+    OM_PACKAGE("torque.om.package", true),
+
+    /**
+     * Whether getters for boolean fields should use "is" instead of "get"
+     * as prefix.
+     */
+    OM_USE_IS_FOR_BOOLEAN_GETTERS("torque.om.useIsForBooleanGetters"),
+
+    /** The default type for a column if no type is given. */
+    DEFAULT_TYPE("torque.om.column.defaultType"),
+
+    /** Whether bean objects should be generated. */
+    GENERATE_BEANS("torque.om.generateBeans"),
+
+    /** Whether manager classes should be used. */
+    OM_USE_MANAGERS("torque.om.useManagers"),
+
+    /**
+     * Whether the map init classes which initialize all database maps
+     * at once should be generated.
+     */
+    OM_GENERATE_MAP_INIT("torque.om.generateMapInit"),
+
+    /** The default base class for dbObjects. */
+    OM_DB_OBJECT_DEFAULT_BASE_CLASS("torque.om.dbObjectDefaultBaseClass"),
+
+    /** The prefix of the name of the mapInit class. */
+    OM_MAP_INIT_CLASS_NAME_PREFIX("torque.om.mapInit.mapInitClassNamePrefix"),
+
+    /** The prefix of the name of the mapInit class. */
+    OM_MAP_INIT_CLASS_NAME_SUFFIX("torque.om.mapInit.mapInitClassNameSuffix"),
+
+    OM_MANAGER_CLASS_NAME_PREFIX("torque.om.className.managerClassNamePrefix"),
+
+    OM_MANAGER_CLASS_NAME_SUFFIX("torque.om.className.managerClassNameSuffix");
+
+    /**
+     * The fully qualified name of the option.
+     */
+    private String name;
+
+    /**
+     * Whether this option must be set or not.
+     */
+    private boolean required;
+
+    /**
+     * Constructor for an option which is not required..
+     *
+     * @param name the fully qualified name of the option, not null.
+     */
+    private TemplateOptionName(String name)
+    {
+        this(name, false);
+    }
+
+    /**
+     * Constructor.
+     *
+     * @param name the fully qualified name of the option, not null.
+     * @param required whether the option is required.
+     */
+    private TemplateOptionName(String name, boolean required)
+    {
+        this.name = name;
+        this.required = required;
+    }
+
+    /**
+     * Returns the name of the option.
+     *
+     * @return the fully qualified name of the option, not null.
+     */
+    public String getName()
+    {
+        return name;
+    }
+
+    /**
+     * Returns whether this option must be set.
+     *
+     * @return true if the option must be set, false if it may be set.
+     */
+    public boolean isRequired()
+    {
+        return required;
+    }
+
+    @Override
+    public String toString()
+    {
+        return name;
+    }
+
+    /**
+     * Checks whether all required options are set.
+     *
+     * @param controllerState the current controller state, not null.
+     *
+     * @throws SourceTransformerException if a required option is not set.
+     */
+    public static void checkRequiredOptions(ControllerState controllerState)
+        throws SourceTransformerException
+    {
+        for (TemplateOptionName templateOption : values())
+        {
+            if (templateOption.isRequired())
+            {
+                Object optionValue
+                    = controllerState.getOption(templateOption.getName());
+                if (optionValue == null)
+                {
+                    throw new SourceTransformerException(
+                            "Option " + optionValue + " must be set");
+                }
+            }
+        }
+    }
+}

Added: db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/TorqueSchemaAttributeName.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/TorqueSchemaAttributeName.java?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/TorqueSchemaAttributeName.java (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/TorqueSchemaAttributeName.java Tue Feb 16 17:15:43 2010
@@ -0,0 +1,110 @@
+package org.apache.torque.templates;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.torque.gf.source.SourceAttributeName;
+
+/**
+ * Contains all attribute names from the Torque schema.
+ *
+ * $Id: $
+ */
+public enum TorqueSchemaAttributeName implements SourceAttributeName
+{
+    /** attribute name. */
+    NAME("name"),
+    /** attribute javaName. */
+    JAVA_NAME("javaName"),
+    /** attribute javaType. */
+    JAVA_TYPE("javaType"),
+    /** attribute foreignTable. */
+    FOREIGN_TABLE("foreignTable"),
+    /** attribute local. */
+    LOCAL("local"),
+    /** attribute foreign. */
+    FOREIGN("foreign"),
+    /** attribute onUpdate. */
+    ON_UPDATE("onUpdate"),
+    /** attribute onDelete. */
+    ON_DELETE("onDelete"),
+    /** attribute primaryKey. */
+    PRIMARY_KEY("primaryKey"),
+    /** attribute idMethod. */
+    ID_METHOD("idMethod"),
+    /** attribute defaultIdMethod. */
+    DEFAULT_ID_METHOD("defaultIdMethod"),
+    /** attribute value. */
+    VALUE("value"),
+    /** attribute required. */
+    REQUIRED("required"),
+    /** attribute autoIncrement. TODO: remove once the schema is changed. */
+    AUTO_INCREMENT("autoIncrement"),
+    /** attribute inheritance. */
+    INHERITANCE("inheritance"),
+    /** attribute interface. */
+    INTERFACE("interface"),
+    /** attribute protected. */
+    PROTECTED("protected"),
+    /** attribute default. */
+    DEFAULT("default"),
+    /** attribute class. */
+    CLASS("class"),
+    /** attribute baseClass. */
+    BASE_CLASS("baseClass"),
+    /** attribute extends. */
+    EXTENDS("extends"),
+    /** attribute domain. */
+    DOMAIN("domain"),
+    /** attribute type. */
+    TYPE("type"),
+    /** attribute size. */
+    SIZE("size"),
+    /** attribute scale. */
+    SCALE("scale");
+
+    /** The name of the attribute, not null. */
+    private String name;
+
+    /**
+     * Constructor.
+     *
+     * @param name the name of the attribute, not null.
+     */
+    private TorqueSchemaAttributeName(String name)
+    {
+        this.name = name;
+    }
+
+    /**
+     * returns the name of the attribute.
+     *
+     * @return the name of the attribute, not null.
+     */
+    public String getName()
+    {
+        return name;
+    }
+
+    @Override
+    public String toString()
+    {
+        return name;
+    }
+}

Added: db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/TorqueSchemaElementName.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/TorqueSchemaElementName.java?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/TorqueSchemaElementName.java (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/TorqueSchemaElementName.java Tue Feb 16 17:15:43 2010
@@ -0,0 +1,84 @@
+package org.apache.torque.templates;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.torque.gf.source.SourceElementName;
+
+/**
+ * Contains all element names from the Torque schema.
+ *
+ * $Id: $
+ */
+public enum TorqueSchemaElementName implements SourceElementName
+{
+    /** element database. */
+    DATABASE("database"),
+    /** element table. */
+    TABLE("table"),
+    /** element column. */
+    COLUMN("column"),
+    /** element foreign-key. */
+    FOREIGN_KEY("foreign-key"),
+    /** element reference. */
+    REFERENCE("reference"),
+    /** element inheritance. */
+    INHERITANCE("inheritance"),
+    /** element id-method-param. */
+    ID_METHOD_PARAMETER("id-method-parameter"),
+    /** element unique. */
+    UNIQUE("unique"),
+    /** element unique-column. */
+    UNIQUE_COLUMN("unique-column"),
+    /** element index. */
+    INDEX("index"),
+    /** element index-column. */
+    INDEX_COLUMN("index-column");
+
+    /**
+     * The name of the element, not null.
+     */
+    private String name;
+
+    /**
+     * Constructor.
+     *
+     * @param name the name of the element, not null.
+     */
+    private TorqueSchemaElementName(String name)
+    {
+        this.name = name;
+    }
+
+    /**
+     * Returns the name of the element.
+     *
+     * @return the name of the element, not null.
+     */
+    public String getName()
+    {
+        return name;
+    }
+
+    @Override
+    public String toString()
+    {
+        return name;
+    }
+}

Added: db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/TorqueSchemaIdMethod.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/TorqueSchemaIdMethod.java?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/TorqueSchemaIdMethod.java (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/TorqueSchemaIdMethod.java Tue Feb 16 17:15:43 2010
@@ -0,0 +1,77 @@
+package org.apache.torque.templates;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * Holds all IdMethods known in the Torque schema
+ */
+public enum TorqueSchemaIdMethod
+{
+    /** Primary keys are generated via the IdBroker. */
+    IDBROKER("idbroker"),
+
+    /**
+     * Primary keys are generated via the native method of the database
+     * (i.e. sequences or autoincrement).
+     */
+    NATIVE("native"),
+
+    /**
+     * Primary keys are not generated automatically.
+     */
+    NONE("none"),
+
+    /**
+     * The default is used.
+     * TODO: remove once the schema is changed.
+     */
+    NULL("null");
+
+    /**
+     * The name of the idMethod, not null.
+     */
+    private String name;
+
+    /**
+     * Constructor.
+     *
+     * @param name the name of the idMethod, not null.
+     */
+    private TorqueSchemaIdMethod(String name)
+    {
+        this.name = name;
+    }
+
+    /**
+     * Returns the name of the idMethod.
+     *
+     * @return the name of the idMethod, not null.
+     */
+    public String getName()
+    {
+        return name;
+    }
+
+    @Override
+    public String toString()
+    {
+        return name;
+    }
+}

Added: db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/TorqueSchemaInheritance.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/TorqueSchemaInheritance.java?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/TorqueSchemaInheritance.java (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/TorqueSchemaInheritance.java Tue Feb 16 17:15:43 2010
@@ -0,0 +1,67 @@
+package org.apache.torque.templates;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * The possible values of the inheritance attribute of the column element.
+ *
+ * $Id: $
+ */
+public enum TorqueSchemaInheritance
+{
+    /** This column determines the inheritance class of the table. */
+    SINGLE("single"),
+
+    /**
+     * This column does nor define an inheritance column.
+     */
+    FALSE("false");
+
+    /**
+     * The value of the inheritance attribute, not null.
+     */
+    private String value;
+
+    /**
+     * Constructor.
+     *
+     * @param value the value of the inheritance attribute, not null.
+     */
+    private TorqueSchemaInheritance(String value)
+    {
+        this.value = value;
+    }
+
+    /**
+     * Returns the value of the inheritance attribute.
+     *
+     * @return the value of the inheritance attribute, not null.
+     */
+    public String getValue()
+    {
+        return value;
+    }
+
+    @Override
+    public String toString()
+    {
+        return value;
+    }
+}

Added: db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/TorqueSchemaJavaType.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/TorqueSchemaJavaType.java?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/TorqueSchemaJavaType.java (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/TorqueSchemaJavaType.java Tue Feb 16 17:15:43 2010
@@ -0,0 +1,67 @@
+package org.apache.torque.templates;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * The possible values the javaType attribute of the column element.
+ *
+ * $Id: $
+ */
+public enum TorqueSchemaJavaType
+{
+    /** The java attribute will be an object (e.g. Integer). */
+    OBJECT("object"),
+
+    /**
+     * The java attribute will be a primitive (e.g. int), if possible.
+     */
+    PRIMITIVE("primitive");
+
+    /**
+     * The value of the javaType attribute, not null.
+     */
+    private String value;
+
+    /**
+     * Constructor.
+     *
+     * @param value the value of the javaType attribute, not null.
+     */
+    private TorqueSchemaJavaType(String value)
+    {
+        this.value = value;
+    }
+
+    /**
+     * Returns the value of the javaType attribute.
+     *
+     * @return the value of the javaType attribute, not null.
+     */
+    public String getValue()
+    {
+        return value;
+    }
+
+    @Override
+    public String toString()
+    {
+        return value;
+    }
+}

Added: db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/Platform.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/Platform.java?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/Platform.java (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/Platform.java Tue Feb 16 17:15:43 2010
@@ -0,0 +1,99 @@
+package org.apache.torque.templates.platform;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.torque.templates.typemapping.SchemaType;
+import org.apache.torque.templates.typemapping.SqlType;
+
+/**
+ * Interface for RDBMS platform specific behaviour.
+ *
+ * @author <a href="mailto:mpoeschl@marmot.at">Martin Poeschl</a>
+ * @version $Id: Platform.java 473814 2006-11-11 22:30:30 +0000 (Sat, 11 Nov 2006) tv $
+ */
+public interface Platform
+{
+    /** constant for native id method */
+    String IDENTITY = "identity";
+    /** constant for native id method */
+    String SEQUENCE = "sequence";
+
+    /**
+     * Returns the native IdMethod (sequence|identity)
+     *
+     * @return the native IdMethod
+     */
+    String getNativeIdMethod();
+
+    /**
+     * Returns the max column length supported by the db.
+     *
+     * @return the max column length
+     */
+    int getMaxColumnNameLength();
+
+    /**
+     * Returns the db specific sql Type for a Torque Type.
+     *
+     * @param schemaType the schema type, not null.
+     *
+     * @return the db specific domain, or null if no domain is defined
+     *         for the given schema type.
+     */
+    SqlType getSqlTypeForSchemaType(SchemaType schemaType);
+
+    /**
+     * @return The RDBMS-specific SQL fragment for <code>NULL</code>
+     * or <code>NOT NULL</code>.
+     */
+    String getNullString(boolean notNull);
+
+    /**
+     * @return The RDBMS-specific SQL fragment for autoincrement.
+     */
+    String getAutoIncrement();
+
+    /**
+     * Returns if the RDBMS-specific SQL type has a size attribute.
+     *
+     * @param sqlType the SQL type
+     * @return true if the type has a size attribute
+     */
+    boolean hasSize(String sqlType);
+
+    /**
+     * Returns if the RDBMS-specific SQL type has a scale attribute.
+     *
+     * @param sqlType the SQL type
+     * @return true if the type has a scale attribute
+     */
+    boolean hasScale(String sqlType);
+
+    /**
+     * Returns whether the "not null part" of the definition of a column
+     * should be generated before the "autoincrement part" in a "create table"
+     * statement.
+     *
+     * @return true if the "not null part" should be first,
+     *         false if the "autoincrement part" should be first in a
+     *         "create table" statement.
+     */
+    boolean createNotNullBeforeAutoincrement();
+}

Added: db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformAxionImpl.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformAxionImpl.java?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformAxionImpl.java (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformAxionImpl.java Tue Feb 16 17:15:43 2010
@@ -0,0 +1,63 @@
+package org.apache.torque.templates.platform;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.torque.templates.typemapping.SqlType;
+import org.apache.torque.templates.typemapping.SchemaType;
+
+/**
+ * Axion Platform implementation.
+ *
+ * @author <a href="mailto:mpoeschl@marmot.at">Martin Poeschl</a>
+ * @version $Id: PlatformAxionImpl.java 473814 2006-11-11 22:30:30 +0000 (Sat, 11 Nov 2006) tv $
+ */
+public class PlatformAxionImpl extends PlatformDefaultImpl
+{
+    /**
+     * Default constructor.
+     */
+    public PlatformAxionImpl()
+    {
+        super();
+        initialize();
+    }
+
+    /**
+     * Initializes db specific domain mapping.
+     */
+    private void initialize()
+    {
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.DECIMAL,
+                new SqlType("INTEGER"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.CHAR,
+                new SqlType("VARCHAR"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.BOOLEANCHAR,
+                new SqlType("VARCHAR"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.LONGVARCHAR,
+                new SqlType("VARCHAR"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.VARBINARY,
+                new SqlType("BINARY"));
+    }
+}

Added: db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformCloudscapeImpl.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformCloudscapeImpl.java?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformCloudscapeImpl.java (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformCloudscapeImpl.java Tue Feb 16 17:15:43 2010
@@ -0,0 +1,84 @@
+package org.apache.torque.templates.platform;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.torque.templates.typemapping.SchemaType;
+import org.apache.torque.templates.typemapping.SqlType;
+
+/**
+ * Cloudscape Platform implementation.
+ *
+ * @author <a href="mailto:mpoeschl@marmot.at">Martin Poeschl</a>
+ * @version $Id: PlatformCloudscapeImpl.java 473814 2006-11-11 22:30:30 +0000 (Sat, 11 Nov 2006) tv $
+ */
+public class PlatformCloudscapeImpl extends PlatformDefaultImpl
+{
+    /**
+     * Default constructor.
+     */
+    public PlatformCloudscapeImpl()
+    {
+        super();
+        initialize();
+    }
+
+    /**
+     * Initializes db specific domain mapping.
+     */
+    private void initialize()
+    {
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.INTEGER,
+                new SqlType("INT"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.BOOLEANINT,
+                new SqlType("INT"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.BIGINT,
+                new SqlType("LONGINT"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.DOUBLE,
+                new SqlType("DOUBLE PRECISION"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.LONGVARCHAR,
+                new SqlType("LONG VARCHAR"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.BINARY,
+                new SqlType("LONG BINARY"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.VARBINARY,
+                new SqlType("LONG BINARY"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.LONGVARBINARY,
+                new SqlType("LONG VARBINARY"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.JAVA_OBJECT,
+                new SqlType("SERIALIZE"));
+    }
+
+    /**
+     * @see Platform#getAutoIncrement()
+     */
+    public String getAutoIncrement()
+    {
+        return "DEFAULT AUTOINCREMENT";
+    }
+
+}

Added: db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformDb2400Impl.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformDb2400Impl.java?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformDb2400Impl.java (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformDb2400Impl.java Tue Feb 16 17:15:43 2010
@@ -0,0 +1,86 @@
+package org.apache.torque.templates.platform;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.torque.templates.typemapping.SqlType;
+import org.apache.torque.templates.typemapping.SchemaType;
+
+/**
+ * DB2-AS400 Platform implementation.
+ *
+ * @author <a href="mailto:mpoeschl@marmot.at">Martin Poeschl</a>
+ * @version $Id: PlatformDb2400Impl.java 473814 2006-11-11 22:30:30 +0000 (Sat, 11 Nov 2006) tv $
+ */
+public class PlatformDb2400Impl extends PlatformDefaultImpl
+{
+    /**
+     * Default constructor.
+     */
+    public PlatformDb2400Impl()
+    {
+        super();
+        initialize();
+    }
+
+    /**
+     * Initializes db specific domain mapping.
+     */
+    private void initialize()
+    {
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.TINYINT,
+                new SqlType("SMALLINT"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.INTEGER,
+                new SqlType("INT"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.BOOLEANINT,
+                new SqlType("INT"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.DOUBLE,
+                new SqlType("DOUBLE PRECISION"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.DECIMAL,
+                new SqlType("DEC"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.CHAR,
+                new SqlType("VARCHAR"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.BOOLEANCHAR,
+                new SqlType("VARCHAR"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.LONGVARCHAR,
+                new SqlType("LONG VARCHAR"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.VARBINARY,
+                new SqlType("VARCHAR (32000) FOR BIT DATA"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.LONGVARBINARY,
+                new SqlType("LONG VARCHAR FOR BIT DATA"));
+    }
+
+    /**
+     * @see Platform#getMaxColumnNameLength()
+     */
+    public int getMaxColumnNameLength()
+    {
+        return 30;
+    }
+}

Added: db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformDb2Impl.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformDb2Impl.java?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformDb2Impl.java (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformDb2Impl.java Tue Feb 16 17:15:43 2010
@@ -0,0 +1,84 @@
+package org.apache.torque.templates.platform;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.torque.templates.typemapping.SqlType;
+import org.apache.torque.templates.typemapping.SchemaType;
+
+/**
+ * DB2 Platform implementation.
+ *
+ * @author <a href="mailto:mpoeschl@marmot.at">Martin Poeschl</a>
+ * @version $Id: PlatformDb2Impl.java 473814 2006-11-11 22:30:30 +0000 (Sat, 11 Nov 2006) tv $
+ */
+public class PlatformDb2Impl extends PlatformDefaultImpl
+{
+    /**
+     * Default constructor.
+     */
+    public PlatformDb2Impl()
+    {
+        super();
+        initialize();
+    }
+
+    /**
+     * Initializes db specific domain mapping.
+     */
+    private void initialize()
+    {
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.CHAR,
+                new SqlType("VARCHAR"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.BOOLEANCHAR,
+                new SqlType("VARCHAR"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.LONGVARCHAR,
+                new SqlType("LONG VARCHAR"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.BINARY,
+                new SqlType("CHAR(n) FOR BIT DATA"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.VARBINARY,
+                new SqlType("VARCHAR(n) FOR BIT DATA"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.LONGVARBINARY,
+                new SqlType("LONG VARCHAR FOR BIT DATA"));
+    }
+
+    /**
+     * @see Platform#getMaxColumnNameLength()
+     */
+    public int getMaxColumnNameLength()
+    {
+        // TODO check this! (value taken from db.props)
+        return 18;
+    }
+
+    /**
+     * @see Platform#getAutoIncrement()
+     */
+    public String getAutoIncrement()
+    {
+        return "GENERATED ALWAYS AS IDENTITY";
+    }
+
+}

Added: db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformDefaultImpl.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformDefaultImpl.java?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformDefaultImpl.java (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformDefaultImpl.java Tue Feb 16 17:15:43 2010
@@ -0,0 +1,161 @@
+package org.apache.torque.templates.platform;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.torque.templates.typemapping.SchemaType;
+import org.apache.torque.templates.typemapping.SqlType;
+
+
+/**
+ * Default implementation for the Platform interface.
+ *
+ * @author <a href="mailto:mpoeschl@marmot.at">Martin Poeschl</a>
+ * @version $Id: PlatformDefaultImpl.java 473814 2006-11-11 22:30:30 +0000 (Sat, 11 Nov 2006) tv $
+ */
+public class PlatformDefaultImpl implements Platform
+{
+    /**
+     * Maps the Torque schema types to sql types.
+     */
+    private Map<SchemaType, SqlType> schemaTypeToSqlTypeMap;
+
+    /**
+     * Default constructor.
+     */
+    public PlatformDefaultImpl()
+    {
+        initialize();
+    }
+
+    private void initialize()
+    {
+        schemaTypeToSqlTypeMap
+                = Collections.synchronizedMap(
+                    new HashMap<SchemaType, SqlType>());
+        for (SchemaType schemaType : SchemaType.values())
+        {
+            setSchemaTypeToSqlTypeMapping(
+                    schemaType,
+                    new SqlType(schemaType.name()));
+        }
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.BOOLEANCHAR,
+                new SqlType("CHAR"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.BOOLEANINT,
+                new SqlType("INTEGER"));
+    }
+
+    /**
+     * Adds a mapping to the torque schema type -> sql type map.
+     *
+     * @param schemaType the torque schema type which should be mapped,
+     *        not null.
+     * @param sqlType the sql type for the torque schema type, not null.
+     */
+    protected void setSchemaTypeToSqlTypeMapping(
+            SchemaType schemaType,
+            SqlType sqlType)
+    {
+        if (schemaType == null)
+        {
+            throw new NullPointerException("schemaType must not be null");
+        }
+        if (sqlType == null)
+        {
+            throw new NullPointerException("sqlType must not be null");
+        }
+        schemaTypeToSqlTypeMap.put(schemaType, sqlType);
+    }
+
+    /**
+     * @see Platform#getMaxColumnNameLength()
+     */
+    public int getMaxColumnNameLength()
+    {
+        return 64;
+    }
+
+    /**
+     * @see Platform#getNativeIdMethod()
+     */
+    public String getNativeIdMethod()
+    {
+        return Platform.IDENTITY;
+    }
+
+    /**
+     * @see Platform#getSqlTypeForSchemaType(SchemaType)
+     */
+    public SqlType getSqlTypeForSchemaType(SchemaType schemaType)
+    {
+        return schemaTypeToSqlTypeMap.get(schemaType);
+    }
+
+    /**
+     * @return Only produces a SQL fragment if null values are
+     * disallowed.
+     * @see Platform#getNullString(boolean)
+     */
+    public String getNullString(boolean notNull)
+    {
+        // TODO: Check whether this is true for all DBs.  Also verify
+        // the old Sybase templates.
+        return (notNull ? "NOT NULL" : "");
+    }
+
+    /**
+     * @see Platform#getAutoIncrement()
+     */
+    public String getAutoIncrement()
+    {
+        return "IDENTITY";
+    }
+
+    /**
+     * @see Platform#hasScale(String)
+     * TODO collect info for all platforms
+     */
+    public boolean hasScale(String sqlType)
+    {
+        return true;
+    }
+
+    /**
+     * @see Platform#hasSize(String)
+     * TODO collect info for all platforms
+     */
+    public boolean hasSize(String sqlType)
+    {
+        return true;
+    }
+
+    /**
+     * @see Platform#createNotNullBeforeAutoincrement()
+     */
+    public boolean createNotNullBeforeAutoincrement()
+    {
+        return true;
+    }
+}

Added: db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformDerbyImpl.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformDerbyImpl.java?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformDerbyImpl.java (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformDerbyImpl.java Tue Feb 16 17:15:43 2010
@@ -0,0 +1,115 @@
+package org.apache.torque.templates.platform;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.torque.templates.typemapping.SizedForBitDataSqlType;
+import org.apache.torque.templates.typemapping.SqlType;
+import org.apache.torque.templates.typemapping.SchemaType;
+
+/**
+ * Derby Platform implementation.
+ *
+ * @author <a href="mailto:johnnymac@tiscali.be">Johnny Macchione</a>
+ * @author <a href="Monroe@DukeCE.com">Greg Monroe</a>
+ * @version $Id: PlatformDerbyImpl.java 482880 2006-12-06 03:55:24Z gmonroe $
+ */
+public class PlatformDerbyImpl extends PlatformDefaultImpl
+{
+
+    /**
+     * Default constructor.
+     */
+    public PlatformDerbyImpl()
+    {
+        super();
+        initialize();
+    }
+
+    /**
+     * Initializes db specific domain mapping.
+     */
+    private void initialize()
+    {
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.LONGVARCHAR,
+                new SqlType("LONG VARCHAR"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.VARBINARY,
+                new SizedForBitDataSqlType("VARCHAR", "32672"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.BINARY,
+                new SizedForBitDataSqlType("CHAR", "1"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.LONGVARBINARY,
+                new SqlType("LONG VARCHAR FOR BIT DATA"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.LONGVARCHAR,
+                new SqlType("LONG VARCHAR"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.BIT,
+                new SqlType("CHAR(1)"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.TINYINT,
+                new SqlType("SMALLINT"));
+    }
+
+    /**
+     * @see Platform#getMaxColumnNameLength()
+     */
+    public int getMaxColumnNameLength()
+    {
+        return 128;
+    }
+
+    /**
+     * @see Platform#getAutoIncrement(
+     */
+    public String getAutoIncrement()
+    {
+        return "GENERATED BY DEFAULT AS IDENTITY";
+    }
+
+    /**
+     * @see Platform#getNativeIdMethod()
+     */
+    public String getNativeIdMethod()
+    {
+        return Platform.IDENTITY;
+    }
+
+    /**
+     * @see Platform#hasScale(String)
+     */
+    public boolean hasScale(String sqlType)
+    {
+        return "NUMERIC".equals(sqlType) || "DECIMAL".equals(sqlType);
+    }
+
+    /**
+     * @see Platform#hasSize(String)
+     */
+    public boolean hasSize(String sqlType)
+    {
+        return "NUMERIC".equals(sqlType) || "DECIMAL".equals(sqlType)
+            || "VARCHAR".equals(sqlType) || "CHAR".equals(sqlType)
+            || "BINARY".equals(sqlType) || "VARBINARY".equals(sqlType)
+            || "BLOB".equals(sqlType) || "CLOB".equals(sqlType);
+    }
+}

Added: db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformFactory.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformFactory.java?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformFactory.java (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformFactory.java Tue Feb 16 17:15:43 2010
@@ -0,0 +1,107 @@
+package org.apache.torque.templates.platform;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.HashMap;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Factory class responsible to create Platform objects that
+ * define RDBMS platform specific behaviour.
+ *
+ * @author Thomas Mahler
+ * @author <a href="mailto:mpoeschl@marmot.at">Martin Poeschl</a>
+ * @version $Id: PlatformFactory.java 473814 2006-11-11 22:30:30 +0000 (Sat, 11 Nov 2006) tv $
+ */
+public class PlatformFactory
+{
+    private static HashMap<String, Platform> platforms
+            = new HashMap<String, Platform>();
+    private static Log log = LogFactory.getLog(PlatformFactory.class);
+
+    /**
+     * Returns the Platform for a platform name.
+     *
+     * @param dbms name of the platform
+     *
+     * @return the Platform, not null.
+     */
+    public static Platform getPlatformFor(String dbms)
+    {
+        Platform result = null;
+        String platformName = null;
+
+        result = (Platform) getPlatforms().get(dbms);
+        if (result == null)
+        {
+            try
+            {
+                platformName = getClassnameFor(dbms);
+                Class<?> platformClass = Class.forName(platformName);
+                result = (Platform) platformClass.newInstance();
+            }
+            catch (Throwable t)
+            {
+                log.warn("problems with platform " + platformName
+                        + ": " + t.getMessage());
+                log.warn("Torque will use PlatformDefaultImpl instead");
+
+                result = new PlatformDefaultImpl();
+            }
+            getPlatforms().put(dbms, result); // cache the Platform
+        }
+        return result;
+    }
+
+    /**
+     * compute the name of the concrete Class representing the Platform
+     * specified by <code>platform</code>
+     *
+     * @param platform the name of the platform as specified in the repository
+     */
+    private static String getClassnameFor(String platform)
+    {
+        String pf = "Default";
+        if (platform != null)
+        {
+            pf = platform;
+        }
+        String myClassname = PlatformFactory.class.getName();
+        String myPackage
+                = myClassname.substring(0,myClassname.lastIndexOf("."));
+        return myPackage
+                + ".Platform"
+                + pf.substring(0, 1).toUpperCase()
+                + pf.substring(1)
+                + "Impl";
+    }
+
+    /**
+     * Gets the platforms.
+     *
+     * @return Returns a HashMap
+     */
+    private static HashMap<String, Platform> getPlatforms()
+    {
+        return platforms;
+    }
+}

Added: db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformHypersonicImpl.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformHypersonicImpl.java?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformHypersonicImpl.java (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformHypersonicImpl.java Tue Feb 16 17:15:43 2010
@@ -0,0 +1,88 @@
+package org.apache.torque.templates.platform;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.torque.templates.typemapping.SchemaType;
+import org.apache.torque.templates.typemapping.SqlType;
+
+/**
+ * HSQLDB (formerly known as Hypersonic) Platform implementation.
+ *
+ * @author <a href="mailto:mpoeschl@marmot.at">Martin Poeschl</a>
+ * @version $Id: PlatformHypersonicImpl.java 473814 2006-11-11 22:30:30 +0000 (Sat, 11 Nov 2006) tv $
+ */
+public class PlatformHypersonicImpl extends PlatformDefaultImpl
+{
+    /**
+     * Default constructor.
+     */
+    public PlatformHypersonicImpl()
+    {
+        super();
+        initialize();
+    }
+
+    /**
+     * Initializes db specific domain mapping.
+     */
+    private void initialize()
+    {
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.CHAR,
+                new SqlType("VARCHAR"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.BOOLEANCHAR,
+                new SqlType("VARCHAR"));
+        // TODO: should longvarchar not be mapped to LONGVARCHAR as CLOB ?
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.LONGVARCHAR,
+                new SqlType("VARCHAR"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.VARBINARY,
+                new SqlType("BINARY"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.BLOB,
+                new SqlType("BINARY"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.CLOB,
+                new SqlType("LONGVARCHAR"));
+    }
+
+    /**
+     * @return The RDBMS-specific SQL fragment for autoincrement.
+     * @see Platform#getAutoIncrement()
+     */
+    public String getAutoIncrement()
+    {
+        return "GENERATED BY DEFAULT AS IDENTITY (START WITH 1)";
+    }
+
+    /**
+     * Returns whether the "not null part" of the definition of a column
+     * should be generated before the "autoincrement part" in a "create table"
+     * statement.
+     * @return false.
+     * @see Platform#createNotNullBeforeAutoincrement()
+     */
+    public boolean createNotNullBeforeAutoincrement()
+    {
+        return false;
+    }
+}

Added: db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformInterbaseImpl.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformInterbaseImpl.java?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformInterbaseImpl.java (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformInterbaseImpl.java Tue Feb 16 17:15:43 2010
@@ -0,0 +1,64 @@
+package org.apache.torque.templates.platform;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.torque.templates.typemapping.SqlType;
+import org.apache.torque.templates.typemapping.SchemaType;
+
+/**
+ * Interbase Platform implementation.
+ *
+ * @author <a href="mailto:mpoeschl@marmot.at">Martin Poeschl</a>
+ * @version $Id: PlatformInterbaseImpl.java 473814 2006-11-11 22:30:30 +0000 (Sat, 11 Nov 2006) tv $
+ */
+public class PlatformInterbaseImpl extends PlatformDefaultImpl
+{
+    /**
+     * Default constructor.
+     */
+    public PlatformInterbaseImpl()
+    {
+        super();
+        initialize();
+    }
+
+    /**
+     * Initializes db specific domain mapping.
+     */
+    private void initialize()
+    {
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.BIT,
+                new SqlType("NUMERIC", "1", "0"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.DOUBLE,
+                new SqlType("DOUBLE PRECISION"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.BOOLEANCHAR,
+                new SqlType("CHAR", "1"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.LONGVARCHAR,
+                new SqlType("VARCHAR"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.VARBINARY,
+                new SqlType("BLOB"));
+    }
+
+}

Added: db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformMsaccessImpl.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformMsaccessImpl.java?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformMsaccessImpl.java (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformMsaccessImpl.java Tue Feb 16 17:15:43 2010
@@ -0,0 +1,63 @@
+package org.apache.torque.templates.platform;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.torque.templates.typemapping.SqlType;
+import org.apache.torque.templates.typemapping.SchemaType;
+
+/**
+ * MS Access Platform implementation.
+ *
+ * @author <a href="mailto:mpoeschl@marmot.at">Martin Poeschl</a>
+ * @version $Id: PlatformMsaccessImpl.java 473814 2006-11-11 22:30:30 +0000 (Sat, 11 Nov 2006) tv $
+ */
+public class PlatformMsaccessImpl extends PlatformDefaultImpl
+{
+    /**
+     * Default constructor.
+     */
+    public PlatformMsaccessImpl()
+    {
+        super();
+        initialize();
+    }
+
+    /**
+     * Initializes db specific domain mapping.
+     */
+    private void initialize()
+    {
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.CHAR,
+                new SqlType("VARCHAR"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.BOOLEANCHAR,
+                new SqlType("VARCHAR"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.LONGVARCHAR,
+                new SqlType("MEMO"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.VARBINARY,
+                new SqlType("BINARY"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.LONGVARBINARY,
+                new SqlType("BINARY"));
+    }
+}

Added: db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformMssqlImpl.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformMssqlImpl.java?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformMssqlImpl.java (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformMssqlImpl.java Tue Feb 16 17:15:43 2010
@@ -0,0 +1,103 @@
+package org.apache.torque.templates.platform;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.torque.templates.typemapping.SqlType;
+import org.apache.torque.templates.typemapping.SchemaType;
+
+/**
+ * MS SQL Platform implementation.
+ *
+ * @author <a href="mailto:mpoeschl@marmot.at">Martin Poeschl</a>
+ * @author <a href="mailto:greg.monroe@dukece.com">Greg Monroe</a>
+ * @version $Id: PlatformMssqlImpl.java 473814 2006-11-11 22:30:30 +0000 (Sat, 11 Nov 2006) tv $
+ */
+public class PlatformMssqlImpl extends PlatformDefaultImpl
+{
+    /**
+     * Default constructor.
+     */
+    public PlatformMssqlImpl()
+    {
+        super();
+        initialize();
+    }
+
+    /**
+     * Initializes db specific domain mapping.
+     */
+    private void initialize()
+    {
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.INTEGER,
+                new SqlType("INT"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.BOOLEANINT,
+                new SqlType("INT"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.DOUBLE,
+                new SqlType("FLOAT"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.LONGVARCHAR,
+                new SqlType("TEXT"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.DATE,
+                new SqlType("DATETIME"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.TIME,
+                new SqlType("DATETIME"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.TIMESTAMP,
+                new SqlType("DATETIME"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.BINARY,
+                new SqlType("BINARY(7132)"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.VARBINARY,
+                new SqlType("IMAGE"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.LONGVARBINARY,
+                new SqlType("IMAGE"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.BLOB,
+                new SqlType("IMAGE"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.CLOB,
+                new SqlType("TEXT"));
+    }
+
+    /**
+     * @see Platform#getMaxColumnNameLength()
+     */
+    public int getMaxColumnNameLength()
+    {
+        return 30;
+    }
+
+    /**
+     * @return Explicitly returns <code>NULL</code> if null values are
+     * allowed (as recomended by Microsoft).
+     * @see Platform#getNullString(boolean)
+     */
+    public String getNullString(boolean notNull)
+    {
+        return (notNull ? "NOT NULL" : "NULL");
+    }
+}

Added: db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformMysqlImpl.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformMysqlImpl.java?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformMysqlImpl.java (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformMysqlImpl.java Tue Feb 16 17:15:43 2010
@@ -0,0 +1,90 @@
+package org.apache.torque.templates.platform;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.torque.templates.typemapping.SqlType;
+import org.apache.torque.templates.typemapping.SchemaType;
+
+/**
+ * MySql Platform implementation.
+ *
+ * @author <a href="mailto:mpoeschl@marmot.at">Martin Poeschl</a>
+ * @version $Id: PlatformMysqlImpl.java 473814 2006-11-11 22:30:30 +0000 (Sat, 11 Nov 2006) tv $
+ */
+public class PlatformMysqlImpl extends PlatformDefaultImpl
+{
+    /**
+     * Default constructor.
+     */
+    public PlatformMysqlImpl()
+    {
+        super();
+        initialize();
+    }
+
+    /**
+     * Initializes db specific domain mapping.
+     */
+    private void initialize()
+    {
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.NUMERIC,
+                new SqlType("DECIMAL"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.LONGVARCHAR,
+                new SqlType("MEDIUMTEXT"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.DATE,
+                new SqlType("DATETIME"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.BINARY,
+                new SqlType("BLOB"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.VARBINARY,
+                new SqlType("MEDIUMBLOB"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.LONGVARBINARY,
+                new SqlType("LONGBLOB"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.BLOB,
+                new SqlType("LONGBLOB"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.CLOB,
+                new SqlType("LONGTEXT"));
+    }
+
+    /**
+     * @see Platform#getAutoIncrement()
+     */
+    public String getAutoIncrement()
+    {
+        return "AUTO_INCREMENT";
+    }
+
+    /**
+     * @see Platform#hasSize(String)
+     */
+    public boolean hasSize(String sqlType)
+    {
+        return !("MEDIUMTEXT".equals(sqlType) || "LONGTEXT".equals(sqlType)
+                || "BLOB".equals(sqlType) || "MEDIUMBLOB".equals(sqlType)
+                || "LONGBLOB".equals(sqlType));
+    }
+}

Added: db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformOracleImpl.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformOracleImpl.java?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformOracleImpl.java (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformOracleImpl.java Tue Feb 16 17:15:43 2010
@@ -0,0 +1,117 @@
+package org.apache.torque.templates.platform;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.torque.templates.typemapping.SqlType;
+import org.apache.torque.templates.typemapping.SchemaType;
+
+/**
+ * Oracle Platform implementation.
+ *
+ * @author <a href="mailto:mpoeschl@marmot.at">Martin Poeschl</a>
+ * @version $Id: PlatformOracleImpl.java 473814 2006-11-11 22:30:30 +0000 (Sat, 11 Nov 2006) tv $
+ */
+public class PlatformOracleImpl extends PlatformDefaultImpl
+{
+    /**
+     * Default constructor.
+     */
+    public PlatformOracleImpl()
+    {
+        super();
+        initialize();
+    }
+
+    /**
+     * Initializes db specific domain mapping.
+     */
+    private void initialize()
+    {
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.TINYINT,
+                new SqlType("NUMBER", "3", "0"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.SMALLINT,
+                new SqlType("NUMBER", "5", "0"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.INTEGER,
+                new SqlType("NUMBER", "10", "0"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.BOOLEANINT,
+                new SqlType("NUMBER", "1", "0"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.BIGINT,
+                new SqlType("NUMBER", "20", "0"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.REAL,
+                new SqlType("NUMBER"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.DOUBLE,
+                new SqlType("FLOAT"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.DECIMAL,
+                new SqlType("NUMBER"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.NUMERIC,
+                new SqlType("NUMBER"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.VARCHAR,
+                new SqlType("VARCHAR2"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.LONGVARCHAR,
+                new SqlType("VARCHAR2", "2000"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.TIME,
+                new SqlType("DATE"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.BINARY,
+                new SqlType("LONG RAW"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.VARBINARY,
+                new SqlType("BLOB"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.LONGVARBINARY,
+                new SqlType("LONG RAW"));
+    }
+
+    /**
+     * @see Platform#getMaxColumnNameLength()
+     */
+    public int getMaxColumnNameLength()
+    {
+        return 30;
+    }
+
+    /**
+     * @see Platform#getNativeIdMethod()
+     */
+    public String getNativeIdMethod()
+    {
+        return Platform.SEQUENCE;
+    }
+
+    /**
+     * @see Platform#getAutoIncrement()
+     */
+    public String getAutoIncrement()
+    {
+        return "";
+    }
+}

Added: db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformPostgresqlImpl.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformPostgresqlImpl.java?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformPostgresqlImpl.java (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformPostgresqlImpl.java Tue Feb 16 17:15:43 2010
@@ -0,0 +1,134 @@
+package org.apache.torque.templates.platform;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.torque.templates.typemapping.SqlType;
+import org.apache.torque.templates.typemapping.SchemaType;
+
+/**
+ * Postgresql Platform implementation.
+ *
+ * @author <a href="mailto:mpoeschl@marmot.at">Martin Poeschl</a>
+ * @version $Id: PlatformPostgresqlImpl.java 491219 2006-12-30 12:39:20Z tfischer $
+ */
+public class PlatformPostgresqlImpl extends PlatformDefaultImpl
+{
+    /**
+     * Default constructor.
+     */
+    public PlatformPostgresqlImpl()
+    {
+        super();
+        initialize();
+    }
+
+    /**
+     * Initializes db specific domain mapping.
+     */
+    private void initialize()
+    {
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.BIT,
+                new SqlType("BOOLEAN"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.TINYINT,
+                new SqlType("INT2"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.SMALLINT,
+                new SqlType("INT2"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.BIGINT,
+                new SqlType("INT8"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.REAL,
+                new SqlType("FLOAT"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.BOOLEANCHAR,
+                new SqlType("CHAR"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.BOOLEANINT,
+                new SqlType("INT2"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.DOUBLE,
+                new SqlType("DOUBLE PRECISION"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.LONGVARCHAR,
+                new SqlType("TEXT"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.BINARY,
+                new SqlType("BYTEA"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.VARBINARY,
+                new SqlType("BYTEA"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.LONGVARBINARY,
+                new SqlType("BYTEA"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.BLOB,
+                new SqlType("BYTEA"));
+        setSchemaTypeToSqlTypeMapping(
+                SchemaType.CLOB,
+                new SqlType("TEXT"));
+    }
+
+    /**
+     * @see Platform#getNativeIdMethod()
+     */
+    public String getNativeIdMethod()
+    {
+        return Platform.SEQUENCE;
+    }
+
+    /**
+     * @see Platform#getAutoIncrement()
+     */
+    public String getAutoIncrement()
+    {
+        return "";
+    }
+
+    /**
+     * @see Platform#hasScale(String)
+     * TODO collect info for all platforms
+     */
+    public boolean hasScale(String sqlType)
+    {
+        if ("INT2".equalsIgnoreCase(sqlType)
+                || "TEXT".equalsIgnoreCase(sqlType))
+        {
+            return false;
+        }
+        return true;
+    }
+
+    /**
+     * @see Platform#hasSize(String)
+     * TODO collect info for all platforms
+     */
+    public boolean hasSize(String sqlType)
+    {
+        if ("INT2".equalsIgnoreCase(sqlType)
+                || "TEXT".equalsIgnoreCase(sqlType))
+        {
+            return false;
+        }
+        return true;
+    }
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org


Mime
View raw message