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

Alachisoft.NCache.Common.Communication.ProtoBuffFormatter Maven / Gradle / Ivy

There is a newer version: 5.3.3
Show newest version
package Alachisoft.NCache.Common.Communication;

import com.alachisoft.ncache.common.protobuf.ManagementCommandProtocol.ManagementCommand;
import com.alachisoft.ncache.common.protobuf.ManagementResponseProtocol.ManagementResponse;
import com.google.protobuf.InvalidProtocolBufferException;

public class ProtoBuffFormatter implements IChannelFormatter {
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: public byte[] Serialize(object graph)

    @Override
    public final byte[] Serialize(Object graph) {
        ManagementCommand command = (ManagementCommand) ((graph instanceof ManagementCommand) ? graph : null);

//C# TO JAVA CONVERTER NOTE: The following 'using' block is replaced by its Java equivalent:
//		using (MemoryStream stream = new MemoryStream())
//        MemoryStream stream = new MemoryStream();
        try {
        } finally {
//            stream.dispose();
        }


//C# TO JAVA CONVERTER NOTE: The following 'using' block is replaced by its Java equivalent:
//		using (MemoryStream stream = new MemoryStream())
//        MemoryStream stream = new MemoryStream();
        try {
            //
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: byte[] argumentBuffer = null;
            byte[] argumentBuffer = null;
            //((Protobuf.NCManagementCommand)graph).ArgumentObject = argumentBuffer;
//            Serializer.Serialize(stream, (ManagementCommand) graph);
            return command.toBuilder().build().toByteArray();

//            return stream.toArray();
        } finally {
//            stream.dispose();
        }

    }

    //C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
//ORIGINAL LINE: public object Deserialize(byte[] buffer)
    public final Object Deserialize(byte[] buffer) throws InvalidProtocolBufferException {
//C# TO JAVA CONVERTER NOTE: The following 'using' block is replaced by its Java equivalent:
//		using (MemoryStream stream = new MemoryStream(buffer))
//        MemoryStream stream = new MemoryStream(buffer);
        try {
            return ManagementResponse.parseFrom(buffer);
//            return Serializer.Deserialize(stream);
        } finally {
//            stream.dispose();
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy