package org.elasticsearch.jdbc; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.SQLWarning; import java.sql.Statement; public abstract class AbstractResultSet extends AbstractFeatureNotSupportedResultSet { protected boolean isClosed = false; protected Statement statement; public AbstractResultSet(Statement statement) { this.statement = statement; } @Override public void close() throws SQLException { isClosed = true; } @Override public boolean isClosed() throws SQLException { return isClosed; } @Override public int findColumn(String columnLabel) throws SQLException { //aways return first col return 1; } @Override public boolean wasNull() throws SQLException { return false; } @Override public SQLWarning getWarnings() throws SQLException { return null; } @Override public void clearWarnings() throws SQLException { // ignore } @Override public int getFetchDirection() throws SQLException { return ResultSet.FETCH_FORWARD; } @Override public int getType() throws SQLException { return ResultSet.TYPE_FORWARD_ONLY; } @Override public int getConcurrency() throws SQLException { return ResultSet.CONCUR_READ_ONLY; } @Override public Statement getStatement() throws SQLException { return statement; } @Override public int getHoldability() throws SQLException { return ResultSet.CLOSE_CURSORS_AT_COMMIT; } @Override public Object getObject(int columnIndex) throws SQLException { return getString(columnIndex); } @Override public Object getObject(String columnLabel) throws SQLException { return getString(columnLabel); } @Override @SuppressWarnings("unchecked") public final T unwrap(final Class iface) throws SQLException { if (isWrapperFor(iface)) { return (T) this; } throw new SQLException(String.format("[%s] cannot be unwrapped as [%s]", getClass().getName(), iface.getName())); } @Override public final boolean isWrapperFor(final Class iface) throws SQLException { return iface.isInstance(this); } }