Package com.sleepycat.bdb.bind

Examples of com.sleepycat.bdb.bind.EntityBinding


    public void testSerialSerialBinding()
        throws IOException {

        SerialFormat keyFormat = new SerialFormat(catalog, String.class);
        SerialFormat valueFormat = new SerialFormat(catalog, String.class);
        EntityBinding binding = new MySerialSerialBinding(keyFormat,
                                                          valueFormat);
        assertSame(keyFormat, binding.getKeyFormat());
        assertSame(valueFormat, binding.getValueFormat());

        String val = "key#value?indexKey";
        binding.objectToValue(val, buffer);
        assertTrue(buffer.getDataLength() > 0);
        binding.objectToKey(val, keyBuffer);
        assertTrue(keyBuffer.getDataLength() > 0);

        Object result = binding.dataToObject(keyBuffer, buffer);
        assertEquals(val, result);
    }
View Full Code Here


        throws IOException {

        SerialFormat keyFormat = new SerialFormat(catalog, String.class);
        SerialFormat valueFormat = new SerialFormat(catalog, String.class);
        SerialFormat indexKeyFormat = new SerialFormat(catalog, String.class);
        EntityBinding binding = new MySerialSerialBinding(keyFormat,
                                                          valueFormat);
        KeyExtractor extractor = new MySerialSerialExtractor(keyFormat,
                                                             valueFormat,
                                                             indexKeyFormat);
        assertSame(keyFormat, extractor.getPrimaryKeyFormat());
        assertSame(valueFormat, extractor.getValueFormat());
        assertSame(indexKeyFormat, extractor.getIndexKeyFormat());

        String val = "key#value?indexKey";
        binding.objectToValue(val, buffer);
        binding.objectToKey(val, keyBuffer);

        extractor.extractIndexKey(keyBuffer, buffer, indexKeyBuffer);
        assertEquals("indexKey", indexKeyFormat.dataToObject(indexKeyBuffer));

        extractor.clearIndexKey(buffer);
View Full Code Here

        TupleFormat keyFormat = new TupleFormat();
        SerialFormat valueFormat = new SerialFormat(catalog,
                                                    MarshalledObject.class);
        TupleFormat indexKeyFormat = new TupleFormat();

        EntityBinding binding =
            new TupleSerialMarshalledBinding(keyFormat, valueFormat);
        assertSame(valueFormat, binding.getValueFormat());
        assertSame(keyFormat, binding.getKeyFormat());

        MarshalledObject val = new MarshalledObject("abc", "primary",
                                                    "index1", "index2");
        binding.objectToValue(val, buffer);
        assertTrue(buffer.getDataLength() > 0);
        binding.objectToKey(val, keyBuffer);
        assertEquals(val.expectedKeyLength(), keyBuffer.getDataLength());

        Object result = binding.dataToObject(keyBuffer, buffer);
        assertTrue(result instanceof MarshalledObject);
        val = (MarshalledObject) result;
        assertEquals("abc", val.getData());
        assertEquals("primary", val.getPrimaryKey());
        assertEquals("index1", val.getIndexKey1());
View Full Code Here

    // also tests TupleTupleBinding since TupleTupleMarshalledBinding extends
    // it
    public void testTupleTupleMarshalledBinding()
        throws IOException {

        EntityBinding binding =
            new TupleTupleMarshalledBinding(keyFormat, format,
                                            MarshalledObject.class);
        assertSame(format, binding.getValueFormat());
        assertSame(keyFormat, binding.getKeyFormat());

        MarshalledObject val = new MarshalledObject("abc", "primary",
                                                    "index1", "index2");
        binding.objectToValue(val, buffer);
        assertEquals(val.expectedDataLength(), buffer.getDataLength());
        binding.objectToKey(val, keyBuffer);
        assertEquals(val.expectedKeyLength(), keyBuffer.getDataLength());

        Object result = binding.dataToObject(keyBuffer, buffer);
        assertTrue(result instanceof MarshalledObject);
        val = (MarshalledObject) result;
        assertEquals("abc", val.getData());
        assertEquals("primary", val.getPrimaryKey());
        assertEquals("index1", val.getIndexKey1());
View Full Code Here

        // details.  For keys, a one-to-one binding is implemented with
        // DataBinding classes to bind the stored tuple data to a key Object.
        //
        DataBinding partKeyBinding =
            new PartKeyBinding(db.getPartKeyFormat());
        EntityBinding partValueBinding =
            new PartBinding(db.getPartKeyFormat(), db.getPartValueFormat());
        DataBinding supplierKeyBinding =
            new SupplierKeyBinding(db.getSupplierKeyFormat());
        EntityBinding supplierValueBinding =
            new SupplierBinding(db.getSupplierKeyFormat(),
                                db.getSupplierValueFormat());
        DataBinding shipmentKeyBinding =
            new ShipmentKeyBinding(db.getShipmentKeyFormat());
        EntityBinding shipmentValueBinding =
            new ShipmentBinding(db.getShipmentKeyFormat(),
                                db.getShipmentValueFormat());
        DataBinding cityKeyBinding =
            TupleBinding.getPrimitiveBinding(String.class,
                                             db.getCityKeyFormat());
View Full Code Here

        // 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());
View Full Code Here

        // one-to-one binding is implemented with DataBinding classes to bind
        // the stored tuple data to a key Object.
        //
        DataBinding partKeyBinding =
            new PartKeyBinding(db.getPartKeyFormat());
        EntityBinding partValueBinding =
            new PartBinding(db.getPartKeyFormat(), db.getPartValueFormat());
        DataBinding supplierKeyBinding =
            new SupplierKeyBinding(db.getSupplierKeyFormat());
        EntityBinding supplierValueBinding =
            new SupplierBinding(db.getSupplierKeyFormat(),
                                db.getSupplierValueFormat());
        DataBinding shipmentKeyBinding =
            new ShipmentKeyBinding(db.getShipmentKeyFormat());
        EntityBinding shipmentValueBinding =
            new ShipmentBinding(db.getShipmentKeyFormat(),
                                db.getShipmentValueFormat());
        DataBinding cityKeyBinding =
            TupleBinding.getPrimitiveBinding(String.class,
                                             db.getCityKeyFormat());
View Full Code Here

        // details.  For keys, a one-to-one binding is implemented with
        // DataBinding classes to bind the stored tuple data to a key Object.
        //
        DataBinding partKeyBinding =
            new MarshalledKeyBinding(db.getPartKeyFormat(), PartKey.class);
        EntityBinding partValueBinding =
            new MarshalledEntityBinding(db.getPartKeyFormat(),
                                        db.getPartValueFormat(),
                                        Part.class);
        DataBinding supplierKeyBinding =
            new MarshalledKeyBinding(db.getSupplierKeyFormat(),
                                     SupplierKey.class);
        EntityBinding supplierValueBinding =
            new MarshalledEntityBinding(db.getSupplierKeyFormat(),
                                        db.getSupplierValueFormat(),
                                        Supplier.class);
        DataBinding shipmentKeyBinding =
            new MarshalledKeyBinding(db.getShipmentKeyFormat(),
                                     ShipmentKey.class);
        EntityBinding shipmentValueBinding =
            new MarshalledEntityBinding(db.getShipmentKeyFormat(),
                                        db.getShipmentValueFormat(),
                                        Shipment.class);
        DataBinding cityKeyBinding =
            TupleBinding.getPrimitiveBinding(String.class,
View Full Code Here

TOP

Related Classes of com.sleepycat.bdb.bind.EntityBinding

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.