KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > triactive > jdo > store > TransientIDROF


1 /*
2  * Copyright 2004 (C) TJDO.
3  * All rights reserved.
4  *
5  * This software is distributed under the terms of the TJDO License version 1.0.
6  * See the terms of the TJDO License in the documentation provided with this software.
7  *
8  * $Id: TransientIDROF.java,v 1.3 2004/01/18 03:01:06 jackknifebarber Exp $
9  */

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 JavaDoc;
16
17
18 public class TransientIDROF implements Query.ResultObjectFactory
19 {
20     private final PersistenceManager pm;
21     private final Class JavaDoc candidateClass;
22     private final int[] fieldNumbers;
23     private final ColumnMapping[] fieldMappings;
24     private final int[] columnNumbersByField;
25     private final StoreManager storeMgr;
26
27
28     public TransientIDROF(PersistenceManager pm,
29                           Class JavaDoc candidateClass,
30                           int[] fieldNumbers,
31                           ColumnMapping[] fieldMappings,
32                           int[] columnNumbersByField)
33     {
34         this.pm = pm;
35         this.candidateClass = candidateClass;
36         this.fieldNumbers = fieldNumbers;
37         this.fieldMappings = fieldMappings;
38         this.columnNumbersByField = columnNumbersByField;
39
40         storeMgr = pm.getStoreManager();
41     }
42
43
44     public Object JavaDoc getObject(ResultSet JavaDoc rs)
45     {
46         Object JavaDoc id = storeMgr.newObjectID(candidateClass);
47
48         if (fieldNumbers != null)
49         {
50             FieldManager fm = new ResultSetGetter(pm, rs, fieldMappings, columnNumbersByField);
51
52             return pm.getObjectById(id, candidateClass, fieldNumbers, fm);
53         }
54         else
55             return pm.getObjectById(id, candidateClass, false);
56     }
57 }
58
Popular Tags