Class DataSerializer

  • java.lang.Object
    • org.apache.geode.DataSerializer

  • public abstract class DataSerializer
    extends java.lang.Object
    Provides static helper methods for reading and writing non-primitive data when working with a DataSerializable. For instance, classes that implement DataSerializable can use the DataSerializer in their toData and fromData methods:
     public class Employee implements DataSerializable {
       private int id;
       private String name;
       private Date birthday;
       private Company employer;
    
       public void toData(DataOutput out) throws IOException {
         out.writeInt(this.id);
         out.writeUTF(this.name);
         DataSerializer.writeDate(this.birthday, out);
         DataSerializer.writeObject(this.employer, out);
       }
    
       public void fromData(DataInput in) throws IOException, ClassNotFoundException {
    
         this.id = in.readInt();
         this.name = in.readUTF();
         this.birthday = DataSerializer.readDate(in);
         this.employer = (Company) DataSerializer.readObject(in);
       }
     }
    
     

    Instances of DataSerializer are used to data serialize objects (such as instances of standard Java classes or third-party classes for which the source code is not available) that do not implement the DataSerializable interface.

    The following DataSerializer data serializes instances of Company. In order for the data serialization framework to consult this custom serializer, it must be registered with the framework.

    public class CompanySerializer extends DataSerializer {
    
      static {
        DataSerializer.register(CompanySerializer.class);
      }
    
      /**
     May be invoked reflectively if instances of Company are
     distributed to other VMs.
    /
      public CompanySerializer() {
    
      }
    
      public Class[] getSupportedClasses() {
        return new Class[] { Company.class };
      }
      public int getId() {
        return 42;
      }
    
      public boolean toData(Object o, DataOutput out)
        throws IOException {
        if (o instanceof Company) {
          Company company = (Company) o;
          out.writeUTF(company.getName());
    
          // Let's assume that Address is java.io.Serializable
          Address address = company.getAddress();
          writeObject(address, out);
          return true;
    
        } else {
          return false;
        }
      }
    
      public Object fromData(DataInput in)
        throws IOException, ClassNotFoundException {
    
        String name = in.readUTF();
        Address address = (Address) readObject(in);
        return new Company(name, address);
      }
    }
     
    Just like Instantiators, a DataSerializer may be sent to other members of the distributed system when it is registered. The data serialization framework does not require that a DataSerializer be Serializable, but it does require that it provide a zero-argument constructor.
    Since:
    GemFire 3.5
    See Also:
    writeObject(Object, DataOutput), readObject(java.io.DataInput)
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected static java.lang.ThreadLocal<java.lang.Boolean> DISALLOW_JAVA_SERIALIZATION  
      protected static boolean TRACE_SERIALIZABLE
      Deprecated.
      Use Boolean.getBoolean("DataSerializer.TRACE_SERIALIZABLE") instead.
    • Constructor Summary

      Constructors 
      Constructor Description
      DataSerializer()
      Creates a new DataSerializer.
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object o)
      Two DataSerializers are consider to be equal if they have the same id and the same class
      abstract java.lang.Object fromData​(java.io.DataInput in)
      Reads an object from a DataInput.
      java.lang.Object getContext()
      For internal use only.
      java.lang.Object getEventId()
      For internal use only.
      abstract int getId()
      Returns the id of this DataSerializer.
      abstract java.lang.Class<?>[] getSupportedClasses()
      Returns the Classes whose instances are data serialized by this DataSerializer.
      int hashCode()  
      static <E> java.util.ArrayList<E> readArrayList​(java.io.DataInput in)
      Reads an ArrayList from a DataInput.
      static byte[][] readArrayOfByteArrays​(java.io.DataInput in)
      Reads an array of byte[]s from a DataInput.
      static java.lang.Boolean readBoolean​(java.io.DataInput in)
      Reads an instance of Boolean from a DataInput.
      static boolean[] readBooleanArray​(java.io.DataInput in)
      Reads an array of booleans from a DataInput.
      static java.lang.Byte readByte​(java.io.DataInput in)
      Reads an instance of Byte from a DataInput.
      static byte[] readByteArray​(java.io.DataInput in)
      Reads an array of bytes from a DataInput.
      static java.lang.Character readCharacter​(java.io.DataInput in)
      Reads an instance of Character from a DataInput.
      static char[] readCharArray​(java.io.DataInput in)
      Reads an array of chars from a DataInput.
      static java.lang.Class<?> readClass​(java.io.DataInput in)
      Reads an instance of Class from a DataInput.
      static <K,​V>
      java.util.concurrent.ConcurrentHashMap<K,​V>
      readConcurrentHashMap​(java.io.DataInput in)
      Reads a ConcurrentHashMap from a DataInput.
      static java.util.Date readDate​(java.io.DataInput in)
      Reads an instance of Date from a DataInput.
      static java.lang.Double readDouble​(java.io.DataInput in)
      Reads an instance of Double from a DataInput.
      static double[] readDoubleArray​(java.io.DataInput in)
      Reads an array of doubles from a DataInput.
      static <E extends java.lang.Enum<E>>
      E
      readEnum​(java.lang.Class<E> clazz, java.io.DataInput in)
      Reads a Enum constant from DataInput.
      static java.io.File readFile​(java.io.DataInput in)
      Reads an instance of File from a DataInput.
      static java.lang.Float readFloat​(java.io.DataInput in)
      Reads an instance of Float from a DataInput.
      static float[] readFloatArray​(java.io.DataInput in)
      Reads an array of floats from a DataInput.
      static <K,​V>
      java.util.HashMap<K,​V>
      readHashMap​(java.io.DataInput in)
      Reads a HashMap from a DataInput.
      static <E> java.util.HashSet<E> readHashSet​(java.io.DataInput in)
      Reads a HashSet from a DataInput.
      static <K,​V>
      java.util.Hashtable<K,​V>
      readHashtable​(java.io.DataInput in)
      Reads a Hashtable from a DataInput.
      static <K,​V>
      java.util.IdentityHashMap<K,​V>
      readIdentityHashMap​(java.io.DataInput in)
      Reads a IdentityHashMap from a DataInput.
      static java.net.InetAddress readInetAddress​(java.io.DataInput in)
      Reads an instance of InetAddress from a DataInput.
      static int[] readIntArray​(java.io.DataInput in)
      Reads an int array from a DataInput.
      static java.lang.Integer readInteger​(java.io.DataInput in)
      Reads an instance of Integer from a DataInput.
      static <K,​V>
      java.util.LinkedHashMap<K,​V>
      readLinkedHashMap​(java.io.DataInput in)
      Reads a LinkedHashMap from a DataInput.
      static <E> java.util.LinkedHashSet<E> readLinkedHashSet​(java.io.DataInput in)
      Reads a LinkedHashSet from a DataInput.
      static <E> java.util.LinkedList<E> readLinkedList​(java.io.DataInput in)
      Reads an LinkedList from a DataInput.
      static java.lang.Long readLong​(java.io.DataInput in)
      Reads an instance of Long from a DataInput.
      static long[] readLongArray​(java.io.DataInput in)
      Reads an array of longs from a DataInput.
      static java.lang.String readNonPrimitiveClassName​(java.io.DataInput in)
      Reads name of an instance of Class from a DataInput.
      static <T> T readObject​(java.io.DataInput in)
      Reads an arbitrary object from a DataInput.
      static java.lang.Object[] readObjectArray​(java.io.DataInput in)
      Reads an array of Objects from a DataInput.
      static boolean readPrimitiveBoolean​(java.io.DataInput in)
      Reads a primitive boolean from a DataInput.
      static byte readPrimitiveByte​(java.io.DataInput in)
      Reads a primitive byte from a DataInput.
      static char readPrimitiveChar​(java.io.DataInput in)
      Reads a primitive char from a DataInput.
      static double readPrimitiveDouble​(java.io.DataInput in)
      Reads a primitive double from a DataInput.
      static float readPrimitiveFloat​(java.io.DataInput in)
      Reads a primitive float from a DataInput.
      static int readPrimitiveInt​(java.io.DataInput in)
      Reads a primitive int from a DataInput.
      static long readPrimitiveLong​(java.io.DataInput in)
      Reads a primitive long from a DataInput.
      static short readPrimitiveShort​(java.io.DataInput in)
      Reads a primitive short from a DataInput.
      static java.util.Properties readProperties​(java.io.DataInput in)
      Reads a Properties from a DataInput.
      static <K,​V>
      Region<K,​V>
      readRegion​(java.io.DataInput in)
      Reads an instance of Region.
      static java.lang.Short readShort​(java.io.DataInput in)
      Reads an instance of Short from a DataInput.
      static short[] readShortArray​(java.io.DataInput in)
      Reads an array of shorts from a DataInput.
      static <E> java.util.Stack<E> readStack​(java.io.DataInput in)
      Reads an Stack from a DataInput.
      static java.lang.String readString​(java.io.DataInput in)
      Reads an instance of String from a DataInput.
      static java.lang.String[] readStringArray​(java.io.DataInput in)
      Reads an array of Strings from a DataInput.
      static <K,​V>
      java.util.TreeMap<K,​V>
      readTreeMap​(java.io.DataInput in)
      Reads a TreeMap from a DataInput.
      static <E> java.util.TreeSet<E> readTreeSet​(java.io.DataInput in)
      Reads a TreeSet from a DataInput.
      static int readUnsignedByte​(java.io.DataInput in)
      Reads a primitive int as an unsigned byte from a DataInput using DataInput.readUnsignedByte().
      static int readUnsignedShort​(java.io.DataInput in)
      Reads a primitive int as an unsigned short from a DataInput using DataInput.readUnsignedShort().
      static <E> java.util.Vector<E> readVector​(java.io.DataInput in)
      Reads an Vector from a DataInput.
      static DataSerializer register​(java.lang.Class<?> c)
      Registers a DataSerializer class with the data serialization framework.
      void setContext​(java.lang.Object context)
      For internal use only.
      void setEventId​(java.lang.Object eventId)
      For internal use only.
      abstract boolean toData​(java.lang.Object o, java.io.DataOutput out)
      Data serializes an object to a DataOutput.
      static void writeArrayList​(java.util.ArrayList<?> list, java.io.DataOutput out)
      Writes an ArrayList to a DataOutput.
      static void writeArrayOfByteArrays​(byte[][] array, java.io.DataOutput out)
      Writes an array of byte[] to a DataOutput.
      static void writeBoolean​(java.lang.Boolean value, java.io.DataOutput out)
      Writes an instance of Boolean to a DataOutput.
      static void writeBooleanArray​(boolean[] array, java.io.DataOutput out)
      Writes an array of booleans to a DataOutput.
      static void writeByte​(java.lang.Byte value, java.io.DataOutput out)
      Writes an instance of Byte to a DataOutput.
      static void writeByteArray​(byte[] array, int len, java.io.DataOutput out)
      Writes the first len elements of an array of bytes to a DataOutput.
      static void writeByteArray​(byte[] array, java.io.DataOutput out)
      Writes an array of bytes to a DataOutput.
      static void writeCharacter​(java.lang.Character value, java.io.DataOutput out)
      Writes an instance of Character to a DataOutput.
      static void writeCharArray​(char[] array, java.io.DataOutput out)
      Writes an array of chars to a DataOutput.
      static void writeClass​(java.lang.Class<?> c, java.io.DataOutput out)
      Writes an instance of Class to a DataOutput.
      static void writeConcurrentHashMap​(java.util.concurrent.ConcurrentHashMap<?,​?> map, java.io.DataOutput out)
      Writes a ConcurrentHashMap to a DataOutput.
      static void writeDate​(java.util.Date date, java.io.DataOutput out)
      Writes an instance of Date to a DataOutput.
      static void writeDouble​(java.lang.Double value, java.io.DataOutput out)
      Writes an instance of Double to a DataOutput.
      static void writeDoubleArray​(double[] array, java.io.DataOutput out)
      Writes an array of doubles to a DataOutput.
      static void writeEnum​(java.lang.Enum<?> e, java.io.DataOutput out)
      Writes the Enum constant to DataOutput.
      static void writeFile​(java.io.File file, java.io.DataOutput out)
      Writes an instance of File to a DataOutput.
      static void writeFloat​(java.lang.Float value, java.io.DataOutput out)
      Writes an instance of Float to a DataOutput.
      static void writeFloatArray​(float[] array, java.io.DataOutput out)
      Writes an array of floats to a DataOutput.
      static void writeHashMap​(java.util.Map<?,​?> map, java.io.DataOutput out)
      Writes a HashMap to a DataOutput.
      static void writeHashSet​(java.util.HashSet<?> set, java.io.DataOutput out)
      Writes a HashSet to a DataOutput.
      static void writeHashtable​(java.util.Hashtable<?,​?> map, java.io.DataOutput out)
      Writes a Hashtable to a DataOutput.
      static void writeIdentityHashMap​(java.util.IdentityHashMap<?,​?> map, java.io.DataOutput out)
      Writes a IdentityHashMap to a DataOutput.
      static void writeInetAddress​(java.net.InetAddress address, java.io.DataOutput out)
      Writes an instance of InetAddress to a DataOutput.
      static void writeIntArray​(int[] array, java.io.DataOutput out)
      Writes an int array to a DataOutput.
      static void writeInteger​(java.lang.Integer value, java.io.DataOutput out)
      Writes an instance of Integer to a DataOutput.
      static void writeLinkedHashMap​(java.util.Map<?,​?> map, java.io.DataOutput out)
      Writes a LinkedHashMap to a DataOutput.
      static void writeLinkedHashSet​(java.util.LinkedHashSet<?> set, java.io.DataOutput out)
      Writes a LinkedHashSet to a DataOutput.
      static void writeLinkedList​(java.util.LinkedList<?> list, java.io.DataOutput out)
      Writes an LinkedList to a DataOutput.
      static void writeLong​(java.lang.Long value, java.io.DataOutput out)
      Writes an instance of Long to a DataOutput.
      static void writeLongArray​(long[] array, java.io.DataOutput out)
      Writes an array of longs to a DataOutput.
      static void writeNonPrimitiveClassName​(java.lang.String className, java.io.DataOutput out)
      Writes class name to a DataOutput.
      static void writeObject​(java.lang.Object o, java.io.DataOutput out)
      Writes an arbitrary object to a DataOutput.
      static void writeObject​(java.lang.Object o, java.io.DataOutput out, boolean allowJavaSerialization)
      Writes an arbitrary object to a DataOutput.
      static void writeObjectArray​(java.lang.Object[] array, java.io.DataOutput out)
      Writes an array of Objects to a DataOutput.
      static void writeObjectAsByteArray​(java.lang.Object obj, java.io.DataOutput out)
      Serialize the given object obj into a byte array using writeObject(Object, DataOutput) and then writes the byte array to the given data output out in the same format writeByteArray(byte[], DataOutput) does.
      static void writePrimitiveBoolean​(boolean value, java.io.DataOutput out)
      Writes a primitive boolean to a DataOutput.
      static void writePrimitiveByte​(byte value, java.io.DataOutput out)
      Writes a primitive byte to a DataOutput.
      static void writePrimitiveChar​(char value, java.io.DataOutput out)
      Writes a primitive char to a DataOutput.
      static void writePrimitiveDouble​(double value, java.io.DataOutput out)
      Writes a primtive double to a DataOutput.
      static void writePrimitiveFloat​(float value, java.io.DataOutput out)
      Writes a primitive float to a DataOutput.
      static void writePrimitiveInt​(int value, java.io.DataOutput out)
      Writes a primitive int to a DataOutput.
      static void writePrimitiveLong​(long value, java.io.DataOutput out)
      Writes a primitive long to a DataOutput.
      static void writePrimitiveShort​(short value, java.io.DataOutput out)
      Writes a primitive short to a DataOutput.
      static void writeProperties​(java.util.Properties props, java.io.DataOutput out)
      Writes a Properties to a DataOutput.
      static void writeRegion​(Region<?,​?> rgn, java.io.DataOutput out)
      Writes an instance of Region.
      static void writeShort​(java.lang.Short value, java.io.DataOutput out)
      Writes an instance of Short to a DataOutput.
      static void writeShortArray​(short[] array, java.io.DataOutput out)
      Writes an array of shorts to a DataOutput.
      static void writeStack​(java.util.Stack<?> list, java.io.DataOutput out)
      Writes an Stack to a DataOutput.
      static void writeString​(java.lang.String value, java.io.DataOutput out)
      Writes an instance of String to a DataOutput.
      static void writeStringArray​(java.lang.String[] array, java.io.DataOutput out)
      Writes an array of Strings to a DataOutput.
      static void writeTreeMap​(java.util.TreeMap<?,​?> map, java.io.DataOutput out)
      Writes a TreeMap to a DataOutput.
      static void writeTreeSet​(java.util.TreeSet<?> set, java.io.DataOutput out)
      Writes a TreeSet to a DataOutput.
      static void writeUnsignedByte​(int value, java.io.DataOutput out)
      Writes a primitive int as an unsigned byte to a DataOutput.
      static void writeUnsignedShort​(int value, java.io.DataOutput out)
      Writes a primitive int as an unsigned short to a DataOutput.
      static void writeVector​(java.util.Vector<?> list, java.io.DataOutput out)
      Writes an Vector to a DataOutput.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • TRACE_SERIALIZABLE

        @Deprecated
        protected static final boolean TRACE_SERIALIZABLE
        Deprecated.
        Use Boolean.getBoolean("DataSerializer.TRACE_SERIALIZABLE") instead.
      • DISALLOW_JAVA_SERIALIZATION

        protected static final java.lang.ThreadLocal<java.lang.Boolean> DISALLOW_JAVA_SERIALIZATION
    • Constructor Detail

      • DataSerializer

        public DataSerializer()
        Creates a new DataSerializer. All class that implement DataSerializer must provide a zero-argument constructor.
        See Also:
        register(Class)
    • Method Detail

      • writeClass

        public static void writeClass​(java.lang.Class<?> c,
                                      java.io.DataOutput out)
                               throws java.io.IOException
        Writes an instance of Class to a DataOutput. This method will handle a null value and not throw a NullPointerException.
        Parameters:
        c - the Class to write
        out - the DataInput to write to
        Throws:
        java.io.IOException - A problem occurs while writing to out
        See Also:
        readClass(java.io.DataInput)
      • writeNonPrimitiveClassName

        public static void writeNonPrimitiveClassName​(java.lang.String className,
                                                      java.io.DataOutput out)
                                               throws java.io.IOException
        Writes class name to a DataOutput. This method will handle a null value and not throw a NullPointerException.
        Parameters:
        className - the class name to write
        out - the DataInput to write to
        Throws:
        java.io.IOException - A problem occurs while writing to out
        See Also:
        readNonPrimitiveClassName(DataInput)
      • readClass

        public static java.lang.Class<?> readClass​(java.io.DataInput in)
                                            throws java.io.IOException,
                                                   java.lang.ClassNotFoundException
        Reads an instance of Class from a DataInput. The class will be loaded using the current content class loader. The return value may be null.
        Parameters:
        in - the DataInput to read from
        Returns:
        the deserialized Class
        Throws:
        java.io.IOException - A problem occurs while reading from in
        java.lang.ClassNotFoundException - The class cannot be loaded
      • readNonPrimitiveClassName

        public static java.lang.String readNonPrimitiveClassName​(java.io.DataInput in)
                                                          throws java.io.IOException
        Reads name of an instance of Class from a DataInput. The return value may be null.
        Parameters:
        in - the DataInput to read from
        Returns:
        the deserialized Class name
        Throws:
        java.io.IOException - A problem occurs while reading from in
        See Also:
        writeNonPrimitiveClassName(String, DataOutput)
      • writeRegion

        public static void writeRegion​(Region<?,​?> rgn,
                                       java.io.DataOutput out)
                                throws java.io.IOException
        Writes an instance of Region. A Region is serialized as just a reference to a full path only. It will be recreated on the other end by calling CacheFactory.getAnyInstance() and then calling getRegion on it. This method will handle a null value and not throw a NullPointerException.
        Parameters:
        rgn - the Region to write
        out - the DataInput to write to
        Throws:
        java.io.IOException - if a problem occurs while reading from in
      • readRegion

        public static <K,​V> Region<K,​V> readRegion​(java.io.DataInput in)
                                                        throws java.io.IOException,
                                                               java.lang.ClassNotFoundException
        Reads an instance of Region. A Region is serialized as a reference to a full path only. It is recreated on the other end by calling CacheFactory.getAnyInstance() and then calling getRegion on it. The return value may be null.
        Type Parameters:
        K - the type of keys in the region
        V - the type of values in the region
        Parameters:
        in - the input stream
        Returns:
        the Region instance
        Throws:
        CacheClosedException - if a cache has not been created or the only created one is closed.
        RegionNotFoundException - if there is no region by this name in the Cache
        java.io.IOException - if a problem occurs while reading from in
        java.lang.ClassNotFoundException - if the class of one of the Region's elements cannot be found.
      • writeDate

        public static void writeDate​(java.util.Date date,
                                     java.io.DataOutput out)
                              throws java.io.IOException
        Writes an instance of Date to a DataOutput. Note that even though date may be an instance of a subclass of Date, readDate will always return an instance of Date, not an instance of the subclass. To preserve the class type of date,\ writeObject(Object, DataOutput) should be used for data serialization. This method will handle a null value and not throw a NullPointerException.
        Parameters:
        date - the Date to write
        out - the DataInput to write to
        Throws:
        java.io.IOException - A problem occurs while writing to out
        See Also:
        readDate(java.io.DataInput)
      • readDate

        public static java.util.Date readDate​(java.io.DataInput in)
                                       throws java.io.IOException
        Reads an instance of Date from a DataInput. The return value may be null.
        Parameters:
        in - the DataInput to read from
        Returns:
        the deserialized Date
        Throws:
        java.io.IOException - A problem occurs while reading from in
      • writeFile

        public static void writeFile​(java.io.File file,
                                     java.io.DataOutput out)
                              throws java.io.IOException
        Writes an instance of File to a DataOutput. Note that even though file may be an instance of a subclass of File, readFile will always return an instance of File, not an instance of the subclass. To preserve the class type of file, writeObject(Object, DataOutput) should be used for data serialization. This method will handle a null value and not throw a NullPointerException.
        Parameters:
        file - the File to write
        out - the DataInput to write to
        Throws:
        java.io.IOException - A problem occurs while writing to out
        See Also:
        readFile(java.io.DataInput), File.getCanonicalPath()
      • readFile

        public static java.io.File readFile​(java.io.DataInput in)
                                     throws java.io.IOException
        Reads an instance of File from a DataInput. The return value may be null.
        Parameters:
        in - the DataInput to read from
        Returns:
        the deserialized File
        Throws:
        java.io.IOException - A problem occurs while reading from in
      • writeInetAddress

        public static void writeInetAddress​(java.net.InetAddress address,
                                            java.io.DataOutput out)
                                     throws java.io.IOException
        Writes an instance of InetAddress to a DataOutput. The InetAddress is data serialized by writing its byte representation to the DataOutput. readInetAddress(java.io.DataInput) converts the byte representation to an instance of InetAddress using InetAddress.getAddress(). As a result, if address is an instance of a user-defined subclass of InetAddress (that is, not an instance of one of the subclasses from the java.net package), its class will not be preserved. In order to be able to read an instance of the user-defined class, writeObject(Object, DataOutput) should be used. This method will handle a null value and not throw a NullPointerException.
        Parameters:
        address - the InetAddress to write
        out - the DataInput to write to
        Throws:
        java.io.IOException - A problem occurs while writing to out
        See Also:
        readInetAddress(java.io.DataInput)
      • readInetAddress

        public static java.net.InetAddress readInetAddress​(java.io.DataInput in)
                                                    throws java.io.IOException
        Reads an instance of InetAddress from a DataInput. The return value may be null.
        Parameters:
        in - the DataInput to read from
        Returns:
        the deserialized InetAddress
        Throws:
        java.io.IOException - A problem occurs while reading from in or the address read from in is unknown
        See Also:
        InetAddress.getAddress()
      • writeString

        public static void writeString​(java.lang.String value,
                                       java.io.DataOutput out)
                                throws java.io.IOException
        Writes an instance of String to a DataOutput. This method will handle a null value and not throw a NullPointerException.

        As of 5.7 strings longer than 0xFFFF can be serialized.

        Parameters:
        value - the String to write
        out - the DataInput to write to
        Throws:
        java.io.IOException - A problem occurs while writing to out
        See Also:
        readString(java.io.DataInput)
      • readString

        public static java.lang.String readString​(java.io.DataInput in)
                                           throws java.io.IOException
        Reads an instance of String from a DataInput. The return value may be null.
        Parameters:
        in - the DataInput to read from
        Returns:
        the deserialized String
        Throws:
        java.io.IOException - A problem occurs while reading from in
        See Also:
        writeString(java.lang.String, java.io.DataOutput)
      • writeBoolean

        public static void writeBoolean​(java.lang.Boolean value,
                                        java.io.DataOutput out)
                                 throws java.io.IOException
        Writes an instance of Boolean to a DataOutput.
        Parameters:
        value - the Boolean to write
        out - the DataInput to write to
        Throws:
        java.io.IOException - A problem occurs while writing to out
        java.lang.NullPointerException - if value is null.
        See Also:
        readBoolean(java.io.DataInput)
      • readBoolean

        public static java.lang.Boolean readBoolean​(java.io.DataInput in)
                                             throws java.io.IOException
        Reads an instance of Boolean from a DataInput.
        Parameters:
        in - the DataInput to read from
        Returns:
        the deserialized Boolean
        Throws:
        java.io.IOException - A problem occurs while reading from in
      • writeCharacter

        public static void writeCharacter​(java.lang.Character value,
                                          java.io.DataOutput out)
                                   throws java.io.IOException
        Writes an instance of Character to a DataOutput.
        Parameters:
        value - the Character to write
        out - the DataInput to write to
        Throws:
        java.io.IOException - A problem occurs while writing to out
        java.lang.NullPointerException - if value is null.
        See Also:
        readCharacter(java.io.DataInput)
      • readCharacter

        public static java.lang.Character readCharacter​(java.io.DataInput in)
                                                 throws java.io.IOException
        Reads an instance of Character from a DataInput.
        Parameters:
        in - the DataInput to read from
        Returns:
        the deserialized Character
        Throws:
        java.io.IOException - A problem occurs while reading from in
      • writeByte

        public static void writeByte​(java.lang.Byte value,
                                     java.io.DataOutput out)
                              throws java.io.IOException
        Writes an instance of Byte to a DataOutput.
        Parameters:
        value - the Byte to write
        out - the DataInput to write to
        Throws:
        java.io.IOException - A problem occurs while writing to out
        java.lang.NullPointerException - if value is null.
        See Also:
        readByte(java.io.DataInput)
      • readByte

        public static java.lang.Byte readByte​(java.io.DataInput in)
                                       throws java.io.IOException
        Reads an instance of Byte from a DataInput.
        Parameters:
        in - the DataInput to read from
        Returns:
        the deserialized Byte
        Throws:
        java.io.IOException - A problem occurs while reading from in
      • writeShort

        public static void writeShort​(java.lang.Short value,
                                      java.io.DataOutput out)
                               throws java.io.IOException
        Writes an instance of Short to a DataOutput.
        Parameters:
        value - the Short to write
        out - the DataInput to write to
        Throws:
        java.io.IOException - A problem occurs while writing to out
        java.lang.NullPointerException - if value is null.
        See Also:
        readShort(java.io.DataInput)
      • readShort

        public static java.lang.Short readShort​(java.io.DataInput in)
                                         throws java.io.IOException
        Reads an instance of Short from a DataInput.
        Parameters:
        in - the DataInput to read from
        Returns:
        the deserialized Short
        Throws:
        java.io.IOException - A problem occurs while reading from in
      • writeInteger

        public static void writeInteger​(java.lang.Integer value,
                                        java.io.DataOutput out)
                                 throws java.io.IOException
        Writes an instance of Integer to a DataOutput.
        Parameters:
        value - the Integer to write
        out - the DataInput to write to
        Throws:
        java.io.IOException - A problem occurs while writing to out
        java.lang.NullPointerException - if value is null.
        See Also:
        readInteger(java.io.DataInput)
      • readInteger

        public static java.lang.Integer readInteger​(java.io.DataInput in)
                                             throws java.io.IOException
        Reads an instance of Integer from a DataInput.
        Parameters:
        in - the DataInput to read from
        Returns:
        the deserialized Integer
        Throws:
        java.io.IOException - A problem occurs while reading from in
      • writeLong

        public static void writeLong​(java.lang.Long value,
                                     java.io.DataOutput out)
                              throws java.io.IOException
        Writes an instance of Long to a DataOutput.
        Parameters:
        value - the Long to write
        out - the DataInput to write to
        Throws:
        java.io.IOException - A problem occurs while writing to out
        java.lang.NullPointerException - if value is null.
        See Also:
        readLong(java.io.DataInput)
      • readLong

        public static java.lang.Long readLong​(java.io.DataInput in)
                                       throws java.io.IOException
        Reads an instance of Long from a DataInput.
        Parameters:
        in - the DataInput to read from
        Returns:
        the deserialized Long
        Throws:
        java.io.IOException - A problem occurs while reading from in
      • writeFloat

        public static void writeFloat​(java.lang.Float value,
                                      java.io.DataOutput out)
                               throws java.io.IOException
        Writes an instance of Float to a DataOutput.
        Parameters:
        value - the Float to write
        out - the DataInput to write to
        Throws:
        java.io.IOException - A problem occurs while writing to out
        java.lang.NullPointerException - if value is null.
        See Also:
        readFloat(java.io.DataInput)
      • readFloat

        public static java.lang.Float readFloat​(java.io.DataInput in)
                                         throws java.io.IOException
        Reads an instance of Float from a DataInput.
        Parameters:
        in - the DataInput to read from
        Returns:
        the deserialized Float
        Throws:
        java.io.IOException - A problem occurs while reading from in
      • writeDouble

        public static void writeDouble​(java.lang.Double value,
                                       java.io.DataOutput out)
                                throws java.io.IOException
        Writes an instance of Double to a DataOutput.
        Parameters:
        value - the Double to write
        out - the DataInput to write to
        Throws:
        java.io.IOException - A problem occurs while writing to out
        java.lang.NullPointerException - if value is null.
        See Also:
        readDouble(java.io.DataInput)
      • readDouble

        public static java.lang.Double readDouble​(java.io.DataInput in)
                                           throws java.io.IOException
        Reads an instance of Double from a DataInput.
        Parameters:
        in - the DataInput to read from
        Returns:
        the deserialized Double
        Throws:
        java.io.IOException - A problem occurs while reading from in
      • writePrimitiveBoolean

        public static void writePrimitiveBoolean​(boolean value,
                                                 java.io.DataOutput out)
                                          throws java.io.IOException
        Writes a primitive boolean to a DataOutput.
        Parameters:
        value - the primitive boolean to write
        out - the DataInput to write to
        Throws:
        java.io.IOException - A problem occurs while writing to out
        Since:
        GemFire 5.1
        See Also:
        DataOutput.writeBoolean(boolean)
      • readPrimitiveBoolean

        public static boolean readPrimitiveBoolean​(java.io.DataInput in)
                                            throws java.io.IOException
        Reads a primitive boolean from a DataInput.
        Parameters:
        in - the DataInput to read from
        Returns:
        the deserialized primitive boolean
        Throws:
        java.io.IOException - A problem occurs while reading from in
        Since:
        GemFire 5.1
        See Also:
        DataInput.readBoolean()
      • writePrimitiveByte

        public static void writePrimitiveByte​(byte value,
                                              java.io.DataOutput out)
                                       throws java.io.IOException
        Writes a primitive byte to a DataOutput.
        Parameters:
        value - the primitive byte to write
        out - the DataInput to write to
        Throws:
        java.io.IOException - A problem occurs while writing to out
        Since:
        GemFire 5.1
        See Also:
        DataOutput.writeByte(int)
      • readPrimitiveByte

        public static byte readPrimitiveByte​(java.io.DataInput in)
                                      throws java.io.IOException
        Reads a primitive byte from a DataInput.
        Parameters:
        in - the DataInput to read from
        Returns:
        the deserialized primitive byte
        Throws:
        java.io.IOException - A problem occurs while reading from in
        Since:
        GemFire 5.1
        See Also:
        DataInput.readByte()
      • writePrimitiveChar

        public static void writePrimitiveChar​(char value,
                                              java.io.DataOutput out)
                                       throws java.io.IOException
        Writes a primitive char to a DataOutput.
        Parameters:
        value - the primitive char to write
        out - the DataInput to write to
        Throws:
        java.io.IOException - A problem occurs while writing to out
        Since:
        GemFire 5.1
        See Also:
        DataOutput.writeChar(int)
      • readPrimitiveChar

        public static char readPrimitiveChar​(java.io.DataInput in)
                                      throws java.io.IOException
        Reads a primitive char from a DataInput.
        Parameters:
        in - the DataInput to read from
        Returns:
        the deserialized primitive char
        Throws:
        java.io.IOException - A problem occurs while reading from in
        Since:
        GemFire 5.1
        See Also:
        DataInput.readChar()
      • writePrimitiveShort

        public static void writePrimitiveShort​(short value,
                                               java.io.DataOutput out)
                                        throws java.io.IOException
        Writes a primitive short to a DataOutput.
        Parameters:
        value - the primitive short to write
        out - the DataInput to write to
        Throws:
        java.io.IOException - A problem occurs while writing to out
        Since:
        GemFire 5.1
        See Also:
        DataOutput.writeShort(int)
      • readPrimitiveShort

        public static short readPrimitiveShort​(java.io.DataInput in)
                                        throws java.io.IOException
        Reads a primitive short from a DataInput.
        Parameters:
        in - the DataInput to read from
        Returns:
        the deserialized primitive short
        Throws:
        java.io.IOException - A problem occurs while reading from in
        Since:
        GemFire 5.1
        See Also:
        DataInput.readShort()
      • writeUnsignedByte

        public static void writeUnsignedByte​(int value,
                                             java.io.DataOutput out)
                                      throws java.io.IOException
        Writes a primitive int as an unsigned byte to a DataOutput.
        Parameters:
        value - the primitive int as an unsigned byte to write
        out - the DataInput to write to
        Throws:
        java.io.IOException - A problem occurs while writing to out
        Since:
        GemFire 5.1
        See Also:
        DataOutput.writeByte(int), DataInput.readUnsignedByte()
      • readUnsignedByte

        public static int readUnsignedByte​(java.io.DataInput in)
                                    throws java.io.IOException
        Reads a primitive int as an unsigned byte from a DataInput using DataInput.readUnsignedByte().
        Parameters:
        in - the DataInput to read from
        Returns:
        the deserialized primitive int as an unsigned byte
        Throws:
        java.io.IOException - A problem occurs while reading from in
        Since:
        GemFire 5.1
      • writeUnsignedShort

        public static void writeUnsignedShort​(int value,
                                              java.io.DataOutput out)
                                       throws java.io.IOException
        Writes a primitive int as an unsigned short to a DataOutput.
        Parameters:
        value - the primitive int as an unsigned short to write
        out - the DataInput to write to
        Throws:
        java.io.IOException - A problem occurs while writing to out
        Since:
        GemFire 5.1
        See Also:
        DataOutput.writeShort(int), DataInput.readUnsignedShort()
      • readUnsignedShort

        public static int readUnsignedShort​(java.io.DataInput in)
                                     throws java.io.IOException
        Reads a primitive int as an unsigned short from a DataInput using DataInput.readUnsignedShort().
        Parameters:
        in - the DataInput to read from
        Returns:
        the deserialized primitive int as an unsigned short
        Throws:
        java.io.IOException - A problem occurs while reading from in
        Since:
        GemFire 5.1
      • writePrimitiveInt

        public static void writePrimitiveInt​(int value,
                                             java.io.DataOutput out)
                                      throws java.io.IOException
        Writes a primitive int to a DataOutput.
        Parameters:
        value - the primitive int to write
        out - the DataOutput to write to
        Throws:
        java.io.IOException - A problem occurs while writing to out
        See Also:
        DataOutput.writeInt(int)
      • readPrimitiveInt

        public static int readPrimitiveInt​(java.io.DataInput in)
                                    throws java.io.IOException
        Reads a primitive int from a DataInput.
        Parameters:
        in - the DataInput to read from
        Returns:
        a primitive int
        Throws:
        java.io.IOException - A problem occurs while reading from in
        Since:
        GemFire 5.1
        See Also:
        DataInput.readInt()
      • writePrimitiveLong

        public static void writePrimitiveLong​(long value,
                                              java.io.DataOutput out)
                                       throws java.io.IOException
        Writes a primitive long to a DataOutput.
        Parameters:
        value - the primitive long to write
        out - the DataOutput to write to
        Throws:
        java.io.IOException - A problem occurs while writing to out
        Since:
        GemFire 5.1
        See Also:
        DataOutput.writeLong(long)
      • readPrimitiveLong

        public static long readPrimitiveLong​(java.io.DataInput in)
                                      throws java.io.IOException
        Reads a primitive long from a DataInput.
        Parameters:
        in - the DataInput to read from
        Returns:
        a primitive long
        Throws:
        java.io.IOException - A problem occurs while reading from in
        Since:
        GemFire 5.1
        See Also:
        DataInput.readLong()
      • writePrimitiveFloat

        public static void writePrimitiveFloat​(float value,
                                               java.io.DataOutput out)
                                        throws java.io.IOException
        Writes a primitive float to a DataOutput.
        Parameters:
        value - the primitive float to write
        out - the DataOutput to write to
        Throws:
        java.io.IOException - A problem occurs while writing to out
        Since:
        GemFire 5.1
        See Also:
        DataOutput.writeFloat(float)
      • readPrimitiveFloat

        public static float readPrimitiveFloat​(java.io.DataInput in)
                                        throws java.io.IOException
        Reads a primitive float from a DataInput.
        Parameters:
        in - the DataInput to read from
        Returns:
        a primitive float
        Throws:
        java.io.IOException - A problem occurs while reading from in
        Since:
        GemFire 5.1
        See Also:
        DataInput.readFloat()
      • writePrimitiveDouble

        public static void writePrimitiveDouble​(double value,
                                                java.io.DataOutput out)
                                         throws java.io.IOException
        Writes a primtive double to a DataOutput.
        Parameters:
        value - the primitive double to write
        out - the DataOutput to write to
        Throws:
        java.io.IOException - A problem occurs while writing to out
        Since:
        GemFire 5.1
        See Also:
        DataOutput.writeDouble(double)
      • readPrimitiveDouble

        public static double readPrimitiveDouble​(java.io.DataInput in)
                                          throws java.io.IOException
        Reads a primitive double from a DataInput.
        Parameters:
        in - the DataInput to read from
        Returns:
        a primitive double
        Throws:
        java.io.IOException - A problem occurs while reading from in
        Since:
        GemFire 5.1
        See Also:
        DataInput.readDouble()
      • writeByteArray

        public static void writeByteArray​(byte[] array,
                                          java.io.DataOutput out)
                                   throws java.io.IOException
        Writes an array of bytes to a DataOutput. This method will serialize a null array and not throw a NullPointerException.
        Parameters:
        array - the array of bytes to write
        out - the DataOutput to write to
        Throws:
        java.io.IOException - A problem occurs while writing to out
        See Also:
        readByteArray(java.io.DataInput)
      • writeByteArray

        public static void writeByteArray​(byte[] array,
                                          int len,
                                          java.io.DataOutput out)
                                   throws java.io.IOException
        Writes the first len elements of an array of bytes to a DataOutput. This method will serialize a null array and not throw a NullPointerException.
        Parameters:
        array - the array of bytes to write
        len - the actual number of entries to write. If len is greater than then length of the
        out - the DataOutput to write to array then the entire array is written.
        Throws:
        java.io.IOException - A problem occurs while writing to out
        See Also:
        readByteArray(java.io.DataInput)
      • writeObjectAsByteArray

        public static void writeObjectAsByteArray​(java.lang.Object obj,
                                                  java.io.DataOutput out)
                                           throws java.io.IOException
        Serialize the given object obj into a byte array using writeObject(Object, DataOutput) and then writes the byte array to the given data output out in the same format writeByteArray(byte[], DataOutput) does. This method will serialize a null obj and not throw a NullPointerException.
        Parameters:
        obj - the object to serialize and write
        out - the data output to write the byte array to
        Throws:
        java.lang.IllegalArgumentException - if a problem occurs while serialize obj
        java.io.IOException - if a problem occurs while writing to out
        Since:
        GemFire 5.0.2
        See Also:
        readByteArray(java.io.DataInput)
      • readByteArray

        public static byte[] readByteArray​(java.io.DataInput in)
                                    throws java.io.IOException
        Reads an array of bytes from a DataInput.
        Parameters:
        in - the DataInput to read from
        Returns:
        the deserialized array of bytes
        Throws:
        java.io.IOException - A problem occurs while reading from in
        See Also:
        writeByteArray(byte[], DataOutput)
      • writeStringArray

        public static void writeStringArray​(java.lang.String[] array,
                                            java.io.DataOutput out)
                                     throws java.io.IOException
        Writes an array of Strings to a DataOutput. This method will serialize a null array and not throw a NullPointerException.
        Parameters:
        array - the array of Strings to write
        out - the DataInput to write to
        Throws:
        java.io.IOException - A problem occurs while writing to out
        See Also:
        readStringArray(java.io.DataInput), writeString(java.lang.String, java.io.DataOutput)
      • readStringArray

        public static java.lang.String[] readStringArray​(java.io.DataInput in)
                                                  throws java.io.IOException
        Reads an array of Strings from a DataInput.
        Parameters:
        in - the DataInput to read from
        Returns:
        the deserialized array of Strings
        Throws:
        java.io.IOException - A problem occurs while reading from in
        See Also:
        writeStringArray(java.lang.String[], java.io.DataOutput)
      • writeShortArray

        public static void writeShortArray​(short[] array,
                                           java.io.DataOutput out)
                                    throws java.io.IOException
        Writes an array of shorts to a DataOutput. This method will serialize a null array and not throw a NullPointerException.
        Parameters:
        array - the array of shorts to write
        out - the DataInput to write to
        Throws:
        java.io.IOException - A problem occurs while writing to out
        See Also:
        readShortArray(java.io.DataInput)
      • readShortArray

        public static short[] readShortArray​(java.io.DataInput in)
                                      throws java.io.IOException
        Reads an array of shorts from a DataInput.
        Parameters:
        in - the DataInput to read from
        Returns:
        the deserialized array of shorts
        Throws:
        java.io.IOException - A problem occurs while reading from in
        See Also:
        writeShortArray(short[], java.io.DataOutput)
      • writeCharArray

        public static void writeCharArray​(char[] array,
                                          java.io.DataOutput out)
                                   throws java.io.IOException
        Writes an array of chars to a DataOutput.
        Parameters:
        array - the array of chars to write
        out - the DataInput to write to
        Throws:
        java.io.IOException - A problem occurs while writing to out
        Since:
        GemFire 5.7
        See Also:
        readCharArray(java.io.DataInput)
      • readCharArray

        public static char[] readCharArray​(java.io.DataInput in)
                                    throws java.io.IOException
        Reads an array of chars from a DataInput.
        Parameters:
        in - the DataInput to read from
        Returns:
        the deserialized array of chars
        Throws:
        java.io.IOException - A problem occurs while reading from in
        Since:
        GemFire 5.7
        See Also:
        writeCharArray(char[], java.io.DataOutput)
      • writeBooleanArray

        public static void writeBooleanArray​(boolean[] array,
                                             java.io.DataOutput out)
                                      throws java.io.IOException
        Writes an array of booleans to a DataOutput.
        Parameters:
        array - the array of booleans to write
        out - the DataInput to write to
        Throws:
        java.io.IOException - A problem occurs while writing to out
        Since:
        GemFire 5.7
        See Also:
        readBooleanArray(java.io.DataInput)
      • readBooleanArray

        public static boolean[] readBooleanArray​(java.io.DataInput in)
                                          throws java.io.IOException
        Reads an array of booleans from a DataInput.
        Parameters:
        in - the DataInput to read from
        Returns:
        the deserialized array of booleans
        Throws:
        java.io.IOException - A problem occurs while reading from in
        Since:
        GemFire 5.7
        See Also:
        writeBooleanArray(boolean[], java.io.DataOutput)
      • writeIntArray

        public static void writeIntArray​(int[] array,
                                         java.io.DataOutput out)
                                  throws java.io.IOException
        Writes an int array to a DataOutput. This method will serialize a null array and not throw a NullPointerException.
        Parameters:
        array - the array of ints to write
        out - the DataInput to write to
        Throws:
        java.io.IOException - A problem occurs while writing to out
        See Also:
        readIntArray(java.io.DataInput)
      • readIntArray

        public static int[] readIntArray​(java.io.DataInput in)
                                  throws java.io.IOException
        Reads an int array from a DataInput.
        Parameters:
        in - the DataInput to read from
        Returns:
        the deserialized array of ints
        Throws:
        java.io.IOException - A problem occurs while reading from in
        See Also:
        writeIntArray(int[], java.io.DataOutput)
      • writeLongArray

        public static void writeLongArray​(long[] array,
                                          java.io.DataOutput out)
                                   throws java.io.IOException
        Writes an array of longs to a DataOutput. This method will serialize a null array and not throw a NullPointerException.
        Parameters:
        array - the array of longs to write
        out - the DataInput to write to
        Throws:
        java.io.IOException - A problem occurs while writing to out
        See Also:
        readLongArray(java.io.DataInput)
      • readLongArray

        public static long[] readLongArray​(java.io.DataInput in)
                                    throws java.io.IOException
        Reads an array of longs from a DataInput.
        Parameters:
        in - the DataInput to read from
        Returns:
        the deserialized array of longs
        Throws:
        java.io.IOException - A problem occurs while reading from in
        See Also:
        writeLongArray(long[], java.io.DataOutput)
      • writeFloatArray

        public static void writeFloatArray​(float[] array,
                                           java.io.DataOutput out)
                                    throws java.io.IOException
        Writes an array of floats to a DataOutput. This method will serialize a null array and not throw a NullPointerException.
        Parameters:
        array - the array of floats to write
        out - the DataInput to write to
        Throws:
        java.io.IOException - A problem occurs while writing to out
        See Also:
        readFloatArray(java.io.DataInput)
      • readFloatArray

        public static float[] readFloatArray​(java.io.DataInput in)
                                      throws java.io.IOException
        Reads an array of floats from a DataInput.
        Parameters:
        in - the DataInput to read from
        Returns:
        the deserialized array of floats
        Throws:
        java.io.IOException - A problem occurs while reading from in
        See Also:
        writeFloatArray(float[], java.io.DataOutput)
      • writeDoubleArray

        public static void writeDoubleArray​(double[] array,
                                            java.io.DataOutput out)
                                     throws java.io.IOException
        Writes an array of doubles to a DataOutput. This method will serialize a null array and not throw a NullPointerException.
        Parameters:
        array - the array of doubles to write
        out - the DataInput to write to
        Throws:
        java.io.IOException - A problem occurs while writing to out
        See Also:
        readDoubleArray(java.io.DataInput)
      • readDoubleArray

        public static double[] readDoubleArray​(java.io.DataInput in)
                                        throws java.io.IOException
        Reads an array of doubles from a DataInput.
        Parameters:
        in - the DataInput to read from
        Returns:
        the deserialized array of doubles
        Throws:
        java.io.IOException - A problem occurs while reading from in
        See Also:
        writeDoubleArray(double[], java.io.DataOutput)
      • writeObjectArray

        public static void writeObjectArray​(java.lang.Object[] array,
                                            java.io.DataOutput out)
                                     throws java.io.IOException
        Writes an array of Objects to a DataOutput. This method will serialize a null array and not throw a NullPointerException.
        Parameters:
        array - the array of Objects to write
        out - the DataInput to write to
        Throws:
        java.io.IOException - A problem occurs while writing to out
        See Also:
        readObjectArray(java.io.DataInput), writeObject(Object, DataOutput)
      • readObjectArray

        public static java.lang.Object[] readObjectArray​(java.io.DataInput in)
                                                  throws java.io.IOException,
                                                         java.lang.ClassNotFoundException
        Reads an array of Objects from a DataInput.
        Parameters:
        in - the DataInput to read from
        Returns:
        the deserialized array of Objects
        Throws:
        java.io.IOException - A problem occurs while reading from in
        java.lang.ClassNotFoundException - if the class of one of the array's elements cannot be found.
        See Also:
        writeObjectArray(java.lang.Object[], java.io.DataOutput), readObject(java.io.DataInput)
      • writeArrayOfByteArrays

        public static void writeArrayOfByteArrays​(byte[][] array,
                                                  java.io.DataOutput out)
                                           throws java.io.IOException
        Writes an array of byte[] to a DataOutput.
        Parameters:
        array - the array of byte[]s to write
        out - the DataInput to write to
        Throws:
        java.io.IOException - A problem occurs while writing to out.
      • readArrayOfByteArrays

        public static byte[][] readArrayOfByteArrays​(java.io.DataInput in)
                                              throws java.io.IOException
        Reads an array of byte[]s from a DataInput.
        Parameters:
        in - the DataInput to read from
        Returns:
        the deserialized array of byte[]s
        Throws:
        java.io.IOException - A problem occurs while reading from in
      • writeArrayList

        public static void writeArrayList​(java.util.ArrayList<?> list,
                                          java.io.DataOutput out)
                                   throws java.io.IOException
        Writes an ArrayList to a DataOutput. Note that even though list may be an instance of a subclass of ArrayList, readArrayList will always return an instance of ArrayList, not an instance of the subclass. To preserve the class type of list, writeObject(Object, DataOutput) should be used for data serialization. This method will serialize a null list and not throw a NullPointerException.
        Parameters:
        list - the ArrayList to write
        out - the DataInput to write to
        Throws:
        java.io.IOException - A problem occurs while writing to out
        See Also:
        readArrayList(java.io.DataInput)
      • readArrayList

        public static <E> java.util.ArrayList<E> readArrayList​(java.io.DataInput in)
                                                        throws java.io.IOException,
                                                               java.lang.ClassNotFoundException
        Reads an ArrayList from a DataInput.
        Type Parameters:
        E - – the type of elements in the list
        Parameters:
        in - the DataInput to read from
        Returns:
        the deserialized ArrayList
        Throws:
        java.io.IOException - A problem occurs while reading from in
        java.lang.ClassNotFoundException - The class of one of the ArrayList's elements cannot be found.
        See Also:
        writeArrayList(java.util.ArrayList<?>, java.io.DataOutput)
      • writeVector

        public static void writeVector​(java.util.Vector<?> list,
                                       java.io.DataOutput out)
                                throws java.io.IOException
        Writes an Vector to a DataOutput. Note that even though list may be an instance of a subclass of Vector, readVector will always return an instance of Vector, not an instance of the subclass. To preserve the class type of list, writeObject(Object, DataOutput) should be used for data serialization.
        Parameters:
        list - the Vector to write
        out - the DataInput to write to
        Throws:
        java.io.IOException - A problem occurs while writing to out
        Since:
        GemFire 5.7
        See Also:
        readVector(java.io.DataInput)
      • readVector

        public static <E> java.util.Vector<E> readVector​(java.io.DataInput in)
                                                  throws java.io.IOException,
                                                         java.lang.ClassNotFoundException
        Reads an Vector from a DataInput.
        Type Parameters:
        E - – the type of elements in the vector
        Parameters:
        in - the DataInput to read from
        Returns:
        the deserialized Vector
        Throws:
        java.io.IOException - A problem occurs while reading from in
        java.lang.ClassNotFoundException - The class of one of the Vector's elements cannot be found.
        Since:
        GemFire 5.7
        See Also:
        writeVector(java.util.Vector<?>, java.io.DataOutput)
      • writeStack

        public static void writeStack​(java.util.Stack<?> list,
                                      java.io.DataOutput out)
                               throws java.io.IOException
        Writes an Stack to a DataOutput. Note that even though list may be an instance of a subclass of Stack, readStack will always return an instance of Stack, not an instance of the subclass. To preserve the class type of list, writeObject(Object, DataOutput) should be used for data serialization.
        Parameters:
        list - the Stack to write
        out - the DataInput to write to
        Throws:
        java.io.IOException - A problem occurs while writing to out
        Since:
        GemFire 5.7
        See Also:
        readStack(java.io.DataInput)
      • readStack

        public static <E> java.util.Stack<E> readStack​(java.io.DataInput in)
                                                throws java.io.IOException,
                                                       java.lang.ClassNotFoundException
        Reads an Stack from a DataInput.
        Type Parameters:
        E - – the type of elements in the stack
        Parameters:
        in - the DataInput to read from
        Returns:
        the deserialized Stack
        Throws:
        java.io.IOException - A problem occurs while reading from in
        java.lang.ClassNotFoundException - The class of one of the Stack's elements cannot be found.
        Since:
        GemFire 5.7
        See Also:
        writeStack(java.util.Stack<?>, java.io.DataOutput)
      • writeLinkedList

        public static void writeLinkedList​(java.util.LinkedList<?> list,
                                           java.io.DataOutput out)
                                    throws java.io.IOException
        Writes an LinkedList to a DataOutput. Note that even though list may be an instance of a subclass of LinkedList, readLinkedList will always return an instance of LinkedList, not an instance of the subclass. To preserve the class type of list, writeObject(Object, DataOutput) should be used for data serialization. This method will serialize a null list and not throw a NullPointerException.
        Parameters:
        list - the LinkedList to write
        out - the DataInput to write to
        Throws:
        java.io.IOException - A problem occurs while writing to out
        See Also:
        readLinkedList(java.io.DataInput)
      • readLinkedList

        public static <E> java.util.LinkedList<E> readLinkedList​(java.io.DataInput in)
                                                          throws java.io.IOException,
                                                                 java.lang.ClassNotFoundException
        Reads an LinkedList from a DataInput.
        Type Parameters:
        E - – the type of elements in the list
        Parameters:
        in - the DataInput to read from
        Returns:
        the deserialized LinkedList
        Throws:
        java.io.IOException - A problem occurs while reading from in
        java.lang.ClassNotFoundException - The class of one of the LinkedList's elements cannot be found.
        See Also:
        writeLinkedList(java.util.LinkedList<?>, java.io.DataOutput)
      • writeHashSet

        public static void writeHashSet​(java.util.HashSet<?> set,
                                        java.io.DataOutput out)
                                 throws java.io.IOException
        Writes a HashSet to a DataOutput. Note that even though set may be an instance of a subclass of HashSet, readHashSet will always return an instance of HashSet, not an instance of the subclass. To preserve the class type of set, writeObject(Object, DataOutput) should be used for data serialization. This method will serialize a null set and not throw a NullPointerException.
        Parameters:
        set - the HashSet to write
        out - the DataInput to write to
        Throws:
        java.io.IOException - A problem occurs while writing to out
        See Also:
        readHashSet(java.io.DataInput)
      • readHashSet

        public static <E> java.util.HashSet<E> readHashSet​(java.io.DataInput in)
                                                    throws java.io.IOException,
                                                           java.lang.ClassNotFoundException
        Reads a HashSet from a DataInput.
        Type Parameters:
        E - – the type of elements in the set
        Parameters:
        in - the DataInput to read from
        Returns:
        the deserialized HashSet
        Throws:
        java.io.IOException - A problem occurs while reading from in
        java.lang.ClassNotFoundException - The class of one of the HashSet's elements cannot be found.
        See Also:
        writeHashSet(java.util.HashSet<?>, java.io.DataOutput)
      • writeLinkedHashSet

        public static void writeLinkedHashSet​(java.util.LinkedHashSet<?> set,
                                              java.io.DataOutput out)
                                       throws java.io.IOException
        Writes a LinkedHashSet to a DataOutput. Note that even though set may be an instance of a subclass of LinkedHashSet, readLinkedHashSet will always return an instance of LinkedHashSet, not an instance of the subclass. To preserve the class type of set, writeObject(Object, DataOutput) should be used for data serialization.
        Parameters:
        set - the LinkedHashSet to write
        out - the DataInput to write to
        Throws:
        java.io.IOException - A problem occurs while writing to out
        Since:
        GemFire 5.7
        See Also:
        readLinkedHashSet(java.io.DataInput)
      • readLinkedHashSet

        public static <E> java.util.LinkedHashSet<E> readLinkedHashSet​(java.io.DataInput in)
                                                                throws java.io.IOException,
                                                                       java.lang.ClassNotFoundException
        Reads a LinkedHashSet from a DataInput.
        Type Parameters:
        E - – the type of elements in the set
        Parameters:
        in - the DataInput to read from
        Returns:
        the deserialized LinkedHashSet
        Throws:
        java.io.IOException - A problem occurs while reading from in
        java.lang.ClassNotFoundException - The class of one of the LinkedHashSet's elements cannot be found.
        Since:
        GemFire 5.7
        See Also:
        writeLinkedHashSet(java.util.LinkedHashSet<?>, java.io.DataOutput)
      • writeHashMap

        public static void writeHashMap​(java.util.Map<?,​?> map,
                                        java.io.DataOutput out)
                                 throws java.io.IOException
        Writes a HashMap to a DataOutput. Note that even though map may be an instance of a subclass of HashMap, readHashMap will always return an instance of HashMap, not an instance of the subclass. To preserve the class type of map, writeObject(Object, DataOutput) should be used for data serialization. This method will serialize a null map and not throw a NullPointerException.
        Parameters:
        map - the HashMap to write
        out - the DataInput to write to
        Throws:
        java.io.IOException - A problem occurs while writing to out
        See Also:
        readHashMap(java.io.DataInput)
      • readHashMap

        public static <K,​V> java.util.HashMap<K,​V> readHashMap​(java.io.DataInput in)
                                                                    throws java.io.IOException,
                                                                           java.lang.ClassNotFoundException
        Reads a HashMap from a DataInput.
        Type Parameters:
        K - – the type of keys in the map
        V - – the type of mapped values
        Parameters:
        in - the DataInput to read from
        Returns:
        the deserialized HashMap
        Throws:
        java.io.IOException - A problem occurs while reading from in
        java.lang.ClassNotFoundException - The class of one of the HashMap's elements cannot be found.
        See Also:
        writeHashMap(java.util.Map<?, ?>, java.io.DataOutput)
      • writeIdentityHashMap

        public static void writeIdentityHashMap​(java.util.IdentityHashMap<?,​?> map,
                                                java.io.DataOutput out)
                                         throws java.io.IOException
        Writes a IdentityHashMap to a DataOutput. Note that even though map may be an instance of a subclass of IdentityHashMap, readIdentityHashMap will always return an instance of IdentityHashMap, not an instance of the subclass. To preserve the class type of map, writeObject(Object, DataOutput) should be used for data serialization.
        Parameters:
        map - the IdentityHashMap to write
        out - the DataInput to write to
        Throws:
        java.io.IOException - A problem occurs while writing to out
        See Also:
        readIdentityHashMap(java.io.DataInput)
      • readIdentityHashMap

        public static <K,​V> java.util.IdentityHashMap<K,​V> readIdentityHashMap​(java.io.DataInput in)
                                                                                    throws java.io.IOException,
                                                                                           java.lang.ClassNotFoundException
        Reads a IdentityHashMap from a DataInput. Note that key identity is not preserved unless the keys belong to a class whose serialization preserves identity.
        Type Parameters:
        K - – the type of keys in the map
        V - – the type of mapped values
        Parameters:
        in - the DataInput to read from
        Returns:
        the deserialized IdentityHashMap
        Throws:
        java.io.IOException - A problem occurs while reading from in
        java.lang.ClassNotFoundException - The class of one of the IdentityHashMap's elements cannot be found.
        See Also:
        writeIdentityHashMap(java.util.IdentityHashMap<?, ?>, java.io.DataOutput)
      • writeConcurrentHashMap

        public static void writeConcurrentHashMap​(java.util.concurrent.ConcurrentHashMap<?,​?> map,
                                                  java.io.DataOutput out)
                                           throws java.io.IOException
        Writes a ConcurrentHashMap to a DataOutput. Note that even though map may be an instance of a subclass of ConcurrentHashMap, readConcurrentHashMap will always return an instance of ConcurrentHashMap, not an instance of the subclass. To preserve the class type of map, writeObject(Object, DataOutput) should be used for data serialization.

        At this time if writeObject(Object, DataOutput) is called with an instance of ConcurrentHashMap then it will be serialized with normal java.io Serialization. So if you want the keys and values of a ConcurrentHashMap to take advantage of GemFire serialization it must be serialized with this method.

        Parameters:
        map - the ConcurrentHashMap to write
        out - the DataInput to write to
        Throws:
        java.io.IOException - A problem occurs while writing to out
        Since:
        GemFire 6.6
        See Also:
        readConcurrentHashMap(java.io.DataInput)
      • readConcurrentHashMap

        public static <K,​V> java.util.concurrent.ConcurrentHashMap<K,​V> readConcurrentHashMap​(java.io.DataInput in)
                                                                                                   throws java.io.IOException,
                                                                                                          java.lang.ClassNotFoundException
        Reads a ConcurrentHashMap from a DataInput.
        Type Parameters:
        K - – the type of keys in the map
        V - – the type of mapped values
        Parameters:
        in - the DataInput to read from
        Returns:
        the deserialized ConcurrentHashMap
        Throws:
        java.io.IOException - A problem occurs while reading from in
        java.lang.ClassNotFoundException - The class of one of the ConcurrentHashMap's elements cannot be found.
        Since:
        GemFire 6.6
        See Also:
        writeConcurrentHashMap(java.util.concurrent.ConcurrentHashMap<?, ?>, java.io.DataOutput)
      • writeHashtable

        public static void writeHashtable​(java.util.Hashtable<?,​?> map,
                                          java.io.DataOutput out)
                                   throws java.io.IOException
        Writes a Hashtable to a DataOutput. Note that even though map may be an instance of a subclass of Hashtable, readHashtable will always return an instance of Hashtable, not an instance of the subclass. To preserve the class type of map, writeObject(Object, DataOutput) should be used for data serialization.
        Parameters:
        map - the Hashtable to write
        out - the DataInput to write to
        Throws:
        java.io.IOException - A problem occurs while writing to out
        Since:
        GemFire 5.7
        See Also:
        readHashtable(java.io.DataInput)
      • readHashtable

        public static <K,​V> java.util.Hashtable<K,​V> readHashtable​(java.io.DataInput in)
                                                                        throws java.io.IOException,
                                                                               java.lang.ClassNotFoundException
        Reads a Hashtable from a DataInput.
        Type Parameters:
        K - – the type of keys in the hashtable
        V - – the type of values in the hashtable
        Parameters:
        in - the DataInput to read from
        Returns:
        the deserialized Hashtable
        Throws:
        java.io.IOException - A problem occurs while reading from in
        java.lang.ClassNotFoundException - The class of one of the Hashtable's elements cannot be found.
        Since:
        GemFire 5.7
        See Also:
        writeHashtable(java.util.Hashtable<?, ?>, java.io.DataOutput)
      • writeTreeMap

        public static void writeTreeMap​(java.util.TreeMap<?,​?> map,
                                        java.io.DataOutput out)
                                 throws java.io.IOException
        Writes a TreeMap to a DataOutput. Note that even though map may be an instance of a subclass of TreeMap, readTreeMap will always return an instance of TreeMap, not an instance of the subclass. To preserve the class type of map, writeObject(Object, DataOutput) should be used for data serialization.

        If the map has a comparator then it must also be serializable.

        Parameters:
        map - the TreeMap to write
        out - the DataInput to write to
        Throws:
        java.io.IOException - A problem occurs while writing to out
        Since:
        GemFire 5.7
        See Also:
        readTreeMap(java.io.DataInput)
      • readTreeMap

        public static <K,​V> java.util.TreeMap<K,​V> readTreeMap​(java.io.DataInput in)
                                                                    throws java.io.IOException,
                                                                           java.lang.ClassNotFoundException
        Reads a TreeMap from a DataInput.
        Type Parameters:
        K - – the type of keys in the map
        V - – the type of mapped values
        Parameters:
        in - the DataInput to read from
        Returns:
        the deserialized TreeMap
        Throws:
        java.io.IOException - A problem occurs while reading from in
        java.lang.ClassNotFoundException - The class of one of the TreeMap's elements cannot be found.
        Since:
        GemFire 5.7
        See Also:
        writeTreeMap(java.util.TreeMap<?, ?>, java.io.DataOutput)
      • writeLinkedHashMap

        public static void writeLinkedHashMap​(java.util.Map<?,​?> map,
                                              java.io.DataOutput out)
                                       throws java.io.IOException
        Writes a LinkedHashMap to a DataOutput. Note that even though map may be an instance of a subclass of LinkedHashMap, readLinkedHashMap will always return an instance of LinkedHashMap, not an instance of the subclass. To preserve the class type of map, writeObject(Object, DataOutput) should be used for data serialization. This method will serialize a null map and not throw a NullPointerException.
        Parameters:
        map - the LinkedHashMap to write
        out - the DataInput to write to
        Throws:
        java.io.IOException - A problem occurs while writing to out
        See Also:
        readLinkedHashMap(java.io.DataInput)
      • readLinkedHashMap

        public static <K,​V> java.util.LinkedHashMap<K,​V> readLinkedHashMap​(java.io.DataInput in)
                                                                                throws java.io.IOException,
                                                                                       java.lang.ClassNotFoundException
        Reads a LinkedHashMap from a DataInput.
        Type Parameters:
        K - – the type of keys in the map
        V - – the type of mapped values
        Parameters:
        in - the DataInput to read from
        Returns:
        the deserialized LinkedHashMap
        Throws:
        java.io.IOException - A problem occurs while reading from in
        java.lang.ClassNotFoundException - The class of one of the HashMap's elements cannot be found.
        See Also:
        writeLinkedHashMap(java.util.Map<?, ?>, java.io.DataOutput)
      • writeTreeSet

        public static void writeTreeSet​(java.util.TreeSet<?> set,
                                        java.io.DataOutput out)
                                 throws java.io.IOException
        Writes a TreeSet to a DataOutput. Note that even though set may be an instance of a subclass of TreeSet, readTreeSet will always return an instance of TreeSet, not an instance of the subclass. To preserve the class type of set, writeObject(Object, DataOutput) should be used for data serialization.

        If the set has a comparator then it must also be serializable.

        Parameters:
        set - the TreeSet to write
        out - the DataInput to write to
        Throws:
        java.io.IOException - A problem occurs while writing to out
        See Also:
        readTreeSet(java.io.DataInput)
      • readTreeSet

        public static <E> java.util.TreeSet<E> readTreeSet​(java.io.DataInput in)
                                                    throws java.io.IOException,
                                                           java.lang.ClassNotFoundException
        Reads a TreeSet from a DataInput.
        Type Parameters:
        E - the type contained in the TreeSet
        Parameters:
        in - the DataInput to read from
        Returns:
        the deserialized TreeSet
        Throws:
        java.io.IOException - A problem occurs while reading from in
        java.lang.ClassNotFoundException - The class of one of the TreeSet's elements cannot be found.
        See Also:
        writeTreeSet(java.util.TreeSet<?>, java.io.DataOutput)
      • writeProperties

        public static void writeProperties​(java.util.Properties props,
                                           java.io.DataOutput out)
                                    throws java.io.IOException
        Writes a Properties to a DataOutput.

        NOTE: The defaults of the specified props are not serialized.

        Note that even though props may be an instance of a subclass of Properties, readProperties will always return an instance of Properties, not an instance of the subclass. To preserve the class type of props, writeObject(Object, DataOutput) should be used for data serialization.

        Parameters:
        props - the Properties to write
        out - the DataInput to write to
        Throws:
        java.io.IOException - A problem occurs while writing to out
        See Also:
        readProperties(java.io.DataInput)
      • readProperties

        public static java.util.Properties readProperties​(java.io.DataInput in)
                                                   throws java.io.IOException,
                                                          java.lang.ClassNotFoundException
        Reads a Properties from a DataInput.

        NOTE: the defaults are always empty in the returned Properties.

        Parameters:
        in - the DataInput to read from
        Returns:
        the deserialized Properties
        Throws:
        java.io.IOException - If this serializer cannot read an object from in.
        java.lang.ClassNotFoundException - If the class cannot be loaded
        See Also:
        writeProperties(java.util.Properties, java.io.DataOutput)
      • writeObject

        public static void writeObject​(java.lang.Object o,
                                       java.io.DataOutput out,
                                       boolean allowJavaSerialization)
                                throws java.io.IOException
        Writes an arbitrary object to a DataOutput. If o is not an instance of a specially-handled standard Java class (see the list in getSupportedClasses()), the toData method of each registered DataSerializer is invoked until the object is serialized. If no registered serializer can serialize the object and o does not implement DataSerializable, then it is serialized to out using standard Java serialization. This method will serialize a null o and not throw a NullPointerException.
        Parameters:
        o - the object to write
        out - the DataOutput to write to
        allowJavaSerialization - If false, then a NotSerializableException is thrown in the case where standard Java serialization would otherwise be used for object o or for any nested subobject of o. This is used to prevent Java serialization from being used when sending data to a non-Java client
        Throws:
        java.io.IOException - A problem occurs while writing o to out
        See Also:
        readObject(DataInput), Instantiator, ObjectOutputStream.writeObject(java.lang.Object)
      • writeObject

        public static void writeObject​(java.lang.Object o,
                                       java.io.DataOutput out)
                                throws java.io.IOException
        Writes an arbitrary object to a DataOutput. If o is not an instance of a specially-handled standard Java class (such as Date, Integer, or ArrayList), the toData method of each registered DataSerializer is invoked until the object is serialized. If no registered serializer can serialize the object and o does not implement DataSerializable, then it is serialized to out using standard Java serialization. This method will serialize a null o and not throw a NullPointerException.
        Parameters:
        o - the object to write
        out - the DataOutput to write to
        Throws:
        java.io.IOException - A problem occurs while writing o to out
        See Also:
        readObject(DataInput), DataSerializer, ObjectOutputStream.writeObject(java.lang.Object)
      • readObject

        public static <T> T readObject​(java.io.DataInput in)
                                throws java.io.IOException,
                                       java.lang.ClassNotFoundException
        Reads an arbitrary object from a DataInput. Instances of classes that are not handled specially (such as String, Class, and DataSerializable) are read using standard Java serialization.

        Note that if an object is deserialized using standard Java serialization, its class will be loaded using the current thread's context class loader before the one normally used by Java serialization is consulted.

        Type Parameters:
        T - the type of the Object to read
        Parameters:
        in - the DataInput to read from
        Returns:
        an arbitrary deserialized object
        Throws:
        java.io.IOException - A problem occurred while reading from in (may wrap another exception)
        java.lang.ClassNotFoundException - The class of an object read from in could not be found
        See Also:
        writeObject(Object, DataOutput), ObjectInputStream.readObject()
      • register

        public static DataSerializer register​(java.lang.Class<?> c)
        Registers a DataSerializer class with the data serialization framework. This method uses reflection to create an instance of the DataSerializer class by invoking its zero-argument constructor.

        The DataSerializer instance will be consulted by the writeObject(Object, DataOutput) and readObject(java.io.DataInput) methods. Note that no two serializers can support the same class.

        This method invokes the DataSerializer instance's getSupportedClasses() method and keeps track of which classes can have their instances serialized by by this data serializer.

        Parameters:
        c - the DataSerializer class to create and register with the data serialization framework.
        Returns:
        the registered serializer instance
        Throws:
        java.lang.IllegalArgumentException - If c does not subclass DataSerializer, if c does not have a zero-argument constructor, if id is 0, if getSupportedClasses returns null or an empty array, if getSupportedClasses returns and array with null elements
        java.lang.IllegalStateException - if another serializer instance with id id has already been registered, if another serializer instance that supports one of this instances classes has already been registered, if an attempt is made to support any of the classes reserved by DataSerializer (see getSupportedClasses() for a list).
        See Also:
        getSupportedClasses()
      • getSupportedClasses

        public abstract java.lang.Class<?>[] getSupportedClasses()
        Returns the Classes whose instances are data serialized by this DataSerializer. This method is invoked when this serializer is registered. This method is not allowed to return null nor an empty array. Only instances whose class name is the same as one of the class names in the result will be serialized by this DataSerializer. Two DataSerializers are not allowed to support the same class. The following classes can not be supported by user defined data serializers since they are all supported by the predefined data serializer:
        • Class
        • String
        • Boolean
        • Byte
        • Character
        • Short
        • Integer
        • Long
        • Float
        • Double
        • File
        • InetAddress
        • Inet4Address
        • Inet6Address
        • ArrayList
        • Date
        • HashMap
        • IdentityHashMap
        • HashSet
        • Hashtable
        • LinkedHashSet
        • LinkedList
        • Properties
        • TreeMap
        • TreeSet
        • Vector
        • any array class
        Returns:
        the Classes whose instances are data serialized by this DataSerializer
      • toData

        public abstract boolean toData​(java.lang.Object o,
                                       java.io.DataOutput out)
                                throws java.io.IOException
        Data serializes an object to a DataOutput. It is very important that when performing the "switch" on o's class, your code test for a subclass before it tests for a superclass. Otherwise, the incorrect class id could be written to the serialization stream.
        Parameters:
        o - The object to data serialize. It will never be null.
        out - the DataInput to write to
        Returns:
        false if this DataSerializer does not know how to data serialize o.
        Throws:
        java.io.IOException - If this serializer cannot write an object to out.
      • fromData

        public abstract java.lang.Object fromData​(java.io.DataInput in)
                                           throws java.io.IOException,
                                                  java.lang.ClassNotFoundException
        Reads an object from a DataInput. This implementation must support deserializing everything serialized by the matching toData(java.lang.Object, java.io.DataOutput).
        Parameters:
        in - the DataInput to write to
        Returns:
        the deserialized Object
        Throws:
        java.io.IOException - If this serializer cannot read an object from in.
        java.lang.ClassNotFoundException - If the class cannot be loaded
        See Also:
        toData(java.lang.Object, java.io.DataOutput)
      • getId

        public abstract int getId()
        Returns the id of this DataSerializer.

        Returns an int instead of a byte

        Returns:
        the id of this DataSerializer
        Since:
        5.7.
      • equals

        public boolean equals​(java.lang.Object o)
        Two DataSerializers are consider to be equal if they have the same id and the same class
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • setEventId

        public void setEventId​(java.lang.Object eventId)
        For internal use only. Sets the unique eventId of this DataSerializer.
        Parameters:
        eventId - the unique eventId of this DataSerializer
        Since:
        GemFire 6.5
      • getEventId

        public java.lang.Object getEventId()
        For internal use only. Returns the unique eventId of this DataSerializer.
        Returns:
        the unique eventId of this DataSerializer
        Since:
        GemFire 6.5
      • setContext

        public void setContext​(java.lang.Object context)
        For internal use only. Sets the context of this DataSerializer.
        Parameters:
        context - the context of this DataSerializer
        Since:
        GemFire 6.5
      • getContext

        public java.lang.Object getContext()
        For internal use only. Returns the context of this DataSerializer.
        Returns:
        the context of this DataSerializer
        Since:
        GemFire 6.5
      • writeEnum

        public static void writeEnum​(java.lang.Enum<?> e,
                                     java.io.DataOutput out)
                              throws java.io.IOException
        Writes the Enum constant to DataOutput. Unlike standard java serialization which serializes both the enum name String and the ordinal, GemFire only serializes the ordinal byte, so for backward compatibility new enum constants should only be added to the end of the enum type.
        Example: DataSerializer.writeEnum(DAY_OF_WEEK.SUN, out);
        Parameters:
        e - the Enum to serialize
        out - the DataInput to write to
        Throws:
        java.io.IOException - if a problem occurs while writing to out
        Since:
        GemFire 6.5
        See Also:
        readEnum(Class, DataInput)
      • readEnum

        public static <E extends java.lang.Enum<E>> E readEnum​(java.lang.Class<E> clazz,
                                                               java.io.DataInput in)
                                                        throws java.io.IOException
        Reads a Enum constant from DataInput. Unlike standard java serialization which serializes both the enum name String and the ordinal, GemFire only serializes the ordinal byte, so be careful about using the correct enum class. Also, for backward compatibility new enum constants should only be added to the end of the enum type.
        Example: DAY_OF_WEEK d = DataSerializer.readEnum(DAY_OF_WEEK.class, in);
        Type Parameters:
        E - the type of Enum
        Parameters:
        clazz - the Enum class to deserialize to
        in - the DataInput to read from
        Returns:
        the deserialized Enum
        Throws:
        java.io.IOException - if a problem occurs while reading from in
        java.lang.ArrayIndexOutOfBoundsException - if the wrong enum class/enum class with a different version and less enum constants is used
        Since:
        GemFire 6.5
        See Also:
        writeEnum(Enum, DataOutput)