Package io.sentry

Class GsonSerializer

  • All Implemented Interfaces:
    ISerializer

    public final class GsonSerializer
    extends java.lang.Object
    implements ISerializer
    The AndroidSerializer class that uses Gson as JSON parser
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      <T> T deserialize​(@NotNull java.io.Reader reader, @NotNull java.lang.Class<T> clazz)
      Deserialize an object of class given by clazz parameter from a stream Reader (JSON)
      @Nullable SentryEnvelope deserializeEnvelope​(@NotNull java.io.InputStream inputStream)
      Deserialize a SentryEnvelope from a InputStream (Envelope+JSON)
      void serialize​(@NotNull SentryEnvelope envelope, @NotNull java.io.OutputStream outputStream)
      Serialize a SentryEnvelope to a stream Writer (JSON)
      @NotNull java.lang.String serialize​(@NotNull java.util.Map<java.lang.String,​java.lang.Object> data)
      Serialize a Map to a String
      <T> void serialize​(T entity, @NotNull java.io.Writer writer)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • GsonSerializer

        public GsonSerializer​(@NotNull
                              @NotNull SentryOptions options)
        AndroidSerializer ctor
        Parameters:
        options - the SentryOptions object
    • Method Detail

      • deserialize

        @Nullable
        public <T> T deserialize​(@NotNull
                                 @NotNull java.io.Reader reader,
                                 @NotNull
                                 @NotNull java.lang.Class<T> clazz)
        Deserialize an object of class given by clazz parameter from a stream Reader (JSON)
        Specified by:
        deserialize in interface ISerializer
        Parameters:
        reader - the Reader
        clazz - the type of object to deserialize into
        Returns:
        the deserialized object or null
      • deserializeEnvelope

        @Nullable
        public @Nullable SentryEnvelope deserializeEnvelope​(@NotNull
                                                            @NotNull java.io.InputStream inputStream)
        Deserialize a SentryEnvelope from a InputStream (Envelope+JSON)
        Specified by:
        deserializeEnvelope in interface ISerializer
        Parameters:
        inputStream - the InputStream
        Returns:
        the SentryEnvelope class or null
      • serialize

        public <T> void serialize​(@NotNull
                                  T entity,
                                  @NotNull
                                  @NotNull java.io.Writer writer)
                           throws java.io.IOException
        Specified by:
        serialize in interface ISerializer
        Throws:
        java.io.IOException
      • serialize

        public void serialize​(@NotNull
                              @NotNull SentryEnvelope envelope,
                              @NotNull
                              @NotNull java.io.OutputStream outputStream)
                       throws java.lang.Exception
        Serialize a SentryEnvelope to a stream Writer (JSON)
        Specified by:
        serialize in interface ISerializer
        Parameters:
        envelope - the SentryEnvelope
        outputStream - the OutputStream
        Throws:
        java.lang.Exception - an Exception
      • serialize

        @NotNull
        public @NotNull java.lang.String serialize​(@NotNull
                                                   @NotNull java.util.Map<java.lang.String,​java.lang.Object> data)
                                            throws java.lang.Exception
        Serialize a Map to a String
        Specified by:
        serialize in interface ISerializer
        Parameters:
        data - the data Map
        Returns:
        the serialized String
        Throws:
        java.lang.Exception - the Exception if there was a problem during serialization