Examples of SerialBinding


Examples of com.sleepycat.bind.serial.SerialBinding

    DBWriter(Environment env, Database db, StoredClassCatalog scc)

        throws DatabaseException {
        myDb = db;
        myEnv = env;
        dataBinding = new SerialBinding(scc, PayloadData.class);
    }
View Full Code Here

Examples of com.sleepycat.bind.serial.SerialBinding

    }

    private void primitiveBindingTest(Object val) {

        Class cls = val.getClass();
        SerialBinding binding = new SerialBinding(catalog, cls);

        binding.objectToEntry(val, buffer);
        assertTrue(buffer.getSize() > 0);

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

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

Examples of com.sleepycat.bind.serial.SerialBinding

        primitiveBindingTest(new Double(123.123));
    }

    public void testNullObjects() {

        SerialBinding binding = new SerialBinding(catalog, null);
        buffer.setSize(0);
        binding.objectToEntry(null, buffer);
        assertTrue(buffer.getSize() > 0);
        assertEquals(null, binding.entryToObject(buffer));
    }
View Full Code Here

Examples of com.sleepycat.bind.serial.SerialBinding

        assertEquals(null, binding.entryToObject(buffer));
    }

    public void testSerialSerialBinding() {

        SerialBinding keyBinding = new SerialBinding(catalog, String.class);
        SerialBinding valueBinding = new SerialBinding(catalog, String.class);
        EntityBinding binding = new MySerialSerialBinding(keyBinding,
                                                          valueBinding);

        String val = "key#value?indexKey";
        binding.objectToData(val, buffer);
View Full Code Here

Examples of com.sleepycat.bind.serial.SerialBinding

    // also tests TupleSerialBinding since TupleSerialMarshalledBinding extends
    // it
    public void testTupleSerialMarshalledBinding() {

        SerialBinding valueBinding = new SerialBinding(catalog,
                                                    MarshalledObject.class);
        EntityBinding binding =
            new TupleSerialMarshalledBinding(valueBinding);

        MarshalledObject val = new MarshalledObject("abc", "primary",
View Full Code Here

Examples of com.sleepycat.bind.serial.SerialBinding

    public void testClassloaderOverride()
        throws Exception {

        DatabaseEntry entry = new DatabaseEntry();

        SerialBinding binding = new CustomLoaderBinding
            (catalog, null, new FailureClassLoader());

        try {
            binding.objectToEntry(new MyClass(), entry);
            binding.entryToObject(entry);
            fail();
        } catch (RuntimeException e) {
            assertTrue(e.getMessage().startsWith("expect failure"));
        }
    }
View Full Code Here

Examples of com.sleepycat.bind.serial.SerialBinding

         * Create a serial binding for Event data objects.  Serial
         * bindings can be used to store any Serializable object.
         * We can use some pre-defined binding classes to convert
         * primitives like the long key value to the a byte array.
         */
        eventBinding = new SerialBinding(catalog, Event.class);

        /*
         * Open a secondary database to allow accessing the primary
         * database a secondary key value. In this case, access events
         * by price.
View Full Code Here

Examples of com.sleepycat.bind.serial.SerialBinding

    classCatalog = new StoredClassCatalog(catalogDB);

    /*
     * Create the binding
     */
    keyBinding = new SerialBinding(classCatalog, KClass);
    valueBinding = new SerialBinding(classCatalog, VClass);

  }
View Full Code Here

Examples of com.sleepycat.bind.serial.SerialBinding

    classCatalog = new StoredClassCatalog(catalogDB);

    /*
     * Create the binding
     */
    keyBinding = new SerialBinding(classCatalog, KClass);
    valueBinding = new SerialBinding(classCatalog, VClass);
    entryBinding = new SerialBinding(classCatalog, Entry.class);
    pairKeyBinding = new SerialBinding(classCatalog, PairKey.class);

    SecondaryConfig mySecConfig = new SecondaryConfig();
    mySecConfig.setAllowCreate(true);
    /*
     * Duplicates are frequently required for secondary databases.
View Full Code Here

Examples of com.sleepycat.bind.serial.SerialBinding

        runner = new TransactionRunner(env);

        catalog = new StoredClassCatalog(openDb(CATALOG_FILE, false));
        catalog2 = new StoredClassCatalog(openDb("catalog2.db", true));

        SerialBinding keyBinding = new SerialBinding(catalog,
                                                  String.class);
        SerialBinding valueBinding = new SerialBinding(catalog,
                                                    TestSerial.class);
        store = openDb(STORE_FILE, false);

        map = new StoredMap(store, keyBinding, valueBinding, true);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.