/* * Copyright 2016 requery.io * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.requery.android.sqlite; import java.io.InputStream; import java.io.Reader; import java.math.BigDecimal; import java.net.URL; import java.sql.Array; import java.sql.Blob; import java.sql.Clob; import java.sql.Date; import java.sql.NClob; import java.sql.Ref; import java.sql.ResultSet; import java.sql.ResultSetMetaData; import java.sql.RowId; import java.sql.SQLException; import java.sql.SQLFeatureNotSupportedException; import java.sql.SQLWarning; import java.sql.SQLXML; import java.sql.Statement; import java.sql.Time; import java.sql.Timestamp; import java.util.Calendar; import java.util.Map; public class SingleResultSet extends NonUpdateableResultSet { private final Statement statement; private final long value; public SingleResultSet(Statement statement, long value) throws SQLException { if (value == -1) { throw new SQLException("invalid row id"); } this.statement = statement; this.value = value; } @Override public boolean absolute(int row) throws SQLException { return row == 1; } @Override public void afterLast() throws SQLException { } @Override public void beforeFirst() throws SQLException { } @Override public void cancelRowUpdates() throws SQLException { } @Override public void clearWarnings() throws SQLException { } @Override public void close() throws SQLException { } @Override public void deleteRow() throws SQLException { } @Override public int findColumn(String columnName) throws SQLException { return 1; } @Override public boolean first() throws SQLException { return true; } @Override public Array getArray(int columnIndex) throws SQLException { return null; } @Override public Array getArray(String colName) throws SQLException { return null; } @Override public InputStream getAsciiStream(int columnIndex) throws SQLException { return null; } @Override public InputStream getAsciiStream(String columnName) throws SQLException { return null; } @Override public BigDecimal getBigDecimal(int columnIndex) throws SQLException { return null; } @Override public BigDecimal getBigDecimal(int columnIndex, int scale) throws SQLException { return null; } @Override public BigDecimal getBigDecimal(String columnName) throws SQLException { return null; } @Override public BigDecimal getBigDecimal(String columnName, int scale) throws SQLException { return null; } @Override public InputStream getBinaryStream(int columnIndex) throws SQLException { return null; } @Override public InputStream getBinaryStream(String columnName) throws SQLException { return null; } @Override public Blob getBlob(int columnIndex) throws SQLException { return null; } @Override public Blob getBlob(String columnName) throws SQLException { return null; } @Override public boolean getBoolean(int columnIndex) throws SQLException { return false; } @Override public boolean getBoolean(String columnName) throws SQLException { return false; } @Override public byte getByte(int columnIndex) throws SQLException { return 0; } @Override public byte getByte(String columnName) throws SQLException { return 0; } @Override public byte[] getBytes(int columnIndex) throws SQLException { return null; } @Override public byte[] getBytes(String columnName) throws SQLException { return null; } @Override public Reader getCharacterStream(int columnIndex) throws SQLException { return null; } @Override public Reader getCharacterStream(String columnName) throws SQLException { return null; } @Override public Clob getClob(int columnIndex) throws SQLException { return null; } @Override public Clob getClob(String colName) throws SQLException { return null; } @Override public int getConcurrency() throws SQLException { return ResultSet.CONCUR_READ_ONLY; } @Override public String getCursorName() throws SQLException { return null; } @Override public Date getDate(int columnIndex) throws SQLException { return null; } @Override public Date getDate(int columnIndex, Calendar cal) throws SQLException { return null; } @Override public Date getDate(String columnName) throws SQLException { return null; } @Override public Date getDate(String columnName, Calendar cal) throws SQLException { return null; } @Override public double getDouble(int columnIndex) throws SQLException { return 0; } @Override public double getDouble(String columnName) throws SQLException { return 0; } @Override public int getFetchDirection() throws SQLException { return ResultSet.FETCH_FORWARD; } @Override public int getFetchSize() throws SQLException { return 0; } @Override public float getFloat(int columnIndex) throws SQLException { return 0; } @Override public float getFloat(String columnName) throws SQLException { return 0; } @Override public int getInt(int columnIndex) throws SQLException { return (int) value; } @Override public int getInt(String columnName) throws SQLException { return (int) value; } @Override public long getLong(int columnIndex) throws SQLException { return value; } @Override public long getLong(String columnName) throws SQLException { return value; } @Override public ResultSetMetaData getMetaData() throws SQLException { return null; } @Override public Object getObject(int columnIndex) throws SQLException { return value; } @Override public Object getObject(int columnIndex, Map<String, Class<?>> map) throws SQLException { return value; } @Override public Object getObject(String columnName) throws SQLException { return value; } @Override public Object getObject(String columnName, Map<String, Class<?>> map) throws SQLException { return value; } @Override public Ref getRef(int columnIndex) throws SQLException { return null; } @Override public Ref getRef(String colName) throws SQLException { return null; } @Override public int getRow() throws SQLException { return 0; } @Override public short getShort(int columnIndex) throws SQLException { return (short) value; } @Override public short getShort(String columnName) throws SQLException { return (short) value; } @Override public Statement getStatement() throws SQLException { return statement; } @Override public String getString(int columnIndex) throws SQLException { return String.valueOf(value); } @Override public String getString(String columnName) throws SQLException { return String.valueOf(value); } @Override public Time getTime(int columnIndex) throws SQLException { return null; } @Override public Time getTime(int columnIndex, Calendar cal) throws SQLException { return null; } @Override public Time getTime(String columnName) throws SQLException { return null; } @Override public Time getTime(String columnName, Calendar cal) throws SQLException { return null; } @Override public Timestamp getTimestamp(int columnIndex) throws SQLException { return null; } @Override public Timestamp getTimestamp(int columnIndex, Calendar cal) throws SQLException { return null; } @Override public Timestamp getTimestamp(String columnName) throws SQLException { return null; } @Override public Timestamp getTimestamp(String columnName, Calendar cal) throws SQLException { return null; } @Override public int getType() throws SQLException { return ResultSet.TYPE_FORWARD_ONLY; } @Override public InputStream getUnicodeStream(int columnIndex) throws SQLException { return null; } @Override public InputStream getUnicodeStream(String columnName) throws SQLException { return null; } @Override public URL getURL(int columnIndex) throws SQLException { return null; } @Override public URL getURL(String columnName) throws SQLException { return null; } @Override public SQLWarning getWarnings() throws SQLException { return null; } @Override public void insertRow() throws SQLException { } @Override public boolean isAfterLast() throws SQLException { return false; } @Override public boolean isBeforeFirst() throws SQLException { return false; } @Override public boolean isFirst() throws SQLException { return false; } @Override public boolean isLast() throws SQLException { return true; } @Override public boolean last() throws SQLException { return false; } @Override public void moveToCurrentRow() throws SQLException { throw new SQLFeatureNotSupportedException(); } @Override public void moveToInsertRow() throws SQLException { throw new SQLFeatureNotSupportedException(); } @Override public boolean next() throws SQLException { return true; } @Override public boolean previous() throws SQLException { return false; } @Override public void refreshRow() throws SQLException { } @Override public boolean relative(int rows) throws SQLException { return false; } @Override public boolean rowDeleted() throws SQLException { return false; } @Override public boolean rowInserted() throws SQLException { return false; } @Override public boolean rowUpdated() throws SQLException { return false; } @Override public void setFetchDirection(int direction) throws SQLException { } @Override public void setFetchSize(int rows) throws SQLException { } @Override public boolean wasNull() throws SQLException { return false; } @Override public RowId getRowId(int columnIndex) throws SQLException { return null; } @Override public RowId getRowId(String columnLabel) throws SQLException { return null; } @Override public int getHoldability() throws SQLException { return ResultSet.CLOSE_CURSORS_AT_COMMIT; } @Override public boolean isClosed() throws SQLException { return false; } @Override public NClob getNClob(int columnIndex) throws SQLException { return null; } @Override public NClob getNClob(String columnLabel) throws SQLException { return null; } @Override public SQLXML getSQLXML(int columnIndex) throws SQLException { return null; } @Override public SQLXML getSQLXML(String columnLabel) throws SQLException { return null; } @Override public String getNString(int columnIndex) throws SQLException { return null; } @Override public String getNString(String columnLabel) throws SQLException { return null; } @Override public Reader getNCharacterStream(int columnIndex) throws SQLException { return null; } @Override public Reader getNCharacterStream(String columnLabel) throws SQLException { return null; } @Override public <T> T unwrap(Class<T> iface) throws SQLException { return null; } @Override public boolean isWrapperFor(Class<?> iface) throws SQLException { return false; } }