Class ByteArraySerializer

java.lang.Object
org.ehcache.impl.serialization.ByteArraySerializer
All Implemented Interfaces:
org.ehcache.spi.serialization.Serializer<byte[]>

public class ByteArraySerializer extends Object implements org.ehcache.spi.serialization.Serializer<byte[]>
Default Serializer for byte[] type. Simply writes the byte array to a byte buffer.

Note that equals(byte[], ByteBuffer) does not follow the byte[].equals(Object) contract but does byte-to-byte comparison of both byte arrays.

  • Constructor Details

    • ByteArraySerializer

      public ByteArraySerializer()
      No arg constructor
    • ByteArraySerializer

      public ByteArraySerializer(ClassLoader classLoader)
      Constructor to enable this serializer as a transient one.

      Parameter is ignored as byte[] is a base java type.

      Parameters:
      classLoader - the classloader to use
      See Also:
      • Serializer
  • Method Details

    • serialize

      public ByteBuffer serialize(byte[] object) throws org.ehcache.spi.serialization.SerializerException
      Specified by:
      serialize in interface org.ehcache.spi.serialization.Serializer<byte[]>
      Throws:
      org.ehcache.spi.serialization.SerializerException
    • read

      public byte[] read(ByteBuffer binary)
      Specified by:
      read in interface org.ehcache.spi.serialization.Serializer<byte[]>
    • equals

      public boolean equals(byte[] object, ByteBuffer binary)
      Specified by:
      equals in interface org.ehcache.spi.serialization.Serializer<byte[]>