📄 axionresultset.java
字号:
/* * $Id: AxionResultSet.java,v 1.24 2003/07/09 23:56:17 rwald Exp $ * ======================================================================= * Copyright (c) 2002-2003 Axion Development Team. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above * copyright notice, this list of conditions and the following * disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The names "Tigris", "Axion", nor the names of its contributors may * not be used to endorse or promote products derived from this * software without specific prior written permission. * * 4. Products derived from this software may not be called "Axion", nor * may "Tigris" or "Axion" appear in their names without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ======================================================================= */package org.axiondb.jdbc;import java.io.ByteArrayInputStream;import java.io.InputStream;import java.io.Reader;import java.io.UnsupportedEncodingException;import java.math.BigDecimal;import java.math.BigInteger;import java.net.URL;import java.sql.Array;import java.sql.Blob;import java.sql.Clob;import java.sql.Date;import java.sql.Ref;import java.sql.ResultSet;import java.sql.ResultSetMetaData;import java.sql.SQLException;import java.sql.SQLWarning;import java.sql.Statement;import java.sql.Time;import java.sql.Timestamp;import java.util.Calendar;import java.util.Collections;import java.util.Map;import org.apache.commons.logging.Log;import org.apache.commons.logging.LogFactory;import org.axiondb.AxionException;import org.axiondb.ColumnIdentifier;import org.axiondb.DataType;import org.axiondb.RowDecorator;import org.axiondb.RowDecoratorIterator;import org.axiondb.Selectable;import org.axiondb.Transaction;import org.axiondb.TransactionManager;import org.axiondb.engine.rowiterators.EmptyRowIterator;import org.axiondb.engine.rowiterators.RowIteratorRowDecoratorIterator;import org.axiondb.util.ExceptionConverter;/** * A {@link java.sql.ResultSet} implementation. * * @TODO Support currently unsupported JDBC 3 methods. * @version $Revision: 1.24 $ $Date: 2003/07/09 23:56:17 $ * @author Chuck Burdick * @author Rodney Waldhoff */public class AxionResultSet implements ResultSet { public AxionResultSet(RowDecoratorIterator rows, Selectable[] selected) { _rows = rows; _selected = selected; _meta = new AxionResultSetMetaData(selected); } public void setTransaction(TransactionManager manager, Transaction transaction) { _transactionManager = manager; _transaction = transaction; } public static ResultSet createEmptyResultSet() { return new AxionResultSet(new RowIteratorRowDecoratorIterator(EmptyRowIterator.INSTANCE,new RowDecorator(Collections.EMPTY_MAP)),new Selectable[0]); } //------------------------------------------------------- ResultSet Methods public boolean absolute(int row) throws SQLException { throw new UnsupportedOperationException(); } public void afterLast() throws SQLException { throw new UnsupportedOperationException(); } public void beforeFirst() throws SQLException { try { _rows.reset(); _currentRowIndex = 0; //TODO: this should probably be an attribute of the RowDecoratorIterator } catch(AxionException e) { throw ExceptionConverter.convert(e); } catch(RuntimeException e) { throw ExceptionConverter.convert(e); } } public void cancelRowUpdates() throws SQLException { throw new UnsupportedOperationException(); } public void clearWarnings() throws SQLException { } public void close() throws SQLException { if(null != _transactionManager && null != _transaction) { try { _transactionManager.commitTransaction(_transaction); } catch(AxionException e) { throw ExceptionConverter.convert(e); } _transactionManager = null; _transaction = null; } _closed = true; _selected = null; _currentRow = null; } public void deleteRow() throws SQLException { throw new UnsupportedOperationException(); } public int findColumn(String colName) throws SQLException { assertOpen(); return getResultSetIndexForColumnName(colName); } public boolean first() throws SQLException { beforeFirst(); return next(); } public Array getArray(int i) throws SQLException { throw new UnsupportedOperationException(); } public Array getArray(String colName) throws SQLException { return getArray(getResultSetIndexForColumnName(colName)); } public InputStream getAsciiStream(int i) throws SQLException { Clob clob = getClob(i); if(null == clob) { return NULL_STREAM; } else { return clob.getAsciiStream(); } } public InputStream getAsciiStream(String colName) throws SQLException { return getAsciiStream(getResultSetIndexForColumnName(colName)); } public BigDecimal getBigDecimal(int i) throws SQLException { Object value = getValue(i); if(null == value) { return NULL_BIGDECIMAL; } else { return getDataType(i).toBigDecimal(value); } } public BigDecimal getBigDecimal(String colName) throws SQLException { return getBigDecimal(getResultSetIndexForColumnName(colName)); } /** @deprecated See {@link java.sql.ResultSet#getBigDecimal(int,int)} */ public BigDecimal getBigDecimal(int i, int scale) throws SQLException { Object value = getValue(i); if(null == value) { return NULL_BIGDECIMAL; } else { BigInteger bigint = getDataType(i).toBigInteger(value); if(null == bigint) { return NULL_BIGDECIMAL; } else { return new BigDecimal(bigint,scale); } } } /** @deprecated See {@link java.sql.ResultSet#getBigDecimal(java.lang.String,int)} */ public BigDecimal getBigDecimal(String colName, int scale) throws SQLException { return getBigDecimal(getResultSetIndexForColumnName(colName),scale); } public InputStream getBinaryStream(int i) throws SQLException { Blob blob = getBlob(i); if(null == blob) { return NULL_STREAM; } else { return blob.getBinaryStream(); } } public InputStream getBinaryStream(String colName) throws SQLException { return getBinaryStream(getResultSetIndexForColumnName(colName)); } public Blob getBlob(int i) throws SQLException { Object value = getValue(i); if(null == value) { return NULL_BLOB; } else { return getDataType(i).toBlob(value); } } public Blob getBlob(String colName) throws SQLException { return getBlob(getResultSetIndexForColumnName(colName)); } public boolean getBoolean(int i) throws SQLException { Object value = getValue(i); if(null == value) { return NULL_BOOLEAN; } else { return getDataType(i).toBoolean(value); } } public boolean getBoolean(String colName) throws SQLException { return getBoolean(getResultSetIndexForColumnName(colName)); } public byte getByte(int i) throws SQLException { Object value = getValue(i); if(null == value) { return NULL_BYTE; } else { return getDataType(i).toByte(value); } } public byte getByte(String colName) throws SQLException { return getByte(getResultSetIndexForColumnName(colName)); } public byte[] getBytes(int i) throws SQLException { throw new UnsupportedOperationException(); } public byte[] getBytes(String colName) throws SQLException { return getBytes(getResultSetIndexForColumnName(colName)); } public Reader getCharacterStream(int i) throws SQLException { Clob clob = getClob(i); if(null == clob) { return NULL_READER; } else { return clob.getCharacterStream(); } } public Reader getCharacterStream(String colName) throws SQLException { return getCharacterStream(getResultSetIndexForColumnName(colName)); } public Clob getClob(int i) throws SQLException { Object value = getValue(i); if(null == value) { return NULL_CLOB; } else { return getDataType(i).toClob(value); } } public Clob getClob(String colName) throws SQLException { return getClob(getResultSetIndexForColumnName(colName)); } public int getConcurrency() throws SQLException { throw new UnsupportedOperationException(); } public String getCursorName() throws SQLException { throw new UnsupportedOperationException(); } public Date getDate(int i) throws SQLException { Object value = getValue(i); if(null == value) { return NULL_DATE; } else { return getDataType(i).toDate(value); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -