summaryrefslogtreecommitdiff
path: root/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/tuple/ConfiguredObjectBinding.java
blob: 8b84a4c9bb8c347eb92f2e6993eb44e0b8922ad0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package org.apache.qpid.server.store.berkeleydb.tuple;

import org.apache.qpid.server.store.ConfiguredObjectRecord;

import com.sleepycat.bind.tuple.TupleBinding;
import com.sleepycat.bind.tuple.TupleInput;
import com.sleepycat.bind.tuple.TupleOutput;

public class ConfiguredObjectBinding extends TupleBinding<ConfiguredObjectRecord>
{
    private static final ConfiguredObjectBinding INSTANCE = new ConfiguredObjectBinding();

    public static ConfiguredObjectBinding getInstance()
    {
        return INSTANCE;
    }

    /** non-public constructor forces getInstance instead */
    private ConfiguredObjectBinding()
    {
    }

    public ConfiguredObjectRecord entryToObject(TupleInput tupleInput)
    {
        String type = tupleInput.readString();
        String json = tupleInput.readString();
        ConfiguredObjectRecord configuredObject = new ConfiguredObjectRecord(null, type, json);
        return configuredObject;
    }

    public void objectToEntry(ConfiguredObjectRecord object, TupleOutput tupleOutput)
    {
        tupleOutput.writeString(object.getType());
        tupleOutput.writeString(object.getAttributes());
    }

}