1 4 package je.gettingStarted; 5 6 import com.sleepycat.bind.tuple.TupleBinding; 7 import com.sleepycat.bind.tuple.TupleInput; 8 import com.sleepycat.bind.tuple.TupleOutput; 9 10 public class InventoryBinding extends TupleBinding { 11 12 public Object entryToObject(TupleInput ti) { 15 16 String sku = ti.readString(); 17 String itemName = ti.readString(); 18 String category = ti.readString(); 19 String vendor = ti.readString(); 20 int vendorInventory = ti.readInt(); 21 float vendorPrice = ti.readFloat(); 22 23 Inventory inventory = new Inventory(); 24 inventory.setSku(sku); 25 inventory.setItemName(itemName); 26 inventory.setCategory(category); 27 inventory.setVendor(vendor); 28 inventory.setVendorInventory(vendorInventory); 29 inventory.setVendorPrice(vendorPrice); 30 31 return inventory; 32 } 33 34 public void objectToEntry(Object object, TupleOutput to) { 37 38 Inventory inventory = (Inventory)object; 39 40 to.writeString(inventory.getSku()); 41 to.writeString(inventory.getItemName()); 42 to.writeString(inventory.getCategory()); 43 to.writeString(inventory.getVendor()); 44 to.writeInt(inventory.getVendorInventory()); 45 to.writeFloat(inventory.getVendorPrice()); 46 } 47 } 48 | Popular Tags |