| /* |
| * Licensed to the Apache Software Foundation (ASF) under one |
| * or more contributor license agreements. See the NOTICE file |
| * distributed with this work for additional information |
| * regarding copyright ownership. The ASF licenses this file |
| * to you 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 org.apache.openjpa.slice.jdbc; |
| |
| 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.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.LinkedList; |
| import java.util.Map; |
| |
| /** |
| * A chain of ResultSet. |
| * |
| * @author Pinaki Poddar |
| * |
| */ |
| class DistributedResultSet implements ResultSet { |
| LinkedList<ResultSet> comps = new LinkedList<ResultSet>(); |
| ResultSet current; |
| int cursor = -1; |
| |
| /** |
| * Adds the ResultSet only if it has rows. |
| */ |
| public void add(ResultSet rs) { |
| try { |
| if (rs.first()) |
| comps.add(rs); |
| } catch (SQLException e) { |
| // ignore |
| } |
| } |
| |
| public boolean absolute(int arg0) throws SQLException { |
| throw new UnsupportedOperationException(); |
| } |
| |
| public void afterLast() throws SQLException { |
| current = null; |
| cursor = comps.size(); |
| } |
| |
| public void beforeFirst() throws SQLException { |
| current = null; |
| cursor = -1; |
| } |
| |
| public void cancelRowUpdates() throws SQLException { |
| throw new UnsupportedOperationException(); |
| } |
| |
| public void clearWarnings() throws SQLException { |
| for (ResultSet rs:comps) |
| rs.clearWarnings(); |
| } |
| |
| public void close() throws SQLException { |
| for (ResultSet rs:comps) |
| rs.close(); |
| } |
| |
| public void deleteRow() throws SQLException { |
| current.deleteRow(); |
| } |
| |
| public int findColumn(String arg0) throws SQLException { |
| return 0; |
| } |
| |
| public boolean first() throws SQLException { |
| if (comps.isEmpty()) return false; |
| cursor = 0; |
| current = comps.get(0); |
| return true; |
| } |
| |
| public Array getArray(int arg0) throws SQLException { |
| return current.getArray(arg0); |
| } |
| |
| public Array getArray(String arg0) throws SQLException { |
| return current.getArray(arg0); |
| } |
| |
| public InputStream getAsciiStream(int arg0) throws SQLException { |
| return current.getAsciiStream(arg0); |
| } |
| |
| public InputStream getAsciiStream(String arg0) throws SQLException { |
| return current.getAsciiStream(arg0); |
| } |
| |
| public BigDecimal getBigDecimal(int arg0) throws SQLException { |
| return current.getBigDecimal(arg0); |
| } |
| |
| public BigDecimal getBigDecimal(String arg0) throws SQLException { |
| return current.getBigDecimal(arg0); |
| } |
| |
| public BigDecimal getBigDecimal(int arg0, int arg1) throws SQLException { |
| return current.getBigDecimal(arg0, arg1); |
| } |
| |
| public BigDecimal getBigDecimal(String arg0, int arg1) throws SQLException { |
| return current.getBigDecimal(arg0, arg1); |
| } |
| |
| public InputStream getBinaryStream(int arg0) throws SQLException { |
| return current.getBinaryStream(arg0); |
| } |
| |
| public InputStream getBinaryStream(String arg0) throws SQLException { |
| return current.getBinaryStream(arg0); |
| } |
| |
| public Blob getBlob(int arg0) throws SQLException { |
| return current.getBlob(arg0); |
| } |
| |
| public Blob getBlob(String arg0) throws SQLException { |
| // TODO Auto-generated method stub |
| return null; |
| } |
| |
| public boolean getBoolean(int arg0) throws SQLException { |
| // TODO Auto-generated method stub |
| return false; |
| } |
| |
| public boolean getBoolean(String arg0) throws SQLException { |
| // TODO Auto-generated method stub |
| return false; |
| } |
| |
| public byte getByte(int arg0) throws SQLException { |
| // TODO Auto-generated method stub |
| return 0; |
| } |
| |
| public byte getByte(String arg0) throws SQLException { |
| // TODO Auto-generated method stub |
| return 0; |
| } |
| |
| public byte[] getBytes(int arg0) throws SQLException { |
| // TODO Auto-generated method stub |
| return null; |
| } |
| |
| public byte[] getBytes(String arg0) throws SQLException { |
| // TODO Auto-generated method stub |
| return null; |
| } |
| |
| public Reader getCharacterStream(int arg0) throws SQLException { |
| // TODO Auto-generated method stub |
| return null; |
| } |
| |
| public Reader getCharacterStream(String arg0) throws SQLException { |
| // TODO Auto-generated method stub |
| return null; |
| } |
| |
| public Clob getClob(int arg0) throws SQLException { |
| // TODO Auto-generated method stub |
| return null; |
| } |
| |
| public Clob getClob(String arg0) throws SQLException { |
| // TODO Auto-generated method stub |
| return null; |
| } |
| |
| public int getConcurrency() throws SQLException { |
| // TODO Auto-generated method stub |
| return 0; |
| } |
| |
| public String getCursorName() throws SQLException { |
| // TODO Auto-generated method stub |
| return null; |
| } |
| |
| public Date getDate(int arg0) throws SQLException { |
| // TODO Auto-generated method stub |
| return null; |
| } |
| |
| public Date getDate(String arg0) throws SQLException { |
| // TODO Auto-generated method stub |
| return null; |
| } |
| |
| public Date getDate(int arg0, Calendar arg1) throws SQLException { |
| // TODO Auto-generated method stub |
| return null; |
| } |
| |
| public Date getDate(String arg0, Calendar arg1) throws SQLException { |
| // TODO Auto-generated method stub |
| return null; |
| } |
| |
| public double getDouble(int arg0) throws SQLException { |
| // TODO Auto-generated method stub |
| return 0; |
| } |
| |
| public double getDouble(String arg0) throws SQLException { |
| // TODO Auto-generated method stub |
| return 0; |
| } |
| |
| public int getFetchDirection() throws SQLException { |
| // TODO Auto-generated method stub |
| return 0; |
| } |
| |
| public int getFetchSize() throws SQLException { |
| // TODO Auto-generated method stub |
| return 0; |
| } |
| |
| public float getFloat(int arg0) throws SQLException { |
| // TODO Auto-generated method stub |
| return 0; |
| } |
| |
| public float getFloat(String arg0) throws SQLException { |
| // TODO Auto-generated method stub |
| return 0; |
| } |
| |
| public int getInt(int arg0) throws SQLException { |
| // TODO Auto-generated method stub |
| return 0; |
| } |
| |
| public int getInt(String arg0) throws SQLException { |
| // TODO Auto-generated method stub |
| return 0; |
| } |
| |
| public long getLong(int arg0) throws SQLException { |
| // TODO Auto-generated method stub |
| return 0; |
| } |
| |
| public long getLong(String arg0) throws SQLException { |
| // TODO Auto-generated method stub |
| return 0; |
| } |
| |
| public ResultSetMetaData getMetaData() throws SQLException { |
| // TODO Auto-generated method stub |
| return null; |
| } |
| |
| public Object getObject(int arg0) throws SQLException { |
| // TODO Auto-generated method stub |
| return null; |
| } |
| |
| public Object getObject(String arg0) throws SQLException { |
| // TODO Auto-generated method stub |
| return null; |
| } |
| |
| public Object getObject(int arg0, Map<String, Class<?>> arg1) |
| throws SQLException { |
| // TODO Auto-generated method stub |
| return null; |
| } |
| |
| public Object getObject(String arg0, Map<String, Class<?>> arg1) |
| throws SQLException { |
| // TODO Auto-generated method stub |
| return null; |
| } |
| |
| public Ref getRef(int arg0) throws SQLException { |
| // TODO Auto-generated method stub |
| return null; |
| } |
| |
| public Ref getRef(String arg0) throws SQLException { |
| // TODO Auto-generated method stub |
| return null; |
| } |
| |
| public int getRow() throws SQLException { |
| // TODO Auto-generated method stub |
| return 0; |
| } |
| |
| public short getShort(int arg0) throws SQLException { |
| // TODO Auto-generated method stub |
| return 0; |
| } |
| |
| public short getShort(String arg0) throws SQLException { |
| // TODO Auto-generated method stub |
| return 0; |
| } |
| |
| public Statement getStatement() throws SQLException { |
| // TODO Auto-generated method stub |
| return null; |
| } |
| |
| public String getString(int arg0) throws SQLException { |
| // TODO Auto-generated method stub |
| return null; |
| } |
| |
| public String getString(String arg0) throws SQLException { |
| // TODO Auto-generated method stub |
| return null; |
| } |
| |
| public Time getTime(int arg0) throws SQLException { |
| // TODO Auto-generated method stub |
| return null; |
| } |
| |
| public Time getTime(String arg0) throws SQLException { |
| // TODO Auto-generated method stub |
| return null; |
| } |
| |
| public Time getTime(int arg0, Calendar arg1) throws SQLException { |
| // TODO Auto-generated method stub |
| return null; |
| } |
| |
| public Time getTime(String arg0, Calendar arg1) throws SQLException { |
| // TODO Auto-generated method stub |
| return null; |
| } |
| |
| public Timestamp getTimestamp(int arg0) throws SQLException { |
| // TODO Auto-generated method stub |
| return null; |
| } |
| |
| public Timestamp getTimestamp(String arg0) throws SQLException { |
| // TODO Auto-generated method stub |
| return null; |
| } |
| |
| public Timestamp getTimestamp(int arg0, Calendar arg1) throws SQLException { |
| // TODO Auto-generated method stub |
| return null; |
| } |
| |
| public Timestamp getTimestamp(String arg0, Calendar arg1) |
| throws SQLException { |
| // TODO Auto-generated method stub |
| return null; |
| } |
| |
| public int getType() throws SQLException { |
| // TODO Auto-generated method stub |
| return 0; |
| } |
| |
| public URL getURL(int arg0) throws SQLException { |
| // TODO Auto-generated method stub |
| return null; |
| } |
| |
| public URL getURL(String arg0) throws SQLException { |
| // TODO Auto-generated method stub |
| return null; |
| } |
| |
| public InputStream getUnicodeStream(int arg0) throws SQLException { |
| // TODO Auto-generated method stub |
| return null; |
| } |
| |
| public InputStream getUnicodeStream(String arg0) throws SQLException { |
| // TODO Auto-generated method stub |
| return null; |
| } |
| |
| public SQLWarning getWarnings() throws SQLException { |
| // TODO Auto-generated method stub |
| return null; |
| } |
| |
| public void insertRow() throws SQLException { |
| // TODO Auto-generated method stub |
| |
| } |
| |
| public boolean isAfterLast() throws SQLException { |
| return current == null && cursor >= comps.size(); |
| } |
| |
| public boolean isBeforeFirst() throws SQLException { |
| return current == null && cursor<0; |
| } |
| |
| public boolean isFirst() throws SQLException { |
| return current != null && current.isFirst() && cursor==0; |
| } |
| |
| public boolean isLast() throws SQLException { |
| return current != null && current.isLast() && cursor==comps.size()-1; |
| } |
| |
| public boolean last() throws SQLException { |
| if (comps.isEmpty()) return false; |
| cursor = comps.size()-1; |
| return false; |
| } |
| |
| public void moveToCurrentRow() throws SQLException { |
| // TODO Auto-generated method stub |
| |
| } |
| |
| public void moveToInsertRow() throws SQLException { |
| // TODO Auto-generated method stub |
| |
| } |
| |
| public boolean next() throws SQLException { |
| if (current == null) { |
| current = comps.get(0); |
| cursor = 0; |
| } |
| if (current.next()) |
| return true; |
| cursor++; |
| if (cursor<comps.size()) |
| current = comps.get(cursor); |
| return cursor<comps.size(); |
| } |
| |
| public boolean previous() throws SQLException { |
| return current.previous(); |
| } |
| |
| public void refreshRow() throws SQLException { |
| // TODO Auto-generated method stub |
| |
| } |
| |
| public boolean relative(int arg0) throws SQLException { |
| // TODO Auto-generated method stub |
| return false; |
| } |
| |
| public boolean rowDeleted() throws SQLException { |
| // TODO Auto-generated method stub |
| return false; |
| } |
| |
| public boolean rowInserted() throws SQLException { |
| // TODO Auto-generated method stub |
| return false; |
| } |
| |
| public boolean rowUpdated() throws SQLException { |
| // TODO Auto-generated method stub |
| return false; |
| } |
| |
| public void setFetchDirection(int arg0) throws SQLException { |
| // TODO Auto-generated method stub |
| |
| } |
| |
| public void setFetchSize(int arg0) throws SQLException { |
| // TODO Auto-generated method stub |
| |
| } |
| |
| public void updateArray(int arg0, Array arg1) throws SQLException { |
| // TODO Auto-generated method stub |
| |
| } |
| |
| public void updateArray(String arg0, Array arg1) throws SQLException { |
| // TODO Auto-generated method stub |
| |
| } |
| |
| public void updateAsciiStream(int arg0, InputStream arg1, int arg2) |
| throws SQLException { |
| // TODO Auto-generated method stub |
| |
| } |
| |
| public void updateAsciiStream(String arg0, InputStream arg1, int arg2) |
| throws SQLException { |
| // TODO Auto-generated method stub |
| |
| } |
| |
| public void updateBigDecimal(int arg0, BigDecimal arg1) throws SQLException { |
| // TODO Auto-generated method stub |
| |
| } |
| |
| public void updateBigDecimal(String arg0, BigDecimal arg1) |
| throws SQLException { |
| // TODO Auto-generated method stub |
| |
| } |
| |
| public void updateBinaryStream(int arg0, InputStream arg1, int arg2) |
| throws SQLException { |
| // TODO Auto-generated method stub |
| |
| } |
| |
| public void updateBinaryStream(String arg0, InputStream arg1, int arg2) |
| throws SQLException { |
| // TODO Auto-generated method stub |
| |
| } |
| |
| public void updateBlob(int arg0, Blob arg1) throws SQLException { |
| // TODO Auto-generated method stub |
| |
| } |
| |
| public void updateBlob(String arg0, Blob arg1) throws SQLException { |
| // TODO Auto-generated method stub |
| |
| } |
| |
| public void updateBoolean(int arg0, boolean arg1) throws SQLException { |
| // TODO Auto-generated method stub |
| |
| } |
| |
| public void updateBoolean(String arg0, boolean arg1) throws SQLException { |
| // TODO Auto-generated method stub |
| |
| } |
| |
| public void updateByte(int arg0, byte arg1) throws SQLException { |
| // TODO Auto-generated method stub |
| |
| } |
| |
| public void updateByte(String arg0, byte arg1) throws SQLException { |
| // TODO Auto-generated method stub |
| |
| } |
| |
| public void updateBytes(int arg0, byte[] arg1) throws SQLException { |
| // TODO Auto-generated method stub |
| |
| } |
| |
| public void updateBytes(String arg0, byte[] arg1) throws SQLException { |
| // TODO Auto-generated method stub |
| |
| } |
| |
| public void updateCharacterStream(int arg0, Reader arg1, int arg2) |
| throws SQLException { |
| // TODO Auto-generated method stub |
| |
| } |
| |
| public void updateCharacterStream(String arg0, Reader arg1, int arg2) |
| throws SQLException { |
| // TODO Auto-generated method stub |
| |
| } |
| |
| public void updateClob(int arg0, Clob arg1) throws SQLException { |
| // TODO Auto-generated method stub |
| |
| } |
| |
| public void updateClob(String arg0, Clob arg1) throws SQLException { |
| // TODO Auto-generated method stub |
| |
| } |
| |
| public void updateDate(int arg0, Date arg1) throws SQLException { |
| // TODO Auto-generated method stub |
| |
| } |
| |
| public void updateDate(String arg0, Date arg1) throws SQLException { |
| // TODO Auto-generated method stub |
| |
| } |
| |
| public void updateDouble(int arg0, double arg1) throws SQLException { |
| // TODO Auto-generated method stub |
| |
| } |
| |
| public void updateDouble(String arg0, double arg1) throws SQLException { |
| // TODO Auto-generated method stub |
| |
| } |
| |
| public void updateFloat(int arg0, float arg1) throws SQLException { |
| // TODO Auto-generated method stub |
| |
| } |
| |
| public void updateFloat(String arg0, float arg1) throws SQLException { |
| // TODO Auto-generated method stub |
| |
| } |
| |
| public void updateInt(int arg0, int arg1) throws SQLException { |
| // TODO Auto-generated method stub |
| |
| } |
| |
| public void updateInt(String arg0, int arg1) throws SQLException { |
| // TODO Auto-generated method stub |
| |
| } |
| |
| public void updateLong(int arg0, long arg1) throws SQLException { |
| // TODO Auto-generated method stub |
| |
| } |
| |
| public void updateLong(String arg0, long arg1) throws SQLException { |
| // TODO Auto-generated method stub |
| |
| } |
| |
| public void updateNull(int arg0) throws SQLException { |
| // TODO Auto-generated method stub |
| |
| } |
| |
| public void updateNull(String arg0) throws SQLException { |
| // TODO Auto-generated method stub |
| |
| } |
| |
| public void updateObject(int arg0, Object arg1) throws SQLException { |
| // TODO Auto-generated method stub |
| |
| } |
| |
| public void updateObject(String arg0, Object arg1) throws SQLException { |
| // TODO Auto-generated method stub |
| |
| } |
| |
| public void updateObject(int arg0, Object arg1, int arg2) |
| throws SQLException { |
| // TODO Auto-generated method stub |
| |
| } |
| |
| public void updateObject(String arg0, Object arg1, int arg2) |
| throws SQLException { |
| // TODO Auto-generated method stub |
| |
| } |
| |
| public void updateRef(int arg0, Ref arg1) throws SQLException { |
| // TODO Auto-generated method stub |
| |
| } |
| |
| public void updateRef(String arg0, Ref arg1) throws SQLException { |
| // TODO Auto-generated method stub |
| |
| } |
| |
| public void updateRow() throws SQLException { |
| // TODO Auto-generated method stub |
| |
| } |
| |
| public void updateShort(int arg0, short arg1) throws SQLException { |
| // TODO Auto-generated method stub |
| |
| } |
| |
| public void updateShort(String arg0, short arg1) throws SQLException { |
| // TODO Auto-generated method stub |
| |
| } |
| |
| public void updateString(int arg0, String arg1) throws SQLException { |
| // TODO Auto-generated method stub |
| |
| } |
| |
| public void updateString(String arg0, String arg1) throws SQLException { |
| // TODO Auto-generated method stub |
| |
| } |
| |
| public void updateTime(int arg0, Time arg1) throws SQLException { |
| // TODO Auto-generated method stub |
| |
| } |
| |
| public void updateTime(String arg0, Time arg1) throws SQLException { |
| // TODO Auto-generated method stub |
| |
| } |
| |
| public void updateTimestamp(int arg0, Timestamp arg1) throws SQLException { |
| // TODO Auto-generated method stub |
| |
| } |
| |
| public void updateTimestamp(String arg0, Timestamp arg1) |
| throws SQLException { |
| // TODO Auto-generated method stub |
| |
| } |
| |
| public boolean wasNull() throws SQLException { |
| // TODO Auto-generated method stub |
| return false; |
| } |
| |
| } |