Class FormatableArrayHolder

  • All Implemented Interfaces:
    java.io.Externalizable, java.io.Serializable, Formatable, TypedFormat

    public class FormatableArrayHolder
    extends java.lang.Object
    implements Formatable
    A formatable holder for an array of formatables. Used to avoid serializing arrays.
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.Object[] array
      This class implements Formatable.
    • Constructor Summary

      Constructors 
      Constructor Description
      FormatableArrayHolder()
      Niladic constructor for formatable
      FormatableArrayHolder​(java.lang.Object[] array)
      Construct a FormatableArrayHolder using the input array.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      <E> E[] getArray​(java.lang.Class<E[]> arrayClass)
      Get the held array of formatables, and return it in an array that is an instance of arrayClass.
      int getTypeFormatId()
      Get the formatID which corresponds to this class.
      void readExternal​(java.io.ObjectInput in)
      Read this array from a stream of stored objects.
      void setArray​(java.lang.Object[] array)
      Set the held array to the input array.
      void writeExternal​(java.io.ObjectOutput out)
      Write this array out
      • Methods inherited from class java.lang.Object

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

      • array

        private java.lang.Object[] array
        This class implements Formatable. That means that it can write itself to and from a formatted stream. If you add more fields to this class, make sure that you also write/read them with the writeExternal()/readExternal() methods. If, inbetween releases, you add more fields to this class, then you should bump the version number emitted by the getTypeFormatId() method.
    • Constructor Detail

      • FormatableArrayHolder

        public FormatableArrayHolder()
        Niladic constructor for formatable
      • FormatableArrayHolder

        public FormatableArrayHolder​(java.lang.Object[] array)
        Construct a FormatableArrayHolder using the input array.
        Parameters:
        array - the array to hold
    • Method Detail

      • setArray

        public void setArray​(java.lang.Object[] array)
        Set the held array to the input array.
        Parameters:
        array - the array to hold
      • getArray

        public <E> E[] getArray​(java.lang.Class<E[]> arrayClass)
        Get the held array of formatables, and return it in an array that is an instance of arrayClass.
        Parameters:
        arrayClass - the type of array to return
        Returns:
        an array of formatables
      • writeExternal

        public void writeExternal​(java.io.ObjectOutput out)
                           throws java.io.IOException
        Write this array out
        Specified by:
        writeExternal in interface java.io.Externalizable
        Parameters:
        out - write bytes here
        Throws:
        java.io.IOException - thrown on error
      • readExternal

        public void readExternal​(java.io.ObjectInput in)
                          throws java.io.IOException,
                                 java.lang.ClassNotFoundException
        Read this array from a stream of stored objects.
        Specified by:
        readExternal in interface java.io.Externalizable
        Parameters:
        in - read this.
        Throws:
        java.io.IOException - thrown on error
        java.lang.ClassNotFoundException - thrown on error
      • getTypeFormatId

        public int getTypeFormatId()
        Get the formatID which corresponds to this class.
        Specified by:
        getTypeFormatId in interface TypedFormat
        Returns:
        the formatID of this class