Home » apache-openjpa-1.1.0-source » org.apache.openjpa.lib » jdbc » [javadoc | source]
    1   /*
    2    * Licensed to the Apache Software Foundation (ASF) under one
    3    * or more contributor license agreements.  See the NOTICE file
    4    * distributed with this work for additional information
    5    * regarding copyright ownership.  The ASF licenses this file
    6    * to you under the Apache License, Version 2.0 (the
    7    * "License"); you may not use this file except in compliance
    8    * with the License.  You may obtain a copy of the License at
    9    *
   10    * http://www.apache.org/licenses/LICENSE-2.0
   11    *
   12    * Unless required by applicable law or agreed to in writing,
   13    * software distributed under the License is distributed on an
   14    * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   15    * KIND, either express or implied.  See the License for the
   16    * specific language governing permissions and limitations
   17    * under the License.    
   18    */
   19   package org.apache.openjpa.lib.jdbc;
   20   
   21   import java.io.InputStream;
   22   import java.io.Reader;
   23   import java.math.BigDecimal;
   24   import java.net.URL;
   25   import java.sql.Array;
   26   import java.sql.Blob;
   27   import java.sql.Clob;
   28   import java.sql.Date;
   29   import java.sql.Ref;
   30   import java.sql.ResultSet;
   31   import java.sql.ResultSetMetaData;
   32   import java.sql.SQLException;
   33   import java.sql.SQLWarning;
   34   import java.sql.Statement;
   35   import java.sql.Time;
   36   import java.sql.Timestamp;
   37   import java.util.Calendar;
   38   import java.util.Map;
   39   
   40   import org.apache.openjpa.lib.util.Closeable;
   41   
   42   /**
   43    * Wrapper around an existing result set. Subclasses can override the
   44    * methods whose behavior they mean to change. The <code>equals</code> and
   45    * <code>hashCode</code> methods pass through to the base underlying data
   46    * store statement.
   47    *
   48    * @author Marc Prud'hommeaux
   49    */
   50   public class DelegatingResultSet implements ResultSet, Closeable {
   51   
   52       private final ResultSet _rs;
   53       private final DelegatingResultSet _del;
   54       private final Statement _stmnt;
   55   
   56       public DelegatingResultSet(ResultSet rs, Statement stmnt) {
   57           if (rs == null)
   58               throw new IllegalArgumentException();
   59   
   60           _stmnt = stmnt;
   61           _rs = rs;
   62           if (_rs instanceof DelegatingResultSet)
   63               _del = (DelegatingResultSet) _rs;
   64           else
   65               _del = null;
   66       }
   67   
   68       /**
   69        * Return the wrapped result set.
   70        */
   71       public ResultSet getDelegate() {
   72           return _rs;
   73       }
   74   
   75       /**
   76        * Return the inner-most wrapped delegate.
   77        */
   78       public ResultSet getInnermostDelegate() {
   79           return (_del == null) ? _rs : _del.getInnermostDelegate();
   80       }
   81   
   82       public int hashCode() {
   83           return _rs.hashCode();
   84       }
   85   
   86       public boolean equals(Object other) {
   87           if (other == this)
   88               return true;
   89           if (other instanceof DelegatingResultSet)
   90               other = ((DelegatingResultSet) other).getInnermostDelegate();
   91           return getInnermostDelegate().equals(other);
   92       }
   93   
   94       public String toString() {
   95           StringBuffer buf = new StringBuffer("resultset ").append(hashCode());
   96           appendInfo(buf);
   97           return buf.toString();
   98       }
   99   
  100       protected void appendInfo(StringBuffer buf) {
  101           if (_del != null)
  102               _del.appendInfo(buf);
  103       }
  104   
  105       public boolean next() throws SQLException {
  106           return _rs.next();
  107       }
  108   
  109       public void close() throws SQLException {
  110           _rs.close();
  111       }
  112   
  113       public boolean wasNull() throws SQLException {
  114           return _rs.wasNull();
  115       }
  116   
  117       public String getString(int a) throws SQLException {
  118           return _rs.getString(a);
  119       }
  120   
  121       public boolean getBoolean(int a) throws SQLException {
  122           return _rs.getBoolean(a);
  123       }
  124   
  125       public byte getByte(int a) throws SQLException {
  126           return _rs.getByte(a);
  127       }
  128   
  129       public short getShort(int a) throws SQLException {
  130           return _rs.getShort(a);
  131       }
  132   
  133       public int getInt(int a) throws SQLException {
  134           return _rs.getInt(a);
  135       }
  136   
  137       public long getLong(int a) throws SQLException {
  138           return _rs.getLong(a);
  139       }
  140   
  141       public float getFloat(int a) throws SQLException {
  142           return _rs.getFloat(a);
  143       }
  144   
  145       public double getDouble(int a) throws SQLException {
  146           return _rs.getDouble(a);
  147       }
  148   
  149       public BigDecimal getBigDecimal(int a, int b) throws SQLException {
  150           return _rs.getBigDecimal(a, b);
  151       }
  152   
  153       public byte[] getBytes(int a) throws SQLException {
  154           return _rs.getBytes(a);
  155       }
  156   
  157       public Date getDate(int a) throws SQLException {
  158           return _rs.getDate(a);
  159       }
  160   
  161       public Time getTime(int a) throws SQLException {
  162           return _rs.getTime(a);
  163       }
  164   
  165       public Timestamp getTimestamp(int a) throws SQLException {
  166           return _rs.getTimestamp(a);
  167       }
  168   
  169       public InputStream getAsciiStream(int a) throws SQLException {
  170           return _rs.getAsciiStream(a);
  171       }
  172   
  173       public InputStream getUnicodeStream(int a) throws SQLException {
  174           return _rs.getUnicodeStream(a);
  175       }
  176   
  177       public InputStream getBinaryStream(int a) throws SQLException {
  178           return _rs.getBinaryStream(a);
  179       }
  180   
  181       public String getString(String a) throws SQLException {
  182           return _rs.getString(a);
  183       }
  184   
  185       public boolean getBoolean(String a) throws SQLException {
  186           return _rs.getBoolean(a);
  187       }
  188   
  189       public byte getByte(String a) throws SQLException {
  190           return _rs.getByte(a);
  191       }
  192   
  193       public short getShort(String a) throws SQLException {
  194           return _rs.getShort(a);
  195       }
  196   
  197       public int getInt(String a) throws SQLException {
  198           return _rs.getInt(a);
  199       }
  200   
  201       public long getLong(String a) throws SQLException {
  202           return _rs.getLong(a);
  203       }
  204   
  205       public float getFloat(String a) throws SQLException {
  206           return _rs.getFloat(a);
  207       }
  208   
  209       public double getDouble(String a) throws SQLException {
  210           return _rs.getDouble(a);
  211       }
  212   
  213       public BigDecimal getBigDecimal(String a, int b) throws SQLException {
  214           return _rs.getBigDecimal(a, b);
  215       }
  216   
  217       public byte[] getBytes(String a) throws SQLException {
  218           return _rs.getBytes(a);
  219       }
  220   
  221       public Date getDate(String a) throws SQLException {
  222           return _rs.getDate(a);
  223       }
  224   
  225       public Time getTime(String a) throws SQLException {
  226           return _rs.getTime(a);
  227       }
  228   
  229       public Timestamp getTimestamp(String a) throws SQLException {
  230           return _rs.getTimestamp(a);
  231       }
  232   
  233       public InputStream getAsciiStream(String a) throws SQLException {
  234           return _rs.getAsciiStream(a);
  235       }
  236   
  237       public InputStream getUnicodeStream(String a) throws SQLException {
  238           return _rs.getUnicodeStream(a);
  239       }
  240   
  241       public InputStream getBinaryStream(String a) throws SQLException {
  242           return _rs.getBinaryStream(a);
  243       }
  244   
  245       public SQLWarning getWarnings() throws SQLException {
  246           return _rs.getWarnings();
  247       }
  248   
  249       public void clearWarnings() throws SQLException {
  250           _rs.clearWarnings();
  251       }
  252   
  253       public String getCursorName() throws SQLException {
  254           return _rs.getCursorName();
  255       }
  256   
  257       public ResultSetMetaData getMetaData() throws SQLException {
  258           return _rs.getMetaData();
  259       }
  260   
  261       public Object getObject(int a) throws SQLException {
  262           return _rs.getObject(a);
  263       }
  264   
  265       public Object getObject(String a) throws SQLException {
  266           return _rs.getObject(a);
  267       }
  268   
  269       public int findColumn(String a) throws SQLException {
  270           return _rs.findColumn(a);
  271       }
  272   
  273       public Reader getCharacterStream(int a) throws SQLException {
  274           return _rs.getCharacterStream(a);
  275       }
  276   
  277       public Reader getCharacterStream(String a) throws SQLException {
  278           return _rs.getCharacterStream(a);
  279       }
  280   
  281       public BigDecimal getBigDecimal(int a) throws SQLException {
  282           return _rs.getBigDecimal(a);
  283       }
  284   
  285       public BigDecimal getBigDecimal(String a) throws SQLException {
  286           return _rs.getBigDecimal(a);
  287       }
  288   
  289       public boolean isBeforeFirst() throws SQLException {
  290           return _rs.isBeforeFirst();
  291       }
  292   
  293       public boolean isAfterLast() throws SQLException {
  294           return _rs.isAfterLast();
  295       }
  296   
  297       public boolean isFirst() throws SQLException {
  298           return _rs.isFirst();
  299       }
  300   
  301       public boolean isLast() throws SQLException {
  302           return _rs.isLast();
  303       }
  304   
  305       public void beforeFirst() throws SQLException {
  306           _rs.beforeFirst();
  307       }
  308   
  309       public void afterLast() throws SQLException {
  310           _rs.afterLast();
  311       }
  312   
  313       public boolean first() throws SQLException {
  314           return _rs.first();
  315       }
  316   
  317       public boolean last() throws SQLException {
  318           return _rs.last();
  319       }
  320   
  321       public int getRow() throws SQLException {
  322           return _rs.getRow();
  323       }
  324   
  325       public boolean absolute(int a) throws SQLException {
  326           return _rs.absolute(a);
  327       }
  328   
  329       public boolean relative(int a) throws SQLException {
  330           return _rs.relative(a);
  331       }
  332   
  333       public boolean previous() throws SQLException {
  334           return _rs.previous();
  335       }
  336   
  337       public void setFetchDirection(int a) throws SQLException {
  338           _rs.setFetchDirection(a);
  339       }
  340   
  341       public int getFetchDirection() throws SQLException {
  342           return _rs.getFetchDirection();
  343       }
  344   
  345       public void setFetchSize(int a) throws SQLException {
  346           _rs.setFetchSize(a);
  347       }
  348   
  349       public int getFetchSize() throws SQLException {
  350           return _rs.getFetchSize();
  351       }
  352   
  353       public int getType() throws SQLException {
  354           return _rs.getType();
  355       }
  356   
  357       public int getConcurrency() throws SQLException {
  358           return _rs.getConcurrency();
  359       }
  360   
  361       public boolean rowUpdated() throws SQLException {
  362           return _rs.rowUpdated();
  363       }
  364   
  365       public boolean rowInserted() throws SQLException {
  366           return _rs.rowInserted();
  367       }
  368   
  369       public boolean rowDeleted() throws SQLException {
  370           return _rs.rowDeleted();
  371       }
  372   
  373       public void updateNull(int a) throws SQLException {
  374           _rs.updateNull(a);
  375       }
  376   
  377       public void updateBoolean(int a, boolean b) throws SQLException {
  378           _rs.updateBoolean(a, b);
  379       }
  380   
  381       public void updateByte(int a, byte b) throws SQLException {
  382           _rs.updateByte(a, b);
  383       }
  384   
  385       public void updateShort(int a, short b) throws SQLException {
  386           _rs.updateShort(a, b);
  387       }
  388   
  389       public void updateInt(int a, int b) throws SQLException {
  390           _rs.updateInt(a, b);
  391       }
  392   
  393       public void updateLong(int a, long b) throws SQLException {
  394           _rs.updateLong(a, b);
  395       }
  396   
  397       public void updateFloat(int a, float b) throws SQLException {
  398           _rs.updateFloat(a, b);
  399       }
  400   
  401       public void updateDouble(int a, double b) throws SQLException {
  402           _rs.updateDouble(a, b);
  403       }
  404   
  405       public void updateBigDecimal(int a, BigDecimal b) throws SQLException {
  406           _rs.updateBigDecimal(a, b);
  407       }
  408   
  409       public void updateString(int a, String b) throws SQLException {
  410           _rs.updateString(a, b);
  411       }
  412   
  413       public void updateBytes(int a, byte[] b) throws SQLException {
  414           _rs.updateBytes(a, b);
  415       }
  416   
  417       public void updateDate(int a, Date b) throws SQLException {
  418           _rs.updateDate(a, b);
  419       }
  420   
  421       public void updateTime(int a, Time b) throws SQLException {
  422           _rs.updateTime(a, b);
  423       }
  424   
  425       public void updateTimestamp(int a, Timestamp b) throws SQLException {
  426           _rs.updateTimestamp(a, b);
  427       }
  428   
  429       public void updateAsciiStream(int a, InputStream in, int b)
  430           throws SQLException {
  431           _rs.updateAsciiStream(a, in, b);
  432       }
  433   
  434       public void updateBinaryStream(int a, InputStream in, int b)
  435           throws SQLException {
  436           _rs.updateBinaryStream(a, in, b);
  437       }
  438   
  439       public void updateBlob(int a, Blob blob) throws SQLException {
  440           _rs.updateBlob(a, blob);
  441       }
  442       
  443       public void updateCharacterStream(int a, Reader reader, int b)
  444           throws SQLException {
  445           _rs.updateCharacterStream(a, reader, b);
  446       }
  447   
  448       public void updateClob(int a, Clob clob) throws SQLException {
  449          _rs.updateClob(a, clob);
  450       }
  451       
  452       public void updateObject(int a, Object ob, int b) throws SQLException {
  453           _rs.updateObject(a, ob, b);
  454       }
  455   
  456       public void updateObject(int a, Object ob) throws SQLException {
  457           _rs.updateObject(a, ob);
  458       }
  459   
  460       public void updateNull(String a) throws SQLException {
  461           _rs.updateNull(a);
  462       }
  463   
  464       public void updateBoolean(String a, boolean b) throws SQLException {
  465           _rs.updateBoolean(a, b);
  466       }
  467   
  468       public void updateByte(String a, byte b) throws SQLException {
  469           _rs.updateByte(a, b);
  470       }
  471   
  472       public void updateShort(String a, short b) throws SQLException {
  473           _rs.updateShort(a, b);
  474       }
  475   
  476       public void updateInt(String a, int b) throws SQLException {
  477           _rs.updateInt(a, b);
  478       }
  479   
  480       public void updateLong(String a, long b) throws SQLException {
  481           _rs.updateLong(a, b);
  482       }
  483   
  484       public void updateFloat(String a, float b) throws SQLException {
  485           _rs.updateFloat(a, b);
  486       }
  487   
  488       public void updateDouble(String a, double b) throws SQLException {
  489           _rs.updateDouble(a, b);
  490       }
  491   
  492       public void updateBigDecimal(String a, BigDecimal b) throws SQLException {
  493           _rs.updateBigDecimal(a, b);
  494       }
  495   
  496       public void updateString(String a, String b) throws SQLException {
  497           _rs.updateString(a, b);
  498       }
  499   
  500       public void updateBytes(String a, byte[] b) throws SQLException {
  501           _rs.updateBytes(a, b);
  502       }
  503   
  504       public void updateDate(String a, Date b) throws SQLException {
  505           _rs.updateDate(a, b);
  506       }
  507   
  508       public void updateTime(String a, Time b) throws SQLException {
  509           _rs.updateTime(a, b);
  510       }
  511   
  512       public void updateTimestamp(String a, Timestamp b) throws SQLException {
  513           _rs.updateTimestamp(a, b);
  514       }
  515   
  516       public void updateAsciiStream(String a, InputStream in, int b)
  517           throws SQLException {
  518           _rs.updateAsciiStream(a, in, b);
  519       }
  520   
  521       public void updateBinaryStream(String a, InputStream in, int b)
  522           throws SQLException {
  523           _rs.updateBinaryStream(a, in, b);
  524       }
  525   
  526       public void updateCharacterStream(String a, Reader reader, int b)
  527           throws SQLException {
  528           _rs.updateCharacterStream(a, reader, b);
  529       }
  530   
  531       public void updateObject(String a, Object ob, int b) throws SQLException {
  532           _rs.updateObject(a, ob, b);
  533       }
  534   
  535       public void updateObject(String a, Object b) throws SQLException {
  536           _rs.updateObject(a, b);
  537       }
  538   
  539       public void insertRow() throws SQLException {
  540           _rs.insertRow();
  541       }
  542   
  543       public void updateRow() throws SQLException {
  544           _rs.updateRow();
  545       }
  546   
  547       public void deleteRow() throws SQLException {
  548           _rs.deleteRow();
  549       }
  550   
  551       public void refreshRow() throws SQLException {
  552           _rs.refreshRow();
  553       }
  554   
  555       public void cancelRowUpdates() throws SQLException {
  556           _rs.cancelRowUpdates();
  557       }
  558   
  559       public void moveToInsertRow() throws SQLException {
  560           _rs.moveToInsertRow();
  561       }
  562   
  563       public void moveToCurrentRow() throws SQLException {
  564           _rs.moveToCurrentRow();
  565       }
  566   
  567       public Statement getStatement() throws SQLException {
  568           return _stmnt;
  569       }
  570   
  571       public Object getObject(int a, Map b) throws SQLException {
  572           return _rs.getObject(a, b);
  573       }
  574   
  575       public Ref getRef(int a) throws SQLException {
  576           return _rs.getRef(a);
  577       }
  578   
  579       public Blob getBlob(int a) throws SQLException {
  580           return _rs.getBlob(a);
  581       }
  582   
  583       public Clob getClob(int a) throws SQLException {
  584           return _rs.getClob(a);
  585       }
  586   
  587       public Array getArray(int a) throws SQLException {
  588           return _rs.getArray(a);
  589       }
  590   
  591       public Object getObject(String a, Map b) throws SQLException {
  592           return _rs.getObject(a, b);
  593       }
  594   
  595       public Ref getRef(String a) throws SQLException {
  596           return _rs.getRef(a);
  597       }
  598   
  599       public Blob getBlob(String a) throws SQLException {
  600           return _rs.getBlob(a);
  601       }
  602   
  603       public Clob getClob(String a) throws SQLException {
  604           return _rs.getClob(a);
  605       }
  606   
  607       public Array getArray(String a) throws SQLException {
  608           return _rs.getArray(a);
  609       }
  610   
  611       public Date getDate(int a, Calendar b) throws SQLException {
  612           return _rs.getDate(a, b);
  613       }
  614   
  615       public Date getDate(String a, Calendar b) throws SQLException {
  616           return _rs.getDate(a, b);
  617       }
  618   
  619       public Time getTime(int a, Calendar b) throws SQLException {
  620           return _rs.getTime(a, b);
  621       }
  622   
  623       public Time getTime(String a, Calendar b) throws SQLException {
  624           return _rs.getTime(a, b);
  625       }
  626   
  627       public Timestamp getTimestamp(int a, Calendar b) throws SQLException {
  628           return _rs.getTimestamp(a, b);
  629       }
  630   
  631       public Timestamp getTimestamp(String a, Calendar b) throws SQLException {
  632           return _rs.getTimestamp(a, b);
  633       }
  634   
  635       // JDBC 3.0 (unsupported) method follow; these are required to be able
  636       // to compile against JDK 1.4
  637   
  638       public URL getURL(int column) throws SQLException {
  639           throw new UnsupportedOperationException();
  640       }
  641   
  642       public URL getURL(String columnName) throws SQLException {
  643           throw new UnsupportedOperationException();
  644       }
  645   
  646       public void updateRef(int column, Ref ref) throws SQLException {
  647           throw new UnsupportedOperationException();
  648       }
  649   
  650       public void updateRef(String columnName, Ref ref) throws SQLException {
  651           throw new UnsupportedOperationException();
  652       }
  653   
  654       public void updateBlob(String columnName, Blob blob) throws SQLException {
  655           throw new UnsupportedOperationException();
  656       }
  657   
  658       public void updateClob(String columnName, Clob clob) throws SQLException {
  659           throw new UnsupportedOperationException();
  660       }
  661   
  662       public void updateArray(int column, Array array) throws SQLException {
  663           throw new UnsupportedOperationException();
  664       }
  665   
  666       public void updateArray(String columnName, Array array)
  667           throws SQLException {
  668           throw new UnsupportedOperationException();
  669       }
  670   }
  671   

Save This Page
Home » apache-openjpa-1.1.0-source » org.apache.openjpa.lib » jdbc » [javadoc | source]