1/*-
2 * See the file LICENSE for redistribution information.
3 *
4 * Copyright (c) 2002,2008 Oracle.  All rights reserved.
5 *
6 * $Id: RawComplexInput.java,v 1.1 2008/02/07 17:12:27 mark Exp $
7 */
8
9package com.sleepycat.persist.impl;
10
11import java.util.IdentityHashMap;
12
13import com.sleepycat.persist.raw.RawObject;
14
15/**
16 * Extends RawAbstractInput to convert complex (ComplexFormat and
17 * CompositeKeyFormat) RawObject instances.
18 *
19 * @author Mark Hayes
20 */
21class RawComplexInput extends RawAbstractInput {
22
23    private FieldInfo[] fields;
24    private RawObject[] objects;
25    private int index;
26
27    RawComplexInput(Catalog catalog,
28                    boolean rawAccess,
29                    IdentityHashMap converted,
30                    FieldInfo[] fields,
31                    RawObject[] objects) {
32        super(catalog, rawAccess, converted);
33        this.fields = fields;
34        this.objects = objects;
35    }
36
37    @Override
38    Object readNext() {
39        RawObject raw = objects[index];
40        FieldInfo field = fields[index];
41        index += 1;
42        Format format = field.getType();
43        Object o = raw.getValues().get(field.getName());
44        return checkAndConvert(o, format);
45    }
46}
47