Search in sources :

Example 1 with SecondaryTargetType

use of com.ms.silverking.cloud.dht.client.SecondaryTargetType in project SilverKing by Morgan-Stanley.

the class SecondaryTargetSerializer method deserialize.

public static Set<SecondaryTarget> deserialize(byte[] multiDef) {
    try {
        ImmutableSet.Builder<SecondaryTarget> specs;
        int i;
        specs = ImmutableSet.builder();
        i = 0;
        while (i < multiDef.length) {
            SecondaryTargetType type;
            int targetSize;
            byte[] targetBytes;
            String target;
            type = SecondaryTargetType.values()[multiDef[i++]];
            targetSize = NumConversion.bytesToShort(multiDef, i);
            i += NumConversion.BYTES_PER_SHORT;
            targetBytes = new byte[targetSize];
            System.arraycopy(multiDef, i, targetBytes, 0, targetSize);
            i += targetSize;
            target = new String(targetBytes);
            specs.add(new SecondaryTarget(type, target));
        }
        return specs.build();
    } catch (Exception e) {
        Log.logErrorWarning(e);
        return ImmutableSet.of();
    }
}
Also used : SecondaryTarget(com.ms.silverking.cloud.dht.SecondaryTarget) ImmutableSet(com.google.common.collect.ImmutableSet) SecondaryTargetType(com.ms.silverking.cloud.dht.client.SecondaryTargetType)

Aggregations

ImmutableSet (com.google.common.collect.ImmutableSet)1 SecondaryTarget (com.ms.silverking.cloud.dht.SecondaryTarget)1 SecondaryTargetType (com.ms.silverking.cloud.dht.client.SecondaryTargetType)1