Main Page | Class Hierarchy | Data Structures | Directories | File List | Data Fields | Related Pages

InventoryBinding.java

00001 // File: InventoryBinding.java
00002 
00003 package db.GettingStarted;
00004 
00005 import com.sleepycat.bind.tuple.TupleBinding;
00006 import com.sleepycat.bind.tuple.TupleInput;
00007 import com.sleepycat.bind.tuple.TupleOutput;
00008 
00009 public class InventoryBinding extends TupleBinding {
00010 
00011     // Implement this abstract method. Used to convert
00012     // a DatabaseEntry to an Inventory object.
00013     public Object entryToObject(TupleInput ti) {
00014 
00015         String sku = ti.readString();
00016         String itemName = ti.readString();
00017         String category = ti.readString();
00018         String vendor = ti.readString();
00019         int vendorInventory = ti.readInt();
00020         float vendorPrice = ti.readFloat();
00021 
00022         Inventory inventory = new Inventory();
00023         inventory.setSku(sku);
00024         inventory.setItemName(itemName);
00025         inventory.setCategory(category);
00026         inventory.setVendor(vendor);
00027         inventory.setVendorInventory(vendorInventory);
00028         inventory.setVendorPrice(vendorPrice);
00029 
00030         return inventory;
00031     }
00032 
00033     // Implement this abstract method. Used to convert a
00034     // Inventory object to a DatabaseEntry object.
00035     public void objectToEntry(Object object, TupleOutput to) {
00036 
00037         Inventory inventory = (Inventory)object;
00038 
00039         to.writeString(inventory.getSku());
00040         to.writeString(inventory.getItemName());
00041         to.writeString(inventory.getCategory());
00042         to.writeString(inventory.getVendor());
00043         to.writeInt(inventory.getVendorInventory());
00044         to.writeFloat(inventory.getVendorPrice());
00045     }
00046 }

Generated on Sun Dec 25 12:14:27 2005 for Berkeley DB 4.4.16 by  doxygen 1.4.2