use of org.odata4j.core.OCollection in project teiid by teiid.
the class ODataExecutionFactory method retrieveValue.
/**
* @param value
* @param expectedType
* @return
*/
public Object retrieveValue(Object value, Class<?> expectedType) {
if (value == null) {
return null;
}
if (value instanceof LocalDateTime) {
DateTime dateTime = ((LocalDateTime) value).toDateTime(DateTimeZone.forTimeZone(this.timeZone));
return new java.sql.Timestamp(dateTime.getMillis());
}
if (value instanceof LocalTime) {
return new java.sql.Timestamp(((LocalTime) value).toDateTimeToday().getMillis());
}
if (value instanceof UnsignedByte) {
return Short.valueOf(((UnsignedByte) value).shortValue());
}
if (expectedType.isArray() && value instanceof OCollection<?>) {
ArrayList<Object> result = new ArrayList<Object>();
OCollection<?> arrayValues = (OCollection<?>) value;
Iterator<?> it = arrayValues.iterator();
while (it.hasNext()) {
OSimpleObject<?> item = (OSimpleObject<?>) it.next();
result.add(retrieveValue(item.getValue(), expectedType.getComponentType()));
}
Object target = java.lang.reflect.Array.newInstance(expectedType.getComponentType(), result.size());
System.arraycopy(result.toArray(), 0, target, 0, result.size());
value = target;
}
return value;
}
Aggregations