Beispiel #1
0
 /**
  * Writes an array to the underlying stream. If the underlying stream does not contain enough of
  * free space to write it will be expanded before it is written to. This will save the state of
  * the array, so if its null or empty and read back it will return null or empty. This is
  * accomplished by writing a single boolean to whether the array is null, if its not null the
  * length of the array is then written as an unsigned short (0-65535) and finally the elements in
  * the array are written.
  *
  * @param <T> The type of the written object.
  * @param x The array of objects to write to the stream.
  * @param callback The callback to invoke to serialize the objects with this writer.
  */
 public <T> void putArray(T[] x, WriteCallback<T> callback) {
   if (putIsNotNull(x)) {
     putUshort(x.length);
     for (int i = 0; i < x.length; i++) {
       if (putIsNotNull(x[i])) {
         callback.write(this, x[i]);
       }
     }
   }
 }
Beispiel #2
0
 /**
  * Writes an object to the underlying stream using a callback which serializes the object. If the
  * underlying stream does not contain enough of free space to write it will be expanded before it
  * is written to.
  *
  * @param <T> The type of the written object.
  * @param item The object to write to the stream.
  * @param callback The callback to invoke to serialize the object with this writer.
  */
 public <T> void putItem(T item, WriteCallback<T> callback) {
   if (putIsNotNull(item)) {
     callback.write(this, item);
   }
 }