< prev index next >

src/java.sql.rowset/share/classes/com/sun/rowset/CachedRowSetImpl.java

Print this page
rev 52881 : 8214971: Replace use of string.equals("") with isEmpty()
Reviewed-by: jlaskey, prappo, lancea, dfuchs, redestad


 576     //-----------------------------------------------------------------------
 577 
 578     /**
 579      * Sets this <code>CachedRowSetImpl</code> object's command property
 580      * to the given <code>String</code> object and clears the parameters,
 581      * if any, that were set for the previous command.
 582      * <P>
 583      * The command property may not be needed
 584      * if the rowset is produced by a data source, such as a spreadsheet,
 585      * that does not support commands. Thus, this property is optional
 586      * and may be <code>null</code>.
 587      *
 588      * @param cmd a <code>String</code> object containing an SQL query
 589      *            that will be set as the command; may be <code>null</code>
 590      * @throws SQLException if an error occurs
 591      */
 592     public void setCommand(String cmd) throws SQLException {
 593 
 594         super.setCommand(cmd);
 595 
 596         if(!buildTableName(cmd).equals("")) {
 597             this.setTableName(buildTableName(cmd));
 598         }
 599     }
 600 
 601 
 602     //---------------------------------------------------------------------
 603     // Reading and writing data
 604     //---------------------------------------------------------------------
 605 
 606     /**
 607      * Populates this <code>CachedRowSetImpl</code> object with data from
 608      * the given <code>ResultSet</code> object.  This
 609      * method is an alternative to the method <code>execute</code>
 610      * for filling the rowset with data.  The method <code>populate</code>
 611      * does not require that the properties needed by the method
 612      * <code>execute</code>, such as the <code>command</code> property,
 613      * be set. This is true because the method <code>populate</code>
 614      * is given the <code>ResultSet</code> object from
 615      * which to get data and thus does not need to use the properties
 616      * required for setting up a connection and executing this


7052     }
7053 
7054     /**
7055      * Sets the designated parameter to the given String array.
7056      *  This forms the basis of the join for the
7057      * <code>JoinRowSet</code> as the column which will form the basis of the
7058      * join.
7059      * <P>
7060      * The parameter value set by this method is stored internally and
7061      * will be supplied as the appropriate parameter in this rowset's
7062      * command when the method <code>getMatchColumn</code> is called.
7063      *
7064      * @param columnNames the name of the column into this rowset
7065      *        object's internal representation of parameter values
7066      * @throws SQLException if an error occurs or the
7067      *  parameter index is out of bounds
7068      */
7069     public void setMatchColumn(String[] columnNames) throws SQLException {
7070 
7071         for(int j = 0; j < columnNames.length; j++) {
7072            if( columnNames[j] == null || columnNames[j].equals("")) {
7073               throw new SQLException(resBundle.handleGetObject("cachedrowsetimpl.matchcols2").toString());
7074            }
7075         }
7076         for( int i = 0; i < columnNames.length; i++) {
7077            strMatchColumns.add(i,columnNames[i]);
7078         }
7079     }
7080 
7081 
7082     /**
7083      * Sets the designated parameter to the given <code>int</code>
7084      * object.  This forms the basis of the join for the
7085      * <code>JoinRowSet</code> as the column which will form the basis of the
7086      * join.
7087      * <P>
7088      * The parameter value set by this method is stored internally and
7089      * will be supplied as the appropriate parameter in this rowset's
7090      * command when the method <code>getMatchColumn</code> is called.
7091      *
7092      * @param columnIdx the index into this rowset


7107         }
7108     }
7109 
7110     /**
7111      * Sets the designated parameter to the given <code>String</code>
7112      * object.  This forms the basis of the join for the
7113      * <code>JoinRowSet</code> as the column which will form the basis of the
7114      * join.
7115      * <P>
7116      * The parameter value set by this method is stored internally and
7117      * will be supplied as the appropriate parameter in this rowset's
7118      * command when the method <code>getMatchColumn</code> is called.
7119      *
7120      * @param columnName the name of the column into this rowset
7121      *        object's internal representation of parameter values
7122      * @throws SQLException if an error occurs or the
7123      *  parameter index is out of bounds
7124      */
7125     public void setMatchColumn(String columnName) throws SQLException {
7126         // validate, if col is ok to be set
7127         if(columnName == null || (columnName= columnName.trim()).equals("") ) {
7128             throw new SQLException(resBundle.handleGetObject("cachedrowsetimpl.matchcols2").toString());
7129         } else {
7130             // set strMatchColumn
7131             strMatchColumns.set(0, columnName);
7132             //iMatchColumn = -1;
7133         }
7134     }
7135 
7136     /**
7137      * Unsets the designated parameter to the given <code>int</code>
7138      * object.  This was set using <code>setMatchColumn</code>
7139      * as the column which will form the basis of the join.
7140      * <P>
7141      * The parameter value unset by this method should be same
7142      * as was set.
7143      *
7144      * @param columnIdx the index into this rowset
7145      *        object's internal representation of parameter values
7146      * @throws SQLException if an error occurs or the
7147      *  parameter index is out of bounds or if the columnIdx is




 576     //-----------------------------------------------------------------------
 577 
 578     /**
 579      * Sets this <code>CachedRowSetImpl</code> object's command property
 580      * to the given <code>String</code> object and clears the parameters,
 581      * if any, that were set for the previous command.
 582      * <P>
 583      * The command property may not be needed
 584      * if the rowset is produced by a data source, such as a spreadsheet,
 585      * that does not support commands. Thus, this property is optional
 586      * and may be <code>null</code>.
 587      *
 588      * @param cmd a <code>String</code> object containing an SQL query
 589      *            that will be set as the command; may be <code>null</code>
 590      * @throws SQLException if an error occurs
 591      */
 592     public void setCommand(String cmd) throws SQLException {
 593 
 594         super.setCommand(cmd);
 595 
 596         if(!buildTableName(cmd).isEmpty()) {
 597             this.setTableName(buildTableName(cmd));
 598         }
 599     }
 600 
 601 
 602     //---------------------------------------------------------------------
 603     // Reading and writing data
 604     //---------------------------------------------------------------------
 605 
 606     /**
 607      * Populates this <code>CachedRowSetImpl</code> object with data from
 608      * the given <code>ResultSet</code> object.  This
 609      * method is an alternative to the method <code>execute</code>
 610      * for filling the rowset with data.  The method <code>populate</code>
 611      * does not require that the properties needed by the method
 612      * <code>execute</code>, such as the <code>command</code> property,
 613      * be set. This is true because the method <code>populate</code>
 614      * is given the <code>ResultSet</code> object from
 615      * which to get data and thus does not need to use the properties
 616      * required for setting up a connection and executing this


7052     }
7053 
7054     /**
7055      * Sets the designated parameter to the given String array.
7056      *  This forms the basis of the join for the
7057      * <code>JoinRowSet</code> as the column which will form the basis of the
7058      * join.
7059      * <P>
7060      * The parameter value set by this method is stored internally and
7061      * will be supplied as the appropriate parameter in this rowset's
7062      * command when the method <code>getMatchColumn</code> is called.
7063      *
7064      * @param columnNames the name of the column into this rowset
7065      *        object's internal representation of parameter values
7066      * @throws SQLException if an error occurs or the
7067      *  parameter index is out of bounds
7068      */
7069     public void setMatchColumn(String[] columnNames) throws SQLException {
7070 
7071         for(int j = 0; j < columnNames.length; j++) {
7072            if( columnNames[j] == null || columnNames[j].isEmpty()) {
7073               throw new SQLException(resBundle.handleGetObject("cachedrowsetimpl.matchcols2").toString());
7074            }
7075         }
7076         for( int i = 0; i < columnNames.length; i++) {
7077            strMatchColumns.add(i,columnNames[i]);
7078         }
7079     }
7080 
7081 
7082     /**
7083      * Sets the designated parameter to the given <code>int</code>
7084      * object.  This forms the basis of the join for the
7085      * <code>JoinRowSet</code> as the column which will form the basis of the
7086      * join.
7087      * <P>
7088      * The parameter value set by this method is stored internally and
7089      * will be supplied as the appropriate parameter in this rowset's
7090      * command when the method <code>getMatchColumn</code> is called.
7091      *
7092      * @param columnIdx the index into this rowset


7107         }
7108     }
7109 
7110     /**
7111      * Sets the designated parameter to the given <code>String</code>
7112      * object.  This forms the basis of the join for the
7113      * <code>JoinRowSet</code> as the column which will form the basis of the
7114      * join.
7115      * <P>
7116      * The parameter value set by this method is stored internally and
7117      * will be supplied as the appropriate parameter in this rowset's
7118      * command when the method <code>getMatchColumn</code> is called.
7119      *
7120      * @param columnName the name of the column into this rowset
7121      *        object's internal representation of parameter values
7122      * @throws SQLException if an error occurs or the
7123      *  parameter index is out of bounds
7124      */
7125     public void setMatchColumn(String columnName) throws SQLException {
7126         // validate, if col is ok to be set
7127         if(columnName == null || (columnName= columnName.trim()).isEmpty() ) {
7128             throw new SQLException(resBundle.handleGetObject("cachedrowsetimpl.matchcols2").toString());
7129         } else {
7130             // set strMatchColumn
7131             strMatchColumns.set(0, columnName);
7132             //iMatchColumn = -1;
7133         }
7134     }
7135 
7136     /**
7137      * Unsets the designated parameter to the given <code>int</code>
7138      * object.  This was set using <code>setMatchColumn</code>
7139      * as the column which will form the basis of the join.
7140      * <P>
7141      * The parameter value unset by this method should be same
7142      * as was set.
7143      *
7144      * @param columnIdx the index into this rowset
7145      *        object's internal representation of parameter values
7146      * @throws SQLException if an error occurs or the
7147      *  parameter index is out of bounds or if the columnIdx is


< prev index next >