Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/**
* Copyright 2010 Tim Azzopardi
*
* 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 net.sf.log4jdbc.sql.resultsetcollector;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.sf.log4jdbc.sql.jdbcapi.ResultSetSpy;
public class DefaultResultSetCollector implements ResultSetCollector {
private static final String NULL_RESULT_SET_VAL = "[null]";
private static final String UNREAD = "[unread]";
private static final String UNREAD_ERROR = "[unread!]";
private boolean fillInUnreadValues = false;
public DefaultResultSetCollector(boolean fillInUnreadValues) {
this.reset();
this.fillInUnreadValues = fillInUnreadValues;
this.lastValueReturnedByNext = true;
}
/**
* A {@code boolean} defining whether parameters of this {@code DefaultResultSetColector}
* has already been obtained from a {@code ResultSetMetaData}.
*/
private boolean loaded;
/**
* An int representing the number of columns
* in the real ResultSet object, obtained by calling
* getColumnCount on the related ResultSetMetaData object.
* This attribute is an Integer rather than an int,
* so that we can distinguish the case where the column count has not yet been obtained,
* from the case when the column count is 0 (should never happend, but still...)
*/
private int columnCount;
/**
* A Map where the key is an Integer representing
* the index of a column, and the corresponding value is a String
* being the label of the column.
* This Map is populated by calling getColumnLabel
* on the ResultSetMetaData object of the real ResultSet object,
* for each column (see {@link #columnCount}).
*/
private Map columnLabels;
/**
* A Map where the key is an Integer representing
* the index of a column, and the corresponding value is a String
* being the name of the column.
* This Map is populated by calling getColumnLabel
* on the ResultSetMetaData object of the real ResultSet object,
* for each column (see {@link #columnCount}).
*/
private Map columnNames;
/**
* A boolean that is the last value returned by a call
* to next (or first) on the related ResultSet.
* This allows to know if this ResultSetCollector must be printed
* when close is called on the related ResultSet:
* if the previous call to next returned true,
* then this ResultSetCollector must be printed
* on the call to close; otherwise, it was already printed following
* the previous call to next, and should not be printed
* on the call to close.
*
* This attribute must not be reset after a printing (the other attributes are, through a call
* to reset), in case the related ResultSet is reused.
*
* Default value at initialization is true (ResultSetCollector
* not printed).
*/
private boolean lastValueReturnedByNext;
private List