⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 itemnamekeycreator.java

📁 嵌入式数据库Berkeley DB-4.5.20源代码
💻 JAVA
字号:
// File: ItemNameKeyCreator.javapackage db.GettingStarted;import com.sleepycat.bind.tuple.TupleBinding;import com.sleepycat.db.SecondaryKeyCreator;import com.sleepycat.db.DatabaseEntry;import com.sleepycat.db.DatabaseException;import com.sleepycat.db.SecondaryDatabase;public class ItemNameKeyCreator implements SecondaryKeyCreator {    private TupleBinding theBinding;    // Use the constructor to set the tuple binding    ItemNameKeyCreator(TupleBinding binding) {        theBinding = binding;    }    // Abstract method that we must implement    public boolean createSecondaryKey(SecondaryDatabase secDb,             DatabaseEntry keyEntry,    // From the primary             DatabaseEntry dataEntry,   // From the primary             DatabaseEntry resultEntry) // set the key data on this.         throws DatabaseException {        if (dataEntry != null) {            // Convert dataEntry to an Inventory object            Inventory inventoryItem =                  (Inventory)theBinding.entryToObject(dataEntry);            // Get the item name and use that as the key            String theItem = inventoryItem.getItemName();            resultEntry.setData(theItem.getBytes());        }        return true;    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -