01: /*
02: * Copyright 2004 (C) TJDO.
03: * All rights reserved.
04: *
05: * This software is distributed under the terms of the TJDO License version 1.0.
06: * See the terms of the TJDO License in the documentation provided with this software.
07: *
08: * $Id: TransientIDROF.java,v 1.3 2004/01/18 03:01:06 jackknifebarber Exp $
09: */
10:
11: package com.triactive.jdo.store;
12:
13: import com.triactive.jdo.FieldManager;
14: import com.triactive.jdo.PersistenceManager;
15: import java.sql.ResultSet;
16:
17: public class TransientIDROF implements Query.ResultObjectFactory {
18: private final PersistenceManager pm;
19: private final Class candidateClass;
20: private final int[] fieldNumbers;
21: private final ColumnMapping[] fieldMappings;
22: private final int[] columnNumbersByField;
23: private final StoreManager storeMgr;
24:
25: public TransientIDROF(PersistenceManager pm, Class candidateClass,
26: int[] fieldNumbers, ColumnMapping[] fieldMappings,
27: int[] columnNumbersByField) {
28: this .pm = pm;
29: this .candidateClass = candidateClass;
30: this .fieldNumbers = fieldNumbers;
31: this .fieldMappings = fieldMappings;
32: this .columnNumbersByField = columnNumbersByField;
33:
34: storeMgr = pm.getStoreManager();
35: }
36:
37: public Object getObject(ResultSet rs) {
38: Object id = storeMgr.newObjectID(candidateClass);
39:
40: if (fieldNumbers != null) {
41: FieldManager fm = new ResultSetGetter(pm, rs,
42: fieldMappings, columnNumbersByField);
43:
44: return pm.getObjectById(id, candidateClass, fieldNumbers,
45: fm);
46: } else
47: return pm.getObjectById(id, candidateClass, false);
48: }
49: }
|