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

org.infinispan.protostream.MessageMarshaller Maven / Gradle / Ivy

There is a newer version: 9.1.7.Final
Show newest version
package org.infinispan.protostream;

import java.io.IOException;
import java.util.Collection;
import java.util.Date;

/**
 * @author [email protected]
 * @since 1.0
 */
public interface MessageMarshaller extends BaseMarshaller {

   T readFrom(ProtoStreamReader reader) throws IOException;

   void writeTo(ProtoStreamWriter writer, T t) throws IOException;

   /**
    * An high-level interface for the wire encoding of a protobuf stream that allows reading named and typed message
    * fields.
    */
   interface ProtoStreamReader {

      SerializationContext getSerializationContext();

      /**
       * Can't return an {@code int} here because the field might be declared optional and missing so we might need to
       * return a {@code null}.
       */
      Integer readInt(String fieldName) throws IOException;

      Long readLong(String fieldName) throws IOException;

      Date readDate(String fieldName) throws IOException;

      Float readFloat(String fieldName) throws IOException;

      Double readDouble(String fieldName) throws IOException;

      Boolean readBoolean(String fieldName) throws IOException;

      String readString(String fieldName) throws IOException;

      byte[] readBytes(String fieldName) throws IOException;

       E readObject(String fieldName, Class clazz) throws IOException;

      > C readCollection(String fieldName, C collection, Class elementClass) throws IOException;

       E[] readArray(String fieldName, Class elementClass) throws IOException;
   }

   interface ProtoStreamWriter {

      SerializationContext getSerializationContext();

      void writeInt(String fieldName, Integer value) throws IOException;

      void writeInt(String fieldName, int value) throws IOException;

      void writeLong(String fieldName, long value) throws IOException;

      void writeLong(String fieldName, Long value) throws IOException;

      void writeDate(String fieldName, Date value) throws IOException;

      void writeDouble(String fieldName, double value) throws IOException;

      void writeDouble(String fieldName, Double value) throws IOException;

      void writeFloat(String fieldName, float value) throws IOException;

      void writeFloat(String fieldName, Float value) throws IOException;

      void writeBoolean(String fieldName, boolean value) throws IOException;

      void writeBoolean(String fieldName, Boolean value) throws IOException;

      void writeString(String fieldName, String value) throws IOException;

      void writeBytes(String fieldName, byte[] value) throws IOException;

       void writeObject(String fieldName, E value, Class clazz) throws IOException;

       void writeCollection(String fieldName, Collection collection, Class elementClass) throws IOException;

       void writeArray(String fieldName, E[] array, Class elementClass) throws IOException;
   }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy