Class PofBufferWriter

    • Field Detail

      • m_ctx

        protected PofContext m_ctx
        The PofContext used by this PofBufferWriter to serialize user types.
      • m_fEvolvable

        protected boolean m_fEvolvable
        Indicate if the object to be written is either Evolvable or part of an Evolvable object.
      • m_handler

        protected WritingPofHandler m_handler
        The WritingPofHandler used to write a POF stream.
    • Constructor Detail

      • PofBufferWriter

        public PofBufferWriter​(WriteBuffer.BufferOutput out,
                               PofContext ctx)
        Construct a new PofBufferWriter that will write a POF stream to the passed BufferOutput object.
        Parameters:
        out - the BufferOutput object to write to; must not be null
        ctx - the PofContext used by the new PofBufferWriter to serialize user types; must not be null
      • PofBufferWriter

        public PofBufferWriter​(WritingPofHandler handler,
                               PofContext ctx)
        Construct a new PofBufferWriter that will write a POF stream using the passed WritingPofHandler.
        Parameters:
        handler - the WritingPofHandler used for writing; must not be null
        ctx - the PofContext used by the new PofBufferWriter to serialize user types; must not be null
    • Method Detail

      • writeBoolean

        public void writeBoolean​(int iProp,
                                 boolean f)
                          throws IOException
        Write a boolean property to the POF stream.
        Specified by:
        writeBoolean in interface PofWriter
        Parameters:
        iProp - the property index
        f - the boolean property value to write
        Throws:
        IOException - if an I/O error occurs
      • writeBoolean

        protected void writeBoolean​(int iProp,
                                    boolean f,
                                    boolean fReferenceable)
                             throws IOException
        Write a boolean property to the POF stream.
        Parameters:
        iProp - the property index
        f - the boolean property value to write
        fReferenceable - true if the property value is a referenceable type
        Throws:
        IllegalArgumentException - if the property index is invalid, or is less than or equal to the index of the previous property written to the POF stream
        IOException - if an I/O error occurs
      • writeByte

        public void writeByte​(int iProp,
                              byte b)
                       throws IOException
        Write a byte property to the POF stream.
        Specified by:
        writeByte in interface PofWriter
        Parameters:
        iProp - the property index
        b - the byte property value to write
        Throws:
        IOException - if an I/O error occurs
      • writeByte

        protected void writeByte​(int iProp,
                                 byte b,
                                 boolean fReferenceable)
                          throws IOException
        Write a byte property to the POF stream.
        Parameters:
        iProp - the property index
        b - the byte property value to write
        fReferenceable - true if the property value is a referenceable type
        Throws:
        IllegalArgumentException - if the property index is invalid, or is less than or equal to the index of the previous property written to the POF stream
        IOException - if an I/O error occurs
      • writeChar

        public void writeChar​(int iProp,
                              char ch)
                       throws IOException
        Write a char property to the POF stream.
        Specified by:
        writeChar in interface PofWriter
        Parameters:
        iProp - the property index
        ch - the char property value to write
        Throws:
        IOException - if an I/O error occurs
      • writeChar

        protected void writeChar​(int iProp,
                                 char ch,
                                 boolean fReferenceable)
                          throws IOException
        Write a char property to the POF stream.
        Parameters:
        iProp - the property index
        ch - the char property value to write
        fReferenceable - true if the property value is a referenceable type
        Throws:
        IllegalArgumentException - if the property index is invalid, or is less than or equal to the index of the previous property written to the POF stream
        IOException - if an I/O error occurs
      • writeShort

        public void writeShort​(int iProp,
                               short n)
                        throws IOException
        Write a short property to the POF stream.
        Specified by:
        writeShort in interface PofWriter
        Parameters:
        iProp - the property index
        n - the short property value to write
        Throws:
        IOException - if an I/O error occurs
      • writeShort

        protected void writeShort​(int iProp,
                                  short n,
                                  boolean fReferenceable)
                           throws IOException
        Write a short property to the POF stream.
        Parameters:
        iProp - the property index
        n - the short property value to write
        fReferenceable - true if the property value is a referenceable type
        Throws:
        IllegalArgumentException - if the property index is invalid, or is less than or equal to the index of the previous property written to the POF stream
        IOException - if an I/O error occurs
      • writeInt

        public void writeInt​(int iProp,
                             int n)
                      throws IOException
        Write a int property to the POF stream.
        Specified by:
        writeInt in interface PofWriter
        Parameters:
        iProp - the property index
        n - the int property value to write
        Throws:
        IOException - if an I/O error occurs
      • writeInt

        protected void writeInt​(int iProp,
                                int n,
                                boolean fReferenceable)
                         throws IOException
        Write a int property to the POF stream.
        Parameters:
        iProp - the property index
        n - the int property value to write
        fReferenceable - true if the property value is a referenceable type
        Throws:
        IllegalArgumentException - if the property index is invalid, or is less than or equal to the index of the previous property written to the POF stream
        IOException - if an I/O error occurs
      • writeLong

        public void writeLong​(int iProp,
                              long n)
                       throws IOException
        Write a long property to the POF stream.
        Specified by:
        writeLong in interface PofWriter
        Parameters:
        iProp - the property index
        n - the long property value to write
        Throws:
        IOException - if an I/O error occurs
      • writeLong

        protected void writeLong​(int iProp,
                                 long n,
                                 boolean fReferenceable)
                          throws IOException
        Write a long property to the POF stream.
        Parameters:
        iProp - the property index
        n - the long property value to write
        fReferenceable - true if the property value is a referenceable type
        Throws:
        IllegalArgumentException - if the property index is invalid, or is less than or equal to the index of the previous property written to the POF stream
        IOException - if an I/O error occurs
      • writeFloat

        public void writeFloat​(int iProp,
                               float fl)
                        throws IOException
        Write a float property to the POF stream.
        Specified by:
        writeFloat in interface PofWriter
        Parameters:
        iProp - the property index
        fl - the float property value to write
        Throws:
        IOException - if an I/O error occurs
      • writeFloat

        protected void writeFloat​(int iProp,
                                  float fl,
                                  boolean fReferenceable)
                           throws IOException
        Write a float property to the POF stream.
        Parameters:
        iProp - the property index
        fl - the float property value to write
        fReferenceable - true if the property value is a referenceable type
        Throws:
        IllegalArgumentException - if the property index is invalid, or is less than or equal to the index of the previous property written to the POF stream
        IOException - if an I/O error occurs
      • writeDouble

        public void writeDouble​(int iProp,
                                double dfl)
                         throws IOException
        Write a double property to the POF stream.
        Specified by:
        writeDouble in interface PofWriter
        Parameters:
        iProp - the property index
        dfl - the double property value to write
        Throws:
        IOException - if an I/O error occurs
      • writeDouble

        protected void writeDouble​(int iProp,
                                   double dfl,
                                   boolean fReferenceable)
                            throws IOException
        Write a double property to the POF stream.
        Parameters:
        iProp - the property index
        dfl - the double property value to write
        fReferenceable - true if the property value is a referenceable type
        Throws:
        IllegalArgumentException - if the property index is invalid, or is less than or equal to the index of the previous property written to the POF stream
        IOException - if an I/O error occurs
      • writeBooleanArray

        public void writeBooleanArray​(int iProp,
                                      boolean[] af)
                               throws IOException
        Write a boolean[] property to the POF stream.
        Specified by:
        writeBooleanArray in interface PofWriter
        Parameters:
        iProp - the property index
        af - the boolean[] property value to write
        Throws:
        IOException - if an I/O error occurs
      • writeByteArray

        public void writeByteArray​(int iProp,
                                   byte[] ab)
                            throws IOException
        Write a byte[] property to the POF stream.
        Specified by:
        writeByteArray in interface PofWriter
        Parameters:
        iProp - the property index
        ab - the byte[] property value to write
        Throws:
        IOException - if an I/O error occurs
      • writeCharArray

        public void writeCharArray​(int iProp,
                                   char[] ach)
                            throws IOException
        Write a char[] property to the POF stream.
        Specified by:
        writeCharArray in interface PofWriter
        Parameters:
        iProp - the property index
        ach - the char[] property value to write
        Throws:
        IOException - if an I/O error occurs
      • writeShortArray

        public void writeShortArray​(int iProp,
                                    short[] an)
                             throws IOException
        Write a short[] property to the POF stream.
        Specified by:
        writeShortArray in interface PofWriter
        Parameters:
        iProp - the property index
        an - the short[] property value to write
        Throws:
        IOException - if an I/O error occurs
      • writeIntArray

        public void writeIntArray​(int iProp,
                                  int[] an)
                           throws IOException
        Write a int[] property to the POF stream.
        Specified by:
        writeIntArray in interface PofWriter
        Parameters:
        iProp - the property index
        an - the int[] property value to write
        Throws:
        IOException - if an I/O error occurs
      • writeLongArray

        public void writeLongArray​(int iProp,
                                   long[] an)
                            throws IOException
        Write a long[] property to the POF stream.
        Specified by:
        writeLongArray in interface PofWriter
        Parameters:
        iProp - the property index
        an - the long[] property value to write
        Throws:
        IOException - if an I/O error occurs
      • writeFloatArray

        public void writeFloatArray​(int iProp,
                                    float[] afl)
                             throws IOException
        Write a float[] property to the POF stream.
        Specified by:
        writeFloatArray in interface PofWriter
        Parameters:
        iProp - the property index
        afl - the float[] property value to write
        Throws:
        IOException - if an I/O error occurs
      • writeDoubleArray

        public void writeDoubleArray​(int iProp,
                                     double[] adfl)
                              throws IOException
        Write a double[] property to the POF stream.
        Specified by:
        writeDoubleArray in interface PofWriter
        Parameters:
        iProp - the property index
        adfl - the double[] property value to write
        Throws:
        IOException - if an I/O error occurs
      • writeBigInteger

        public void writeBigInteger​(int iProp,
                                    BigInteger n)
                             throws IOException
        Write a BigInteger property to the POF stream.
        Specified by:
        writeBigInteger in interface PofWriter
        Parameters:
        iProp - the property index
        n - the BigInteger property value to write
        Throws:
        IOException - if an I/O error occurs
      • writeRawQuad

        public void writeRawQuad​(int iProp,
                                 RawQuad qfl)
                          throws IOException
        Write a RawQuad property to the POF stream.
        Specified by:
        writeRawQuad in interface PofWriter
        Parameters:
        iProp - the property index
        qfl - the RawQuad property value to write
        Throws:
        IOException - if an I/O error occurs
      • writeBigDecimal

        public void writeBigDecimal​(int iProp,
                                    BigDecimal dec)
                             throws IOException
        Write a BigDecimal property to the POF stream.
        Specified by:
        writeBigDecimal in interface PofWriter
        Parameters:
        iProp - the property index
        dec - the BigDecimal property value to write
        Throws:
        IOException - if an I/O error occurs
      • writeBinary

        public void writeBinary​(int iProp,
                                Binary bin)
                         throws IOException
        Write a Binary property to the POF stream.
        Specified by:
        writeBinary in interface PofWriter
        Parameters:
        iProp - the property index
        bin - the Binary property value to write
        Throws:
        IOException - if an I/O error occurs
      • writeString

        public void writeString​(int iProp,
                                String s)
                         throws IOException
        Write a String property to the POF stream.
        Specified by:
        writeString in interface PofWriter
        Parameters:
        iProp - the property index
        s - the String property value to write
        Throws:
        IOException - if an I/O error occurs
      • writeDate

        public void writeDate​(int iProp,
                              Date dt)
                       throws IOException
        Write a Date property to the POF stream in ISO8601 format.

        This method encodes the year, month and day information of the specified Date object. No time or timezone information is encoded.

        Specified by:
        writeDate in interface PofWriter
        Parameters:
        iProp - the property index
        dt - the Date property value to write in ISO8601 format
        Throws:
        IOException - if an I/O error occurs
      • writeDate

        public void writeDate​(int iProp,
                              LocalDate dt)
                       throws IOException
        Description copied from interface: PofWriter
        Write a LocalDate property to the POF stream in ISO8601 format.

        This method encodes the year, month and day information of the specified LocalDate object. No time or timezone information is encoded.

        Specified by:
        writeDate in interface PofWriter
        Parameters:
        iProp - the property index
        dt - the LocalDate property value to write in ISO8601 format
        Throws:
        IOException - if an I/O error occurs
      • writeDateTime

        public void writeDateTime​(int iProp,
                                  Date dt)
                           throws IOException
        Write a Date property to the POF stream in ISO8601 format.

        This method encodes the year, month, day, hour, minute, second and millisecond information of the specified Date object. No timezone information is encoded.

        Specified by:
        writeDateTime in interface PofWriter
        Parameters:
        iProp - the property index
        dt - the Date property value to write in ISO8601 format
        Throws:
        IOException - if an I/O error occurs
      • writeDateTime

        public void writeDateTime​(int iProp,
                                  LocalDateTime dt)
                           throws IOException
        Description copied from interface: PofWriter
        Write a LocalDateTime property to the POF stream in ISO8601 format.

        This method encodes the year, month, day, hour, minute, second and millisecond information of the specified LocalDateTime object. No timezone information is encoded.

        Specified by:
        writeDateTime in interface PofWriter
        Parameters:
        iProp - the property index
        dt - the LocalDateTime property value to write in ISO8601 format
        Throws:
        IOException - if an I/O error occurs
      • writeDateTime

        public void writeDateTime​(int iProp,
                                  Timestamp dt)
                           throws IOException
        Write a Timestamp property to the POF stream in ISO8601 format.

        This method encodes the year, month, day, hour, minute, second, millisecond and nanosecond information of the specified Timestamp object. No timezone information is encoded.

        Specified by:
        writeDateTime in interface PofWriter
        Parameters:
        iProp - the property index
        dt - the Timestamp property value to write in ISO8601 format
        Throws:
        IOException - if an I/O error occurs
      • writeDateTimeWithZone

        public void writeDateTimeWithZone​(int iProp,
                                          Date dt)
                                   throws IOException
        Write a Date property to the POF stream in ISO8601 format.

        This method encodes the year, month, day, hour, minute, second, millisecond and timezone information of the specified Date object.

        Specified by:
        writeDateTimeWithZone in interface PofWriter
        Parameters:
        iProp - the property index
        dt - the Date property value to write in ISO8601 format
        Throws:
        IOException - if an I/O error occurs
      • writeDateTimeWithZone

        public void writeDateTimeWithZone​(int iProp,
                                          OffsetDateTime dt)
                                   throws IOException
        Description copied from interface: PofWriter
        Write a OffsetDateTime property to the POF stream in ISO8601 format.

        This method encodes the year, month, day, hour, minute, second, millisecond and timezone information of the specified OffsetDateTime object.

        Specified by:
        writeDateTimeWithZone in interface PofWriter
        Parameters:
        iProp - the property index
        dt - the OffsetDateTime property value to write in ISO8601 format
        Throws:
        IOException - if an I/O error occurs
      • writeDateTimeWithZone

        public void writeDateTimeWithZone​(int iProp,
                                          Timestamp dt)
                                   throws IOException
        Write a Timestamp property to the POF stream in ISO8601 format.

        This method encodes the year, month, day, hour, minute, second, millisecond, nanosecond and timezone information of the specified Timestamp object.

        Specified by:
        writeDateTimeWithZone in interface PofWriter
        Parameters:
        iProp - the property index
        dt - the Timestamp property value to write in ISO8601 format
        Throws:
        IOException - if an I/O error occurs
      • writeTime

        public void writeTime​(int iProp,
                              Date dt)
                       throws IOException
        Write a Date property to the POF stream in ISO8601 format.

        This method encodes the hour, minute, second and millisecond information of the specified Date object. No year, month, day or timezone information is encoded.

        Specified by:
        writeTime in interface PofWriter
        Parameters:
        iProp - the property index
        dt - the Date property value to write in ISO8601 format
        Throws:
        IOException - if an I/O error occurs
      • writeTime

        public void writeTime​(int iProp,
                              LocalTime dt)
                       throws IOException
        Description copied from interface: PofWriter
        Write a LocalTime property to the POF stream in ISO8601 format.

        This method encodes the hour, minute, second and millisecond information of the specified LocalTime object. No year, month, day or timezone information is encoded.

        Specified by:
        writeTime in interface PofWriter
        Parameters:
        iProp - the property index
        dt - the LocalTime property value to write in ISO8601 format
        Throws:
        IOException - if an I/O error occurs
      • writeTime

        public void writeTime​(int iProp,
                              Timestamp dt)
                       throws IOException
        Write a Timestamp property to the POF stream in ISO8601 format.

        This method encodes the hour, minute, second, millisecond and nanosecond information of the specified Timestamp object.

        Specified by:
        writeTime in interface PofWriter
        Parameters:
        iProp - the property index
        dt - the Timestamp property value to write in ISO8601 format
        Throws:
        IOException - if an I/O error occurs
      • writeTimeWithZone

        public void writeTimeWithZone​(int iProp,
                                      Date dt)
                               throws IOException
        Write a Date property to the POF stream in ISO8601 format.

        This method encodes the hour, minute, second, millisecond and timezone information of the specified Date object. No year, month or day information is encoded.

        Specified by:
        writeTimeWithZone in interface PofWriter
        Parameters:
        iProp - the property index
        dt - the Date property value to write in ISO8601 format
        Throws:
        IOException - if an I/O error occurs
      • writeTimeWithZone

        public void writeTimeWithZone​(int iProp,
                                      OffsetTime dt)
                               throws IOException
        Description copied from interface: PofWriter
        Write a OffsetTime property to the POF stream in ISO8601 format.

        This method encodes the hour, minute, second, millisecond and timezone information of the specified OffsetTime object. No year, month or day information is encoded.

        Specified by:
        writeTimeWithZone in interface PofWriter
        Parameters:
        iProp - the property index
        dt - the OffsetTime property value to write in ISO8601 format
        Throws:
        IOException - if an I/O error occurs
      • writeTimeWithZone

        public void writeTimeWithZone​(int iProp,
                                      Timestamp dt)
                               throws IOException
        Write a Timestamp property to the POF stream in ISO8601 format.

        This method encodes the hour, minute, second, millisecond, nanosecond and timezone information of the specified Timestamp object. No year, month or day information is encoded.

        Specified by:
        writeTimeWithZone in interface PofWriter
        Parameters:
        iProp - the property index
        dt - the Timestamp property value to write in ISO8601 format
        Throws:
        IOException - if an I/O error occurs
      • writeRawDate

        public void writeRawDate​(int iProp,
                                 RawDate date)
                          throws IOException
        Write a RawDate property to the POF stream.
        Specified by:
        writeRawDate in interface PofWriter
        Parameters:
        iProp - the property index
        date - the RawDate property value to write
        Throws:
        IOException - if an I/O error occurs
      • writeRawTime

        public void writeRawTime​(int iProp,
                                 RawTime time)
                          throws IOException
        Write a RawTime property to the POF stream.
        Specified by:
        writeRawTime in interface PofWriter
        Parameters:
        iProp - the property index
        time - the RawTime property value to write
        Throws:
        IOException - if an I/O error occurs
      • writeRawDateTime

        public void writeRawDateTime​(int iProp,
                                     RawDateTime dt)
                              throws IOException
        Write a RawDateTime property to the POF stream.
        Specified by:
        writeRawDateTime in interface PofWriter
        Parameters:
        iProp - the property index
        dt - the RawDateTime property value to write
        Throws:
        IOException - if an I/O error occurs
      • writeRawYearMonthInterval

        public void writeRawYearMonthInterval​(int iProp,
                                              RawYearMonthInterval interval)
                                       throws IOException
        Write a RawYearMonthInterval property to the POF stream.
        Specified by:
        writeRawYearMonthInterval in interface PofWriter
        Parameters:
        iProp - the property index
        interval - the RawYearMonthInterval property value to write
        Throws:
        IOException - if an I/O error occurs
      • writeRawTimeInterval

        public void writeRawTimeInterval​(int iProp,
                                         RawTimeInterval interval)
                                  throws IOException
        Write a RawTimeInterval property to the POF stream.
        Specified by:
        writeRawTimeInterval in interface PofWriter
        Parameters:
        iProp - the property index
        interval - the RawTimeInterval property value to write
        Throws:
        IOException - if an I/O error occurs
      • writeRawDayTimeInterval

        public void writeRawDayTimeInterval​(int iProp,
                                            RawDayTimeInterval interval)
                                     throws IOException
        Write a RawDayTimeInterval property to the POF stream.
        Specified by:
        writeRawDayTimeInterval in interface PofWriter
        Parameters:
        iProp - the property index
        interval - the RawDayTimeInterval property value to write
        Throws:
        IOException - if an I/O error occurs
      • writeUserType

        protected void writeUserType​(int iProp,
                                     Object o)
                              throws IOException
        Write a user-type to the POF stream.
        Parameters:
        iProp - the property index
        o - the object to write
        Throws:
        IOException - if an I/O error occurs
      • writeObjectArray

        public <T> void writeObjectArray​(int iProp,
                                         T[] ao,
                                         Class<? extends T> clz)
                                  throws IOException
        Write a uniform Object[] property to the POF stream.

        Each element of the given array must be an instance (or an array of instances) of one of the following:

        Otherwise, a PofSerializer for each element of the array must be obtainable from the PofContext associated with this PofWriter.

        Additionally, the type of each element must be equal to the specified class.

        Specified by:
        writeObjectArray in interface PofWriter
        Type Parameters:
        T - the type of the elements in the array
        Parameters:
        iProp - the property index
        ao - the Object[] property to write
        clz - the class of all elements; must not be null
        Throws:
        IOException - if an I/O error occurs
      • writeCollection

        public <T> void writeCollection​(int iProp,
                                        Collection<? extends T> coll,
                                        Class<? extends T> clz)
                                 throws IOException
        Write a uniform Collection property to the POF stream.

        Each element of the given Collection must be an instance (or an array of instances) of one of the following:

        Otherwise, a PofSerializer for each element of the Collection must be obtainable from the PofContext associated with this PofWriter.

        Additionally, the type of each element must be equal to the specified class.

        Specified by:
        writeCollection in interface PofWriter
        Type Parameters:
        T - the type of elements in the Collection
        Parameters:
        iProp - the property index
        coll - the Collection property to write
        clz - the class of all elements; must not be null
        Throws:
        IOException - if an I/O error occurs
      • writeLongArray

        public void writeLongArray​(int iProp,
                                   LongArray la,
                                   Class clz)
                            throws IOException
        Write a uniform LongArray property to the POF stream.

        Each element of the given LongArray must be an instance (or an array of instances) of one of the following:

        Otherwise, a PofSerializer for each element of the LongArray must be obtainable from the PofContext associated with this PofWriter.

        Additionally, the type of each element must be equal to the specified class.

        Specified by:
        writeLongArray in interface PofWriter
        Parameters:
        iProp - the property index
        la - the LongArray property to write
        clz - the class of all elements; must not be null
        Throws:
        IOException - if an I/O error occurs
      • writeMap

        public <K,​V> void writeMap​(int iProp,
                                         Map<K,​? extends V> map,
                                         Class<? extends K> clzKey)
                                  throws IOException
        Write a uniform key Map property to the POF stream.

        Each key and value of the given Map must be an instance (or an array of instances) of one of the following:

        Otherwise, a PofSerializer for each key and value of the Map must be obtainable from the PofContext associated with this PofWriter.

        Additionally, the type of each key must be equal to the specified class.

        Specified by:
        writeMap in interface PofWriter
        Type Parameters:
        K - the key type
        V - the value type
        Parameters:
        iProp - the property index
        map - the Map property to write
        clzKey - the class of all keys; must not be null
        Throws:
        IOException - if an I/O error occurs
      • writeMap

        public <K,​V> void writeMap​(int iProp,
                                         Map<K,​V> map,
                                         Class<? extends K> clzKey,
                                         Class<? extends V> clzValue)
                                  throws IOException
        Write a uniform Map property to the POF stream.

        Each key and value of the given Map must be an instance (or an array of instances) of one of the following:

        Otherwise, a PofSerializer for each key and value of the Map must be obtainable from the PofContext associated with this PofWriter.

        Additionally, the type of each key and value must be equal to the specified key class and value class respectively.

        Specified by:
        writeMap in interface PofWriter
        Type Parameters:
        K - the key type
        V - the value type
        Parameters:
        iProp - the property index
        map - the Map property to write
        clzKey - the class of all keys; must not be null
        clzValue - the class of all values; must not be null
        Throws:
        IOException - if an I/O error occurs
      • getPofContext

        public PofContext getPofContext()
        Return the PofContext object used by this PofWriter to serialize user types to a POF stream.
        Specified by:
        getPofContext in interface PofWriter
        Returns:
        the PofContext object that contains user type meta-data
      • setPofContext

        public void setPofContext​(PofContext ctx)
        Configure the PofContext object used by this PofWriter to serialize user types to a POF stream.

        Note: this is an advanced method that should be used with care. For example, if this method is being used to switch to another PofContext mid-POF stream, it is important to eventually restore the original PofContext. For example:

         PofContext ctxOrig = writer.getPofContext();
         try
             {
             // switch to another PofContext
             PofContext ctxNew = ...;
             writer.setContext(ctxNew);
        
             // output POF data using the writer
             }
         finally
             {
             // restore the original PofContext
             writer.setPofContext(ctxOrig);
             }
         
        Specified by:
        setPofContext in interface PofWriter
        Parameters:
        ctx - the new PofContext; must not be null
      • getUserTypeId

        public int getUserTypeId()
        Determine the user type that is currently being written.
        Specified by:
        getUserTypeId in interface PofWriter
        Returns:
        the user type identifier, or -1 if the PofWriter is not currently writing a user type
      • getVersionId

        public int getVersionId()
        Determine the version identifier of the user type that is currently being written.
        Specified by:
        getVersionId in interface PofWriter
        Returns:
        the integer version ID of the user type; always non-negative
      • setVersionId

        public void setVersionId​(int nVersionId)
        Set the version identifier of the user type that is currently being written.
        Specified by:
        setVersionId in interface PofWriter
        Parameters:
        nVersionId - the user type identifier; must be non-negative
      • createNestedPofWriter

        public PofWriter createNestedPofWriter​(int iProp)
                                        throws IOException
        Obtain a PofWriter that can be used to write a set of properties into a single property of the current user type. The returned PofWriter is only valid from the time that it is returned until the next call is made to this PofWriter.
        Specified by:
        createNestedPofWriter in interface PofWriter
        Parameters:
        iProp - the property index
        Returns:
        a PofWriter whose contents are nested into a single property of this PofWriter
        Throws:
        IOException - if an I/O error occurs
      • createNestedPofWriter

        public PofWriter createNestedPofWriter​(int iProp,
                                               int nTypeId)
                                        throws IOException
        Obtain a PofWriter that can be used to write a set of properties into a single property of the current user type. The returned PofWriter is only valid from the time that it is returned until the next call is made to this PofWriter.
        Specified by:
        createNestedPofWriter in interface PofWriter
        Parameters:
        iProp - the property index
        nTypeId - the type identifier of the nested property
        Returns:
        a PofWriter whose contents are nested into a single property of this PofWriter
        Throws:
        IOException - if an I/O error occurs
      • writeRemainder

        public void writeRemainder​(Binary binProps)
                            throws IOException
        Write the remaining properties to the POF stream, terminating the writing of the current user type. As part of writing out a user type, this method must be called by the PofSerializer that is writing out the user type, or the POF stream will be corrupted.

        Calling this method terminates the current user type by writing a -1 to the POF stream after the last indexed property. Subsequent calls to the various writeXYZ methods of this interface will fail after this method is called.

        Specified by:
        writeRemainder in interface PofWriter
        Parameters:
        binProps - a Binary object containing zero or more indexed properties in binary POF encoded form; may be null
        Throws:
        IOException - if an I/O error occurs
      • getParentWriter

        protected PofBufferWriter getParentWriter()
        If this writer is contextually within a user type, obtain the writer which created this writer in order to write the user type.
        Returns:
        the containing writer
      • beginProperty

        protected void beginProperty​(int iProp)
                              throws IOException
        Report that a POF property is about to be written to the POF stream.

        This method call will be followed by one or more separate calls to a "write" method and the property extent will then be terminated by a call to endProperty(int).

        Parameters:
        iProp - the index of the property being written
        Throws:
        IllegalArgumentException - if the property index is invalid, or is less than or equal to the index of the previous property written to the POF stream
        IOException - if an I/O error occurs
      • endProperty

        protected void endProperty​(int iProp)
        Signifies the termination of the current POF property.
        Parameters:
        iProp - the index of the current property
      • onException

        protected void onException​(Exception e)
                            throws IOException
        Called when an unexpected exception is caught while writing to the POF stream.

        If the given exception wraps an IOException, the IOException is unwrapped and rethrown; otherwise the given exception is rethrown.

        Parameters:
        e - the exception
        Throws:
        IOException - the wrapped IOException, if the given exception is a wrapped IOException
      • fixNanos

        protected static Date fixNanos​(Date dt)
        Return a Date which is suitable for POF serialization

        Similar to Timestamp, POF requires that dates have positive sub-second values.

        Parameters:
        dt - the Date object to check
        Returns:
        the passed in Date if no conversion is necessary; otherwise the passed in Date as a Timestamp.
        Since:
        Coherence 3.7.1.13
      • getNanos

        protected static int getNanos​(Date dt)
        Extract the nanoseconds from the date. This number represents a fraction of a second in the passed-in date expressed with a nanosecond resolution.
        Parameters:
        dt - the Date object to extract the nanoseconds from
        Returns:
        the number of nanoseconds in the date
      • assertEqual

        protected static void assertEqual​(Class clz,
                                          Class clzTest)
        Assert that a class is equal to another class.
        Parameters:
        clz - the expected class; must not be null
        clzTest - the class to test for equality; must not be null
        Throws:
        IllegalArgumentException - if the second class is not equal to the first
      • getBufferOutput

        protected WriteBuffer.BufferOutput getBufferOutput()
        Return the BufferOutput that this PofBufferWriter writes to.
        Returns:
        the BufferOutput
      • getPofHandler

        protected WritingPofHandler getPofHandler()
        Return the WritingPofHandler used internally by this PofBufferWriter to write the POF stream.
        Returns:
        the PofHandler
      • enableReference

        public void enableReference()
        Ensure that reference support (necessary for cyclic dependencies) is enabled.
      • isReferenceEnabled

        public boolean isReferenceEnabled()
        Determine if reference support is enabled.
        Returns:
        true iff reference support is enabled
      • isEvolvable

        protected boolean isEvolvable()
        Determine if the object to be written is either Evolvable or part of an Evolvable object.
        Returns:
        true iff the object to be written is Evolvable
      • setEvolvable

        protected void setEvolvable​(boolean fEvolvable)
        Set the Evolvable flag to indicate if the object to be written is Evolvable or part of an Evolvable object.
        Parameters:
        fEvolvable - true iff the object to be written is Evolvable
      • main

        public static void main​(String[] args)