All Downloads are FREE. Search and download functionalities are using the official Maven repository.

Alachisoft.NCache.Common.Activate.CpuInfoResult Maven / Gradle / Ivy

There is a newer version: 5.3.3
Show newest version
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Alachisoft.NCache.Common.Activate;

import Alachisoft.NCache.Common.Common;
import com.alachisoft.ncache.serialization.core.io.InternalCompactSerializable;
import com.alachisoft.ncache.serialization.standard.io.CompactReader;
import com.alachisoft.ncache.serialization.standard.io.CompactWriter;

import java.io.IOException;

/**
 * @author Muneeb_Shahid
 */
public class CpuInfoResult implements InternalCompactSerializable {

    private byte[][] infoChunks;

    public CpuInfoResult() {
    }

    public CpuInfoResult(byte[][] dataChunks) {
        this.infoChunks = dataChunks;
    }

    @Override
    public void Deserialize(CompactReader reader) throws IOException, ClassNotFoundException {
        int totalChunks = Common.as(reader.ReadObject(), Integer.class);
        infoChunks = new byte[totalChunks][totalChunks];
        int chunkNo = 0;
        while (chunkNo < totalChunks) {
            int length = Common.as(reader.ReadObject(), Integer.class);
            byte[] temp = reader.ReadBytes(length);
            infoChunks[chunkNo++] = temp;
        }
    }

    @Override
    public void Serialize(CompactWriter writer) throws IOException {
        writer.WriteObject(infoChunks.length);
        for (byte[] infoChunk : infoChunks) {
            writer.WriteObject(infoChunk.length);
            writer.Write(infoChunk);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy