01: /*
02: * Copyright Aduna (http://www.aduna-software.com/) (c) 2008.
03: *
04: * Licensed under the Aduna BSD-style license.
05: */
06: package org.openrdf.sail.rdbms.iteration;
07:
08: import java.sql.PreparedStatement;
09: import java.sql.ResultSet;
10: import java.sql.SQLException;
11:
12: import org.openrdf.sail.SailException;
13: import org.openrdf.sail.rdbms.RdbmsValueFactory;
14: import org.openrdf.sail.rdbms.exceptions.RdbmsException;
15: import org.openrdf.sail.rdbms.iteration.base.RdbmIterationBase;
16: import org.openrdf.sail.rdbms.model.RdbmsResource;
17:
18: /**
19: * Converts a {@link ResultSet} into a {@link RdbmsResource} in an iteration.
20: *
21: * @author James Leigh
22: *
23: */
24: public class RdbmsResourceIteration extends
25: RdbmIterationBase<RdbmsResource, SailException> {
26: private RdbmsValueFactory vf;
27:
28: public RdbmsResourceIteration(RdbmsValueFactory vf,
29: PreparedStatement stmt) throws SQLException {
30: super (stmt);
31: this .vf = vf;
32: }
33:
34: @Override
35: protected RdbmsResource convert(ResultSet rs) throws SQLException {
36: Number id = rs.getLong(0 + 1);
37: return vf.getRdbmsResource(id, rs.getString(0 + 2));
38: }
39:
40: @Override
41: protected RdbmsException convertSQLException(SQLException e) {
42: return new RdbmsException(e);
43: }
44:
45: }
|