1 package org.apache.torque.om.mapper; 2 3 /* 4 * Licensed to the Apache Software Foundation (ASF) under one 5 * or more contributor license agreements. See the NOTICE file 6 * distributed with this work for additional information 7 * regarding copyright ownership. The ASF licenses this file 8 * to you under the Apache License, Version 2.0 (the 9 * "License"); you may not use this file except in compliance 10 * with the License. You may obtain a copy of the License at 11 * 12 * http://www.apache.org/licenses/LICENSE-2.0 13 * 14 * Unless required by applicable law or agreed to in writing, 15 * software distributed under the License is distributed on an 16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 * KIND, either express or implied. See the License for the 18 * specific language governing permissions and limitations 19 * under the License. 20 */ 21 22 import java.io.Serializable; 23 import java.sql.ResultSet; 24 25 import org.apache.torque.TorqueException; 26 27 /** 28 * Maps an object to a database record and back. 29 * This means that the object can be read from a database resultSet 30 * and that it can produce PreparedStatements which insert or update 31 * the record in the the database. 32 * 33 * @param <T> the class to map from and to a database record 34 * 35 * @version $Id: RecordMapper.java 1388656 2012-09-21 19:59:16Z tfischer $ 36 */ 37 public interface RecordMapper<T> extends Serializable 38 { 39 /** 40 * Constructs the object from the current row in the resultSet. 41 * Implementing methods can be sure that the resultSet contains a row, 42 * but they must only operate on the current row, i.e they must not call 43 * resultSet.next(). 44 * 45 * @param resultSet the resultSet to operate on, already pointing 46 * to the correct row. Not null. 47 * @param rowOffset a possible offset in the rows to be considered 48 * (if previous rows contain other objects). 49 * 50 * @return the mapped object, not null. 51 * 52 * @throws TorqueException when the mapping fails. 53 */ 54 T processRow(ResultSet resultSet, int rowOffset) throws TorqueException; 55 }