1/*-
2 * See the file LICENSE for redistribution information.
3 *
4 * Copyright (c) 2000,2008 Oracle.  All rights reserved.
5 *
6 * $Id: EntityBinding.java,v 12.7 2008/02/08 20:12:36 mark Exp $
7 */
8
9package com.sleepycat.bind;
10
11import com.sleepycat.db.DatabaseEntry;
12
13/**
14 * A binding between a key-value entry pair and an entity object.
15 *
16 * <p><em>WARNING:</em> Binding instances are typically shared by multiple
17 * threads and binding methods are called without any special synchronization.
18 * Therefore, bindings must be thread safe.  In general no shared state should
19 * be used and any caching of computed values must be done with proper
20 * synchronization.</p>
21 *
22 * @author Mark Hayes
23 */
24public interface EntityBinding {
25
26    /**
27     * Converts key and data entry buffers into an entity Object.
28     *
29     * @param key is the source key entry.
30     *
31     * @param data is the source data entry.
32     *
33     * @return the resulting Object.
34     */
35    Object entryToObject(DatabaseEntry key, DatabaseEntry data);
36
37    /**
38     * Extracts the key entry from an entity Object.
39     *
40     * @param object is the source Object.
41     *
42     * @param key is the destination entry buffer.
43     */
44    void objectToKey(Object object, DatabaseEntry key);
45
46    /**
47     * Extracts the data entry from an entity Object.
48     *
49     * @param object is the source Object.
50     *
51     * @param data is the destination entry buffer.
52     */
53    void objectToData(Object object, DatabaseEntry data);
54}
55