Package com.sleepycat.bind.tuple

Examples of com.sleepycat.bind.tuple.TupleOutput


                AMQShortString queueNameAMQ = new AMQShortString(queueName);
                QueueRecord record = new QueueRecord(queueNameAMQ, null, false, null);

                DatabaseEntry key = new DatabaseEntry();

                TupleOutput output = new TupleOutput();
                AMQShortStringEncoding.writeShortString(record.getNameShortString(), output);
                TupleBase.outputToEntry(output, key);

                DatabaseEntry newValue = new DatabaseEntry();
                binding.objectToEntry(record, newValue);
View Full Code Here


                DUMMY_ATTRIBUTES_MAP);
    }

    public void testObjectToEntryAndEntryToObject()
    {
        TupleOutput tupleOutput = new TupleOutput();

        _configuredObjectBinding.objectToEntry(_object, tupleOutput);

        byte[] entryAsBytes = tupleOutput.getBufferBytes();
        TupleInput tupleInput = new TupleInput(entryAsBytes);

        ConfiguredObjectRecord storedObject = _configuredObjectBinding.entryToObject(tupleInput);
        assertEquals("Unexpected attributes", DUMMY_ATTRIBUTES_MAP, storedObject.getAttributes());
        assertEquals("Unexpected type", DUMMY_TYPE_STRING, storedObject.getType());
View Full Code Here

    * parts.
    */
   private DatabaseEntry makeKeyEntry(Fqn name, int nParts)
   {
      /* Write the sequence of name parts. */
      TupleOutput tupleOutput = new TupleOutput();
      for (int i = 0; i < nParts; i += 1)
      {
         tupleOutput.writeString(name.get(i).toString());
      }

      /* Return the tuple as an entry. */
      DatabaseEntry entry = new DatabaseEntry();
      TupleBinding.outputToEntry(tupleOutput, entry);
View Full Code Here

    */
   private DatabaseEntry makeKeyEntry(DatabaseEntry prefix, String namePart)
   {

      /* Write the bytes of the prefix followed by the child name. */
      TupleOutput tupleOutput = new TupleOutput();
      tupleOutput.writeFast(prefix.getData(),
            prefix.getOffset(),
            prefix.getSize());
      tupleOutput.writeString(namePart);

      /* Return the tuple as an entry. */
      DatabaseEntry entry = new DatabaseEntry();
      TupleBinding.outputToEntry(tupleOutput, entry);
      return entry;
View Full Code Here

    // javadoc is inherited
    public boolean createSecondaryKey(SecondaryDatabase db,
                                      DatabaseEntry primaryKeyEntry,
                                      DatabaseEntry dataEntry,
                                      DatabaseEntry indexKeyEntry) {
        TupleOutput output = getTupleOutput(null);
        TupleInput primaryKeyInput = entryToInput(primaryKeyEntry);
        D dataInput = dataBinding.entryToObject(dataEntry);
        if (createSecondaryKey(primaryKeyInput, dataInput, output)) {
            outputToEntry(output, indexKeyEntry);
            return true;
View Full Code Here

    }

    // javadoc is inherited
    public void objectToKey(E object, DatabaseEntry key) {

        TupleOutput output = getTupleOutput(object);
        objectToKey(object, output);
        outputToEntry(output, key);
    }
View Full Code Here

     * @param object the object being serialized
     * @return the hex string containing the serialized hex form of the object
     */
    static <T> String objectToHex(TupleBinding<T> binding, T object) {
        StringBuilder buffer = new StringBuilder();
        TupleOutput tuple = new TupleOutput(new byte[100]);
        binding.objectToEntry(object, tuple);
        byte[] bytes = tuple.getBufferBytes();
        int size = tuple.getBufferLength();

        for (int i=0; i < size; i++) {
            int lowNibble = (bytes[i] & 0xf);
            int highNibble = ((bytes[i]>>4) & 0xf);
            buffer.append(Character.forDigit(lowNibble,16));
View Full Code Here

     *
     * @return the serailized byte array
     */
    static public byte[] serializeBytes(RepNodeImpl node) {
        final NodeBinding binding = new NodeBinding();
        TupleOutput tuple = new TupleOutput(new byte[100]);
        binding.objectToEntry(node, tuple);
        return tuple.getBufferBytes();
    }
View Full Code Here

{

    public void testWriteReadNullValues()
    {
        // write into tuple output
        TupleOutput tupleOutput = new TupleOutput();
        AMQShortStringEncoding.writeShortString(null, tupleOutput);
        byte[] data = tupleOutput.getBufferBytes();

        // read from tuple input
        TupleInput tupleInput = new TupleInput(data);
        AMQShortString result = AMQShortStringEncoding.readShortString(tupleInput);
        assertNull("Expected null but got " + result, result);
View Full Code Here

    public void testWriteReadShortStringWithLengthOver127()
    {
        AMQShortString value = createString('a', 128);

        // write into tuple output
        TupleOutput tupleOutput = new TupleOutput();
        AMQShortStringEncoding.writeShortString(value, tupleOutput);
        byte[] data = tupleOutput.getBufferBytes();

        // read from tuple input
        TupleInput tupleInput = new TupleInput(data);
        AMQShortString result = AMQShortStringEncoding.readShortString(tupleInput);
        assertEquals("Expected " + value + " but got " + result, value, result);
View Full Code Here

TOP

Related Classes of com.sleepycat.bind.tuple.TupleOutput

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.