[Schmitzm-commits] r778 - in trunk/src/skrueger: . db

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Mon Mar 29 12:53:15 CEST 2010


Author: alfonx
Date: 2010-03-29 12:53:14 +0200 (Mon, 29 Mar 2010)
New Revision: 778

Added:
   trunk/src/skrueger/db/
   trunk/src/skrueger/db/PGUtil.java
Log:
Neue PGUtil mit Hilfsmethoden f?\195?\188r PostgreSQL erstellt.

Added: trunk/src/skrueger/db/PGUtil.java
===================================================================
--- trunk/src/skrueger/db/PGUtil.java	2010-03-29 10:48:38 UTC (rev 777)
+++ trunk/src/skrueger/db/PGUtil.java	2010-03-29 10:53:14 UTC (rev 778)
@@ -0,0 +1,29 @@
+package skrueger.db;
+
+/**
+ * Hilfsmethoden für PostgreSQL
+ */
+public class PGUtil {
+
+	/**
+	 * @param binding
+	 *            Eine "einfache" Javaklasse, die in PG abgebildet werden soll.
+	 * @return einen PG-spezifischen Datentypenamen für einen Javatyp zurück, z.b. "double precision" für <code>Double.class</code> 
+	 */
+	public static String getColTypeName(Class<?> binding) {
+
+		if (binding.isAssignableFrom(Double.class)) {
+			return "double precision"; // eg 'number' at oracle
+		} else if (binding.isAssignableFrom(String.class)) {
+			return "text";
+		} else if (binding.isAssignableFrom(Integer.class)) {
+			return "integer";
+		} else if (binding.isAssignableFrom(Long.class)) {
+			return "bigint";
+		}
+
+		throw new RuntimeException("DB Type mapping for " + binding
+				+ " not yet implemented.");
+	}
+
+}


Property changes on: trunk/src/skrueger/db/PGUtil.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Id URL
Name: svn:eol-style
   + native



More information about the Schmitzm-commits mailing list