Alachisoft.NCache.Common.Communication.ProtoBuffFormatter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of nc-common Show documentation
Show all versions of nc-common Show documentation
Internal package of Alachisoft.
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();
}
}
}