[libpostgresql-jdbc-java] 100/128: add uuid array support
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 2d1327b28418b5e22f428d84d21ed110db1f3c42
Author: tminglei <tmlneu at gmail.com>
Date: Sat Aug 24 16:28:21 2013 +0800
add uuid array support
---
org/postgresql/jdbc4/Jdbc4Array.java | 8 ++++++++
.../jdbc4/array/UUIDArrayElementBuilder.java | 23 ++++++++++++++++++++++
org/postgresql/test/jdbc4/ArrayTest.java | 2 +-
3 files changed, 32 insertions(+), 1 deletion(-)
diff --git a/org/postgresql/jdbc4/Jdbc4Array.java b/org/postgresql/jdbc4/Jdbc4Array.java
index 130b663..0289f15 100644
--- a/org/postgresql/jdbc4/Jdbc4Array.java
+++ b/org/postgresql/jdbc4/Jdbc4Array.java
@@ -9,11 +9,19 @@ package org.postgresql.jdbc4;
import java.util.Map;
import org.postgresql.core.*;
+import org.postgresql.jdbc2.ArrayElementBuilderFactory;
+import org.postgresql.jdbc4.array.UUIDArrayElementBuilder;
+
import java.sql.SQLException;
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());
+ }
+
public Jdbc4Array(BaseConnection conn, int oid, String fieldString) throws SQLException
{
super(conn, oid, fieldString);
diff --git a/org/postgresql/jdbc4/array/UUIDArrayElementBuilder.java b/org/postgresql/jdbc4/array/UUIDArrayElementBuilder.java
new file mode 100644
index 0000000..6080c03
--- /dev/null
+++ b/org/postgresql/jdbc4/array/UUIDArrayElementBuilder.java
@@ -0,0 +1,23 @@
+package org.postgresql.jdbc4.array;
+
+import org.postgresql.jdbc2.ArrayElementBuilder;
+import org.postgresql.util.ByteConverter;
+
+import java.util.UUID;
+
+public class UUIDArrayElementBuilder implements ArrayElementBuilder {
+ @Override
+ public Class getElementClass() {
+ return UUID.class;
+ }
+
+ @Override
+ public Object buildElement(byte[] bytes, int pos, int len) {
+ return new UUID(ByteConverter.int8(bytes, pos + 0), ByteConverter.int8(bytes, pos + 8));
+ }
+
+ @Override
+ public Object buildElement(String literal) {
+ return UUID.fromString(literal);
+ }
+}
diff --git a/org/postgresql/test/jdbc4/ArrayTest.java b/org/postgresql/test/jdbc4/ArrayTest.java
index 827df87..9eec6af 100644
--- a/org/postgresql/test/jdbc4/ArrayTest.java
+++ b/org/postgresql/test/jdbc4/ArrayTest.java
@@ -24,7 +24,7 @@ public class ArrayTest extends TestCase {
protected void setUp() throws Exception {
_conn = TestUtil.openDB();
- TestUtil.createTable(_conn, "arrtest", "intarr int[], decarr decimal(2,1)[], strarr text[]");
+ TestUtil.createTable(_conn, "arrtest", "intarr int[], decarr decimal(2,1)[], strarr text[], uuidarr uuid[]");
}
protected void tearDown() throws SQLException {
--
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