| 1 |
/*- |
| 2 |
* See the file LICENSE for redistribution information. |
| 3 |
* |
| 4 |
* Copyright (c) 2002, 2013 Oracle and/or its affiliates. All rights reserved. |
| 5 |
* |
| 6 |
*/ |
| 7 |
|
| 8 |
package com.sleepycat.persist.impl; |
| 9 |
|
| 10 |
import com.sleepycat.persist.raw.RawObject; |
| 11 |
import java.util.IdentityHashMap; |
| 12 |
|
| 13 |
/** |
| 14 |
* Extends RawAbstractInput to convert complex (ComplexFormat and |
| 15 |
* CompositeKeyFormat) RawObject instances. |
| 16 |
* |
| 17 |
* @author Mark Hayes |
| 18 |
*/ |
| 19 |
class RawComplexInput extends RawAbstractInput { |
| 20 |
|
| 21 |
private FieldInfo[] fields; |
| 22 |
private RawObject[] objects; |
| 23 |
private int index; |
| 24 |
|
| 25 |
RawComplexInput(Catalog catalog, |
| 26 |
boolean rawAccess, |
| 27 |
IdentityHashMap converted, |
| 28 |
FieldInfo[] fields, |
| 29 |
RawObject[] objects) { |
| 30 |
super(catalog, rawAccess, converted); |
| 31 |
this.fields = fields; |
| 32 |
this.objects = objects; |
| 33 |
} |
| 34 |
|
| 35 |
@Override |
| 36 |
Object readNext() |
| 37 |
throws RefreshException { |
| 38 |
|
| 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 |
} |