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