[libpostgresql-jdbc-java] 101/128: add uuid array support (rename ArrayElementBuilder to ArrayAssistant)
Emmanuel Bourg
ebourg-guest at moszumanska.debian.org
Mon Jan 9 10:18:35 UTC 2017
This is an automated email from the git hooks/post-receive script.
ebourg-guest pushed a commit to annotated tag REL9_3_1100
in repository libpostgresql-jdbc-java.
commit 7e6b7bd32f4447d0db08045bc6cf4429223d71cd
Author: tminglei <tmlneu at gmail.com>
Date: Sat Aug 24 19:13:54 2013 +0800
add uuid array support (rename ArrayElementBuilder to ArrayAssistant)
---
org/postgresql/jdbc2/AbstractJdbc2Array.java | 22 +++++++++++-----------
...rrayElementBuilder.java => ArrayAssistant.java} | 6 +++---
org/postgresql/jdbc2/ArrayAssistantRegistry.java | 22 ++++++++++++++++++++++
.../jdbc2/ArrayElementBuilderFactory.java | 20 --------------------
org/postgresql/jdbc4/Jdbc4Array.java | 8 ++++----
...ElementBuilder.java => UUIDArrayAssistant.java} | 6 +++---
6 files changed, 43 insertions(+), 41 deletions(-)
diff --git a/org/postgresql/jdbc2/AbstractJdbc2Array.java b/org/postgresql/jdbc2/AbstractJdbc2Array.java
index 5d83a95..ce6a526 100644
--- a/org/postgresql/jdbc2/AbstractJdbc2Array.java
+++ b/org/postgresql/jdbc2/AbstractJdbc2Array.java
@@ -19,7 +19,6 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Types;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -234,9 +233,9 @@ public abstract class AbstractJdbc2Array
arr[i] = encoding.decode(fieldBytes, pos, len);
break;
default:
- ArrayElementBuilder arrElemBuilder = ArrayElementBuilderFactory.getArrayElementBuilder(elementOid);
- if (arrElemBuilder != null) {
- arr[i] = arrElemBuilder.buildElement(fieldBytes, pos, len);
+ ArrayAssistant arrAssistant = ArrayAssistantRegistry.getAssistant(elementOid);
+ if (arrAssistant != null) {
+ arr[i] = arrAssistant.buildElement(fieldBytes, pos, len);
}
}
pos += len;
@@ -357,9 +356,9 @@ public abstract class AbstractJdbc2Array
case Oid.VARCHAR:
return String.class;
default:
- ArrayElementBuilder arrElemBuilder = ArrayElementBuilderFactory.getArrayElementBuilder(oid);
+ ArrayAssistant arrElemBuilder = ArrayAssistantRegistry.getAssistant(oid);
if (arrElemBuilder != null) {
- return arrElemBuilder.getElementClass();
+ return arrElemBuilder.baseType();
}
throw org.postgresql.Driver.notImplemented(this.getClass(),
@@ -747,18 +746,19 @@ public abstract class AbstractJdbc2Array
}
}
- else if (ArrayElementBuilderFactory.getArrayElementBuilder(oid) != null) {
- ArrayElementBuilder arrElemBuilder = ArrayElementBuilderFactory.getArrayElementBuilder(oid);
+ else if (ArrayAssistantRegistry.getAssistant(oid) != null)
+ {
+ ArrayAssistant arrAssistant = ArrayAssistantRegistry.getAssistant(oid);
Object[] oa = null;
- ret = oa = (dims > 1) ? (Object[]) java.lang.reflect.Array.newInstance(arrElemBuilder.getElementClass(), dimsLength)
- : (Object[]) java.lang.reflect.Array.newInstance(arrElemBuilder.getElementClass(), count) ;
+ ret = oa = (dims > 1) ? (Object[]) java.lang.reflect.Array.newInstance(arrAssistant.baseType(), dimsLength)
+ : (Object[]) java.lang.reflect.Array.newInstance(arrAssistant.baseType(), count) ;
for (; count > 0; count--)
{
Object v = input.get(index++);
oa[length++] = (dims > 1 && v != null) ? buildArray((PgArrayList) v, 0, -1)
- : (v == null ? null : arrElemBuilder.buildElement((String) v));
+ : (v == null ? null : arrAssistant.buildElement((String) v));
}
}
diff --git a/org/postgresql/jdbc2/ArrayElementBuilder.java b/org/postgresql/jdbc2/ArrayAssistant.java
similarity index 86%
rename from org/postgresql/jdbc2/ArrayElementBuilder.java
rename to org/postgresql/jdbc2/ArrayAssistant.java
index 04a6893..854e4f6 100644
--- a/org/postgresql/jdbc2/ArrayElementBuilder.java
+++ b/org/postgresql/jdbc2/ArrayAssistant.java
@@ -1,18 +1,18 @@
package org.postgresql.jdbc2;
/**
- * Implement this interface and register the its instance to ArrayElementBuilderFactory,
+ * Implement this interface and register the its instance to ArrayAssistantRegistry,
* to let Postgres driver to support more array type
*
* @author Minglei Tu
*/
-public interface ArrayElementBuilder {
+public interface ArrayAssistant {
/**
* get array base type
*
* @return
*/
- Class getElementClass();
+ Class baseType();
/**
* build a array element from its binary bytes
diff --git a/org/postgresql/jdbc2/ArrayAssistantRegistry.java b/org/postgresql/jdbc2/ArrayAssistantRegistry.java
new file mode 100644
index 0000000..316d65f
--- /dev/null
+++ b/org/postgresql/jdbc2/ArrayAssistantRegistry.java
@@ -0,0 +1,22 @@
+package org.postgresql.jdbc2;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Array assistants register here
+ *
+ * @author Minglei Tu
+ */
+public class ArrayAssistantRegistry {
+ private static Map arrayAssistantMap = new HashMap();
+
+ public static ArrayAssistant getAssistant(int oid) {
+ return (ArrayAssistant) arrayAssistantMap.get(new Integer(oid));
+ }
+
+ ////
+ public static void register(int oid, ArrayAssistant assistant) {
+ arrayAssistantMap.put(new Integer(oid), assistant);
+ }
+}
diff --git a/org/postgresql/jdbc2/ArrayElementBuilderFactory.java b/org/postgresql/jdbc2/ArrayElementBuilderFactory.java
deleted file mode 100644
index 47f60a1..0000000
--- a/org/postgresql/jdbc2/ArrayElementBuilderFactory.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package org.postgresql.jdbc2;
-
-import java.util.HashMap;
-import java.util.Map;
-
-public class ArrayElementBuilderFactory {
- private static Map builderMap = new HashMap();
-
- public static void setArrayElementBuilder(int oid, ArrayElementBuilder builder) {
- if (builder == null) {
- builderMap.remove(new Integer(oid));
- } else {
- builderMap.put(new Integer(oid), builder);
- }
- }
-
- public static ArrayElementBuilder getArrayElementBuilder(int oid) {
- return (ArrayElementBuilder) builderMap.get(new Integer(oid));
- }
-}
diff --git a/org/postgresql/jdbc4/Jdbc4Array.java b/org/postgresql/jdbc4/Jdbc4Array.java
index 0289f15..d6dc10e 100644
--- a/org/postgresql/jdbc4/Jdbc4Array.java
+++ b/org/postgresql/jdbc4/Jdbc4Array.java
@@ -9,8 +9,8 @@ package org.postgresql.jdbc4;
import java.util.Map;
import org.postgresql.core.*;
-import org.postgresql.jdbc2.ArrayElementBuilderFactory;
-import org.postgresql.jdbc4.array.UUIDArrayElementBuilder;
+import org.postgresql.jdbc2.ArrayAssistantRegistry;
+import org.postgresql.jdbc4.array.UUIDArrayAssistant;
import java.sql.SQLException;
import java.sql.ResultSet;
@@ -18,8 +18,8 @@ import java.sql.ResultSet;
public class Jdbc4Array extends org.postgresql.jdbc2.AbstractJdbc2Array implements java.sql.Array
{
static {
- ArrayElementBuilderFactory.setArrayElementBuilder(Oid.UUID, new UUIDArrayElementBuilder());
- ArrayElementBuilderFactory.setArrayElementBuilder(Oid.UUID_ARRAY, new UUIDArrayElementBuilder());
+ ArrayAssistantRegistry.register(Oid.UUID, new UUIDArrayAssistant());
+ ArrayAssistantRegistry.register(Oid.UUID_ARRAY, new UUIDArrayAssistant());
}
public Jdbc4Array(BaseConnection conn, int oid, String fieldString) throws SQLException
diff --git a/org/postgresql/jdbc4/array/UUIDArrayElementBuilder.java b/org/postgresql/jdbc4/array/UUIDArrayAssistant.java
similarity index 74%
rename from org/postgresql/jdbc4/array/UUIDArrayElementBuilder.java
rename to org/postgresql/jdbc4/array/UUIDArrayAssistant.java
index 6080c03..bb08731 100644
--- a/org/postgresql/jdbc4/array/UUIDArrayElementBuilder.java
+++ b/org/postgresql/jdbc4/array/UUIDArrayAssistant.java
@@ -1,13 +1,13 @@
package org.postgresql.jdbc4.array;
-import org.postgresql.jdbc2.ArrayElementBuilder;
+import org.postgresql.jdbc2.ArrayAssistant;
import org.postgresql.util.ByteConverter;
import java.util.UUID;
-public class UUIDArrayElementBuilder implements ArrayElementBuilder {
+public class UUIDArrayAssistant implements ArrayAssistant {
@Override
- public Class getElementClass() {
+ public Class baseType() {
return UUID.class;
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/libpostgresql-jdbc-java.git
More information about the pkg-java-commits
mailing list