Package com.sleepycat.bdb.bind.serial

Examples of com.sleepycat.bdb.bind.serial.SerialBinding


        SerialFormat valueFormat = new SerialFormat(catalog,
                                                    TestSerial.class);
        store = new DataStore(openDb(STORE_FILE),
                              keyFormat, valueFormat, null);

        SerialBinding keyBinding = new SerialBinding(keyFormat);
        SerialBinding valueBinding = new SerialBinding(valueFormat);
        map = new StoredMap(store, keyBinding, valueBinding, true);
    }
View Full Code Here


    private void primitiveBindingTest(Object val)
        throws IOException {

        Class cls = val.getClass();
        SerialFormat format = new SerialFormat(catalog, cls);
        DataBinding binding = new SerialBinding(format);
        assertSame(format, binding.getDataFormat());

        binding.objectToData(val, buffer);
        assertTrue(buffer.getDataLength() > 0);

        Object val2 = binding.dataToObject(buffer);
        assertSame(cls, val2.getClass());
        assertEquals(val, val2);

        Object valWithWrongCls = (cls == String.class)
                      ? ((Object) new Integer(0)) : ((Object) new String(""));
        try {
            binding.objectToData(valWithWrongCls, buffer);
        } catch (IllegalArgumentException expected) {}
    }
View Full Code Here

        // key/value data pair to a combined value object.  For keys, however,
        // the stored data is used directly via a SerialBinding and no
        // special binding class is needed.
        //
        DataBinding partKeyBinding =
            new SerialBinding(db.getPartKeyFormat());
        EntityBinding partValueBinding =
            new PartBinding(db.getPartKeyFormat(), db.getPartValueFormat());
        DataBinding supplierKeyBinding =
            new SerialBinding(db.getSupplierKeyFormat());
        EntityBinding supplierValueBinding =
            new SupplierBinding(db.getSupplierKeyFormat(),
                                db.getSupplierValueFormat());
        DataBinding shipmentKeyBinding =
            new SerialBinding(db.getShipmentKeyFormat());
        EntityBinding shipmentValueBinding =
            new ShipmentBinding(db.getShipmentKeyFormat(),
                                db.getShipmentValueFormat());
        DataBinding cityKeyBinding =
            new SerialBinding(db.getCityKeyFormat());

        // Create map views for all stores and indices.
        // StoredSortedMap is not used since the stores and indices are
        // ordered by serialized key objects, which do not provide a very
        // useful ordering.
View Full Code Here

            TupleBinding.getPrimitiveBinding(Integer.class, keyFormat);

        // use String serial format and binding for values
        SerialFormat valueFormat =
            new SerialFormat(catalog, String.class);
        SerialBinding valueBinding = new SerialBinding(valueFormat);

        // open a BTREE (sorted) data store
        Db db = new Db(env, 0);
        db.open(null, "data.db", null, Db.DB_BTREE, dbFlags, 0);
        this.store = new DataStore(db, keyFormat, valueFormat, null);
View Full Code Here

        // In this sample, the stored keys and values are used directly rather
        // than mapping them to separate objects. Therefore, no binding classes
        // are defined here and the SerialBinding class is used.
        //
        DataBinding partKeyBinding =
            new SerialBinding(db.getPartKeyFormat());
        DataBinding partValueBinding =
            new SerialBinding(db.getPartValueFormat());
        DataBinding supplierKeyBinding =
            new SerialBinding(db.getSupplierKeyFormat());
        DataBinding supplierValueBinding =
            new SerialBinding(db.getSupplierValueFormat());
        DataBinding shipmentKeyBinding =
            new SerialBinding(db.getShipmentKeyFormat());
        DataBinding shipmentValueBinding =
            new SerialBinding(db.getShipmentValueFormat());

        // Create map views for all stores and indices.
        // StoredSortedMap is not used since the stores and indices are
        // ordered by serialized key objects, which do not provide a very
        // useful ordering.
View Full Code Here

        // In this sample, the stored keys and values are used directly rather
        // than mapping them to separate objects. Therefore, no binding classes
        // are defined here and the SerialBinding class is used.
        //
        DataBinding partKeyBinding =
            new SerialBinding(db.getPartKeyFormat());
        DataBinding partValueBinding =
            new SerialBinding(db.getPartValueFormat());
        DataBinding supplierKeyBinding =
            new SerialBinding(db.getSupplierKeyFormat());
        DataBinding supplierValueBinding =
            new SerialBinding(db.getSupplierValueFormat());
        DataBinding shipmentKeyBinding =
            new SerialBinding(db.getShipmentKeyFormat());
        DataBinding shipmentValueBinding =
            new SerialBinding(db.getShipmentValueFormat());
        DataBinding cityKeyBinding =
            new SerialBinding(db.getCityKeyFormat());

        // Create map views for all stores and indices.
        // StoredSortedMap is not used since the stores and indices are
        // ordered by serialized key objects, which do not provide a very
        // useful ordering.
View Full Code Here

TOP

Related Classes of com.sleepycat.bdb.bind.serial.SerialBinding

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.