1 8 9 package com.sleepycat.persist; 10 11 import com.sleepycat.bind.EntryBinding; 12 import com.sleepycat.je.DatabaseEntry; 13 14 20 class DataValueAdapter<V> implements ValueAdapter<V> { 21 22 private EntryBinding dataBinding; 23 24 DataValueAdapter(Class <V> keyClass, EntryBinding dataBinding) { 25 this.dataBinding = dataBinding; 26 } 27 28 public DatabaseEntry initKey() { 29 return new DatabaseEntry(); 30 } 31 32 public DatabaseEntry initPKey() { 33 return null; 34 } 35 36 public DatabaseEntry initData() { 37 return new DatabaseEntry(); 38 } 39 40 public void clearEntries(DatabaseEntry key, 41 DatabaseEntry pkey, 42 DatabaseEntry data) { 43 key.setData(null); 44 data.setData(null); 45 } 46 47 public V entryToValue(DatabaseEntry key, 48 DatabaseEntry pkey, 49 DatabaseEntry data) { 50 return (V) dataBinding.entryToObject(data); 51 } 52 53 public void valueToData(V value, DatabaseEntry data) { 54 throw new UnsupportedOperationException 55 ("Cannot change the data in a key-only index"); 56 } 57 } 58 | Popular Tags |