co.paralleluniverse.fibers.jdbc.FiberArray Maven / Gradle / Ivy
The newest version!
/*
* COMSAT
* Copyright (c) 2013-2015, Parallel Universe Software Co. All rights reserved.
*
* This program and the accompanying materials are dual-licensed under
* either the terms of the Eclipse Public License v1.0 as published by
* the Eclipse Foundation
*
* or (per the licensee's choosing)
*
* under the terms of the GNU Lesser General Public License version 3.0
* as published by the Free Software Foundation.
*/
package co.paralleluniverse.fibers.jdbc;
import co.paralleluniverse.common.util.CheckedCallable;
import co.paralleluniverse.fibers.Suspendable;
import java.sql.Array;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Map;
import java.util.concurrent.ExecutorService;
/**
* @author crclespainter
*/
public class FiberArray implements Array {
private final Array array;
private final ExecutorService executor;
public FiberArray(final Array array, final ExecutorService executor) {
this.array = array;
this.executor = executor;
}
@Override
@Suspendable
public String getBaseTypeName() throws SQLException {
return JDBCFiberAsync.exec(executor, new CheckedCallable() {
@Override
public String call() throws SQLException {
return array.getBaseTypeName();
}
});
}
@Override
@Suspendable
public int getBaseType() throws SQLException {
return JDBCFiberAsync.exec(executor, new CheckedCallable() {
@Override
public Integer call() throws SQLException {
return array.getBaseType();
}
});
}
@Override
@Suspendable
public Object getArray() throws SQLException {
return JDBCFiberAsync.exec(executor, new CheckedCallable