1 8 9 package com.sleepycat.persist.impl; 10 11 import com.sleepycat.persist.evolve.Converter; 12 import com.sleepycat.persist.raw.RawObject; 13 14 19 public class ConverterReader implements Reader { 20 21 private static final long serialVersionUID = -305788321064984348L; 22 23 private Converter converter; 24 private transient Format oldFormat; 25 26 ConverterReader(Converter converter) { 27 this.converter = converter; 28 } 29 30 public void initializeReader(Catalog catalog, Format oldFormat) { 31 this.oldFormat = oldFormat; 32 } 33 34 public Object newInstance(EntityInput input, boolean rawAccess) { 35 36 return oldFormat.newInstance(input, true); 37 } 38 39 public void readPriKey(Object o, EntityInput input, boolean rawAccess) { 40 41 oldFormat.readPriKey(o, input, true); 42 } 43 44 public Object readObject(Object o, EntityInput input, boolean rawAccess) { 45 Catalog catalog = input.getCatalog(); 46 47 48 o = oldFormat.readObject(o, input, true); 49 o = converter.getConversion().convert(o); 50 51 52 if (!rawAccess && o instanceof RawObject) { 53 o = catalog.convertRawObject((RawObject) o, null); 54 } 55 return o; 56 } 57 } 58 | Popular Tags |