public Object getArrayImpl(long index, int count, Map map) throws SQLException { // for now maps aren't supported. if (map != null && !map.isEmpty()) { throw org.postgresql.Driver.notImplemented(this.getClass(), "getArrayImpl(long,int,Map)"); } // array index is out of range if (index < 1) { throw new PSQLException(GT.tr("The array index is out of range: {0}", new Long(index)), PSQLState.DATA_ERROR); } buildArrayList(); if (count == 0) count = arrayList.size(); // array index out of range if ((--index) + count > arrayList.size()) { throw new PSQLException(GT.tr("The array index is out of range: {0}, number of elements: {1}.", new Object[] { new Long(index + count), new Long(arrayList.size()) }), PSQLState.DATA_ERROR); } return buildArray(arrayList, (int) index, count); }
/** * Convert array list to PG String representation (e.g. {0,1,2}). */ private String toString(PgArrayList list) throws SQLException { StringBuffer b = new StringBuffer().append('{'); char delim = connection.getTypeInfo().getArrayDelimiter(oid); for (int i = 0; i < list.size(); i++) { Object v = list.get(i); if (i > 0) b.append(delim); if (v == null) b.append("NULL"); else if (v instanceof PgArrayList) b.append(toString((PgArrayList) v)); else escapeArrayElement(b, (String)v); } b.append('}'); return b.toString(); }
public int getBaseType() throws SQLException { return connection.getTypeInfo().getSQLType(getBaseTypeName()); }
buildArrayList(); t[1] = v == null ? null : connection.encodeString(toString((PgArrayList) v)); rows.add(t);
oa[length++] = o == null ? null : (dims > 1 ? buildArray((PgArrayList) o, 0, -1) : new Boolean(AbstractJdbc2ResultSet.toBoolean((String) o))); oa[length++] = o == null ? null : (dims > 1 ? buildArray((PgArrayList) o, 0, -1) : new Integer(AbstractJdbc2ResultSet.toInt((String) o))); oa[length++] = o == null ? null : (dims > 1 ? buildArray((PgArrayList) o, 0, -1) : new Long(AbstractJdbc2ResultSet.toLong((String) o))); oa[length++] = dims > 1 && v != null ? buildArray((PgArrayList) v, 0, -1) : (v == null ? null : AbstractJdbc2ResultSet.toBigDecimal((String) v, -1)); oa[length++] = o == null ? null : (dims > 1 ? buildArray((PgArrayList) o, 0, -1) : new Float(AbstractJdbc2ResultSet.toFloat((String) o))); oa[length++] = o == null ? null : (dims > 1 ? buildArray((PgArrayList) o, 0, -1) : new Double(AbstractJdbc2ResultSet.toDouble((String) o))); oa[length++] = dims > 1 && v != null ? buildArray((PgArrayList) v, 0, -1) : v; oa[length++] = dims > 1 && v != null ? buildArray((PgArrayList) v, 0, -1) : (v == null ? null : connection.getTimestampUtils().toDate(null, (String) v)); oa[length++] = dims > 1 && v != null ? buildArray((PgArrayList) v, 0, -1) : (v == null ? null : connection.getTimestampUtils().toTime(null, (String) v)); oa[length++] = dims > 1 && v != null ? buildArray((PgArrayList) v, 0, -1) : (v == null ? null : connection.getTimestampUtils().toTimestamp(null, (String) v)); connection.getLogger().debug("getArrayImpl(long,int,Map) with " + getBaseTypeName());
public Object getArray() throws SQLException { return getArrayImpl(1, 0, null); }
public java.sql.ResultSet getResultSet() throws SQLException { return getResultSetImpl(1, 0, null); }
public String getBaseTypeName() throws SQLException { buildArrayList(); int elementOID = connection.getTypeInfo().getPGArrayElement(oid); return connection.getTypeInfo().getPGType(elementOID); }
private static void appendArray(StringBuffer sb, Object elements) { sb.append('{'); int nElements = java.lang.reflect.Array.getLength(elements); for (int i=0; i<nElements; i++) { if (i > 0) { sb.append(','); } Object o = java.lang.reflect.Array.get(elements, i); if (o == null) { sb.append("NULL"); } else if (o.getClass().isArray()) { appendArray(sb, o); } else { String s = o.toString(); AbstractJdbc2Array.escapeArrayElement(sb, s); } } sb.append('}'); }
buildArrayList(); t[1] = v == null ? null : connection.encodeString(toString((PgArrayList) v)); rows.add(t);
oa[length++] = o == null ? null : (dims > 1 ? buildArray((PgArrayList) o, 0, -1) : new Boolean(AbstractJdbc2ResultSet.toBoolean((String) o))); oa[length++] = o == null ? null : (dims > 1 ? buildArray((PgArrayList) o, 0, -1) : new Integer(AbstractJdbc2ResultSet.toInt((String) o))); oa[length++] = o == null ? null : (dims > 1 ? buildArray((PgArrayList) o, 0, -1) : new Long(AbstractJdbc2ResultSet.toLong((String) o))); oa[length++] = dims > 1 && v != null ? buildArray((PgArrayList) v, 0, -1) : (v == null ? null : AbstractJdbc2ResultSet.toBigDecimal((String) v, -1)); oa[length++] = o == null ? null : (dims > 1 ? buildArray((PgArrayList) o, 0, -1) : new Float(AbstractJdbc2ResultSet.toFloat((String) o))); oa[length++] = o == null ? null : (dims > 1 ? buildArray((PgArrayList) o, 0, -1) : new Double(AbstractJdbc2ResultSet.toDouble((String) o))); oa[length++] = dims > 1 && v != null ? buildArray((PgArrayList) v, 0, -1) : v; oa[length++] = dims > 1 && v != null ? buildArray((PgArrayList) v, 0, -1) : (v == null ? null : connection.getTimestampUtils().toDate(null, (String) v)); oa[length++] = dims > 1 && v != null ? buildArray((PgArrayList) v, 0, -1) : (v == null ? null : connection.getTimestampUtils().toTime(null, (String) v)); oa[length++] = dims > 1 && v != null ? buildArray((PgArrayList) v, 0, -1) : (v == null ? null : connection.getTimestampUtils().toTimestamp(null, (String) v)); connection.getLogger().debug("getArrayImpl(long,int,Map) with " + getBaseTypeName());
public Object getArray(long index, int count) throws SQLException { return getArrayImpl(index, count, null); }
public java.sql.ResultSet getResultSet(long index, int count) throws SQLException { return getResultSetImpl(index, count, null); }
public String getBaseTypeName() throws SQLException { buildArrayList(); int elementOID = connection.getTypeInfo().getPGArrayElement(oid); return connection.getTypeInfo().getPGType(elementOID); }
private static void appendArray(StringBuffer sb, Object elements) { sb.append('{'); int nElements = java.lang.reflect.Array.getLength(elements); for (int i=0; i<nElements; i++) { if (i > 0) { sb.append(','); } Object o = java.lang.reflect.Array.get(elements, i); if (o == null) { sb.append("NULL"); } else if (o.getClass().isArray()) { appendArray(sb, o); } else { String s = o.toString(); AbstractJdbc2Array.escapeArrayElement(sb, s); } } sb.append('}'); }
public Object getArrayImpl(long index, int count, Map map) throws SQLException { // for now maps aren't supported. if (map != null && !map.isEmpty()) { throw org.postgresql.Driver.notImplemented(this.getClass(), "getArrayImpl(long,int,Map)"); } // array index is out of range if (index < 1) { throw new PSQLException(GT.tr("The array index is out of range: {0}", new Long(index)), PSQLState.DATA_ERROR); } buildArrayList(); if (count == 0) count = arrayList.size(); // array index out of range if ((--index) + count > arrayList.size()) { throw new PSQLException(GT.tr("The array index is out of range: {0}, number of elements: {1}.", new Object[] { new Long(index + count), new Long(arrayList.size()) }), PSQLState.DATA_ERROR); } return buildArray(arrayList, (int) index, count); }
buildArrayList(); t[1] = v == null ? null : connection.encodeString(toString((PgArrayList) v)); rows.add(t);
/** * Convert array list to PG String representation (e.g. {0,1,2}). */ private String toString(PgArrayList list) throws SQLException { StringBuffer b = new StringBuffer().append('{'); char delim = connection.getTypeInfo().getArrayDelimiter(oid); for (int i = 0; i < list.size(); i++) { Object v = list.get(i); if (i > 0) b.append(delim); if (v == null) b.append("NULL"); else if (v instanceof PgArrayList) b.append(toString((PgArrayList) v)); else escapeArrayElement(b, (String)v); } b.append('}'); return b.toString(); }
oa[length++] = o == null ? null : (dims > 1 ? buildArray((PgArrayList) o, 0, -1) : new Boolean(AbstractJdbc2ResultSet.toBoolean((String) o))); oa[length++] = o == null ? null : (dims > 1 ? buildArray((PgArrayList) o, 0, -1) : new Integer(AbstractJdbc2ResultSet.toInt((String) o))); oa[length++] = o == null ? null : (dims > 1 ? buildArray((PgArrayList) o, 0, -1) : new Long(AbstractJdbc2ResultSet.toLong((String) o))); oa[length++] = dims > 1 && v != null ? buildArray((PgArrayList) v, 0, -1) : (v == null ? null : AbstractJdbc2ResultSet.toBigDecimal((String) v, -1)); oa[length++] = o == null ? null : (dims > 1 ? buildArray((PgArrayList) o, 0, -1) : new Float(AbstractJdbc2ResultSet.toFloat((String) o))); oa[length++] = o == null ? null : (dims > 1 ? buildArray((PgArrayList) o, 0, -1) : new Double(AbstractJdbc2ResultSet.toDouble((String) o))); oa[length++] = dims > 1 && v != null ? buildArray((PgArrayList) v, 0, -1) : v; oa[length++] = dims > 1 && v != null ? buildArray((PgArrayList) v, 0, -1) : (v == null ? null : connection.getTimestampUtils().toDate(null, (String) v)); oa[length++] = dims > 1 && v != null ? buildArray((PgArrayList) v, 0, -1) : (v == null ? null : connection.getTimestampUtils().toTime(null, (String) v)); oa[length++] = dims > 1 && v != null ? buildArray((PgArrayList) v, 0, -1) : (v == null ? null : connection.getTimestampUtils().toTimestamp(null, (String) v)); connection.getLogger().debug("getArrayImpl(long,int,Map) with " + getBaseTypeName());
public Object getArray(long index, int count) throws SQLException { return getArrayImpl(index, count, null); }