private void append(StringBuilder buf, Object o) { if (o == null) { buf.append("null"); } else if (o.getClass().isArray()) { append(buf, AvaticaUtils.primitiveList(o)); } else { buf.append(o); } }
private void append(StringBuilder buf, Object o) { if (o == null) { buf.append("null"); } else if (o.getClass().isArray()) { append(buf, AvaticaUtils.primitiveList(o)); } else { buf.append(o); } }
@Override public Object getObject() { final Object object = super.getObject(); if (object == null || object instanceof List) { return object; } // The object can be java array in case of user-provided class for row // storage. return AvaticaUtils.primitiveList(object); }
private void append(StringBuilder buf, Object o) { if (o == null) { buf.append("null"); } else if (o.getClass().isArray()) { append(buf, AvaticaUtils.primitiveList(o)); } else { buf.append(o); } }
/** * Converts an Array into a List using {@link Array#getArray()}. This implementation assumes * a non-nested array. Use {link {@link #extractUsingResultSet(Array, Calendar)} if nested * arrays may be possible. */ static List<?> extractUsingArray(Array array, Calendar calendar) throws SQLException { // No option but to guess as to what the type actually is... Object o = array.getArray(); if (o instanceof List) { return (List<?>) o; } // Assume that it's a Java array. return AvaticaUtils.primitiveList(o); } }
/** * Converts an Array into a List using {@link Array#getArray()}. This implementation assumes * a non-nested array. Use {link {@link #extractUsingResultSet(Array, Calendar)} if nested * arrays may be possible. */ static List<?> extractUsingArray(Array array, Calendar calendar) throws SQLException { // No option but to guess as to what the type actually is... Object o = array.getArray(); if (o instanceof List) { return (List<?>) o; } // Assume that it's a Java array. return AvaticaUtils.primitiveList(o); } }
@Override public Object getObject() throws SQLException { final Object object = super.getObject(); if (object == null || object instanceof ArrayImpl) { return object; } else if (object instanceof List) { List<?> list = (List<?>) object; // Run the array values through the component accessor List<Object> convertedValues = new ArrayList<>(list.size()); for (Object val : list) { if (null == val) { convertedValues.add(null); } else { // Set the current value in the SlotGetter so we can use the Accessor to coerce it. componentSlotGetter.slot = val; convertedValues.add(convertValue()); } } return convertedValues; } // The object can be java array in case of user-provided class for row storage. return AvaticaUtils.primitiveList(object); }
@Override public Object getObject() throws SQLException { final Object object = super.getObject(); if (object == null || object instanceof ArrayImpl) { return object; } else if (object instanceof List) { List<?> list = (List<?>) object; // Run the array values through the component accessor List<Object> convertedValues = new ArrayList<>(list.size()); for (Object val : list) { if (null == val) { convertedValues.add(null); } else { // Set the current value in the SlotGetter so we can use the Accessor to coerce it. componentSlotGetter.slot = val; convertedValues.add(convertValue()); } } return convertedValues; } // The object can be java array in case of user-provided class for row storage. return AvaticaUtils.primitiveList(object); }
default: return AvaticaUtils.primitiveList(array.getArray());
default: return AvaticaUtils.primitiveList(array.getArray());
public Array createArrayOf(String typeName, Object[] elements) throws SQLException { checkOpen(); @SuppressWarnings("unchecked") List<Object> elementList = (List<Object>) AvaticaUtils.primitiveList(elements); SqlType type; try { type = SqlType.valueOf(typeName); } catch (IllegalArgumentException e) { throw new SQLException("Could not find JDBC type for '" + typeName + "'"); } AvaticaType avaticaType = null; switch (type) { case ARRAY: // TODO: Nested ARRAYs throw HELPER.createException("Cannot create an ARRAY of ARRAY's"); case STRUCT: // TODO: ARRAYs of STRUCTs throw HELPER.createException("Cannot create an ARRAY of STRUCT's"); default: // This is an ARRAY, we need to use Objects, not primitives (nullable). avaticaType = ColumnMetaData.scalar(type.id, typeName, Rep.nonPrimitiveRepOf(type)); } ArrayFactoryImpl arrayFactory = new ArrayFactoryImpl(getTimeZone()); return arrayFactory.createArray(avaticaType, elementList); }
public Array createArrayOf(String typeName, Object[] elements) throws SQLException { checkOpen(); @SuppressWarnings("unchecked") List<Object> elementList = (List<Object>) AvaticaUtils.primitiveList(elements); SqlType type; try { type = SqlType.valueOf(typeName); } catch (IllegalArgumentException e) { throw new SQLException("Could not find JDBC type for '" + typeName + "'"); } AvaticaType avaticaType = null; switch (type) { case ARRAY: // TODO: Nested ARRAYs throw HELPER.createException("Cannot create an ARRAY of ARRAY's"); case STRUCT: // TODO: ARRAYs of STRUCTs throw HELPER.createException("Cannot create an ARRAY of STRUCT's"); default: // This is an ARRAY, we need to use Objects, not primitives (nullable). avaticaType = ColumnMetaData.scalar(type.id, typeName, Rep.nonPrimitiveRepOf(type)); } ArrayFactoryImpl arrayFactory = new ArrayFactoryImpl(getTimeZone()); return arrayFactory.createArray(avaticaType, elementList); }