01: /*-
02: * See the file LICENSE for redistribution information.
03: *
04: * Copyright (c) 2002,2008 Oracle. All rights reserved.
05: *
06: * $Id: RawArrayInput.java,v 1.4.2.2 2008/01/07 15:14:20 cwl Exp $
07: */
08:
09: package com.sleepycat.persist.impl;
10:
11: import java.util.IdentityHashMap;
12:
13: import com.sleepycat.persist.raw.RawObject;
14:
15: /**
16: * Extends RawAbstractInput to convert array (ObjectArrayFormat and
17: * PrimitiveArrayteKeyFormat) RawObject instances.
18: *
19: * @author Mark Hayes
20: */
21: class RawArrayInput extends RawAbstractInput {
22:
23: private Object[] array;
24: private int index;
25: private Format componentFormat;
26:
27: RawArrayInput(Catalog catalog, boolean rawAccess,
28: IdentityHashMap converted, RawObject raw,
29: Format componentFormat) {
30: super (catalog, rawAccess, converted);
31: array = raw.getElements();
32: this .componentFormat = componentFormat;
33: }
34:
35: @Override
36: public int readArrayLength() {
37: return array.length;
38: }
39:
40: @Override
41: Object readNext() {
42: Object o = array[index++];
43: return checkAndConvert(o, componentFormat);
44: }
45: }
|