| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| SqlBasedReportQueryRsIterator |
|
| 3.5;3.5 |
| 1 | package org.apache.ojb.broker.accesslayer; | |
| 2 | ||
| 3 | /* Copyright 2002-2005 The Apache Software Foundation | |
| 4 | * | |
| 5 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
| 6 | * you may not use this file except in compliance with the License. | |
| 7 | * You may obtain a copy of the License at | |
| 8 | * | |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 | |
| 10 | * | |
| 11 | * Unless required by applicable law or agreed to in writing, software | |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, | |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 14 | * See the License for the specific language governing permissions and | |
| 15 | * limitations under the License. | |
| 16 | */ | |
| 17 | ||
| 18 | import java.sql.ResultSetMetaData; | |
| 19 | import java.sql.SQLException; | |
| 20 | ||
| 21 | import org.apache.ojb.broker.PersistenceBrokerException; | |
| 22 | import org.apache.ojb.broker.core.PersistenceBrokerImpl; | |
| 23 | import org.apache.ojb.broker.metadata.JdbcTypesHelper; | |
| 24 | ||
| 25 | /** | |
| 26 | * ReporQueryRsIterator based on SQL-Statement | |
| 27 | * | |
| 28 | * @author <a href="mailto:jbraeuchi@hotmail.com">Jakob Braeuchi</a> | |
| 29 | * @version $Id: SqlBasedReportQueryRsIterator.java,v 1.1 2007-08-24 22:17:30 ewestfal Exp $ | |
| 30 | */ | |
| 31 | public class SqlBasedReportQueryRsIterator extends SqlBasedRsIterator | |
| 32 | { | |
| 33 | private ResultSetMetaData rsMetaData; | |
| 34 | private int columnCount; | |
| 35 | ||
| 36 | /** | |
| 37 | * SqlBasedRsIterator constructor. | |
| 38 | */ | |
| 39 | public SqlBasedReportQueryRsIterator(RsQueryObject queryObject, PersistenceBrokerImpl broker) | |
| 40 | throws PersistenceBrokerException | |
| 41 | { | |
| 42 | ||
| 43 | super(queryObject, broker); | |
| 44 | try | |
| 45 | { | |
| 46 | rsMetaData = getRsAndStmt().m_rs.getMetaData(); | |
| 47 | columnCount = rsMetaData.getColumnCount(); | |
| 48 | } | |
| 49 | catch (SQLException e) | |
| 50 | { | |
| 51 | throw new PersistenceBrokerException(e); | |
| 52 | } | |
| 53 | } | |
| 54 | ||
| 55 | /** | |
| 56 | * returns an Object[] representing the columns of the current ResultSet row. | |
| 57 | * There is no OJB object materialization, Proxy generation etc. involved | |
| 58 | * to maximize performance. | |
| 59 | */ | |
| 60 | protected Object getObjectFromResultSet() throws PersistenceBrokerException | |
| 61 | { | |
| 62 | Object[] result = new Object[columnCount]; | |
| 63 | for (int i = 0; i < columnCount; i++) | |
| 64 | { | |
| 65 | try | |
| 66 | { | |
| 67 | int jdbcType = rsMetaData.getColumnType(i + 1); | |
| 68 | Object item = JdbcTypesHelper.getObjectFromColumn(getRsAndStmt().m_rs, new Integer(jdbcType), i + 1); | |
| 69 | result[i] = item; | |
| 70 | } | |
| 71 | catch (SQLException e) | |
| 72 | { | |
| 73 | throw new PersistenceBrokerException(e); | |
| 74 | } | |
| 75 | } | |
| 76 | return result; | |
| 77 | } | |
| 78 | ||
| 79 | } |