Exemplo n.º 1
0
 /**
  * Writes an array of longs 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. A long takes up 8
  * bytes.
  *
  * @param x The array to write to the stream.
  */
 public void putLongs(long[] x) {
   ByteBuffer b = stream.getWriter(x.length << 3);
   for (int i = 0; i < x.length; i++) {
     b.putLong(x[i]);
   }
 }
Exemplo n.º 2
0
 /**
  * Writes an array of unsigned ints 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. An unsigned
  * int takes up 4 bytes.
  *
  * @param x The array to write to the stream.
  */
 public void putUints(long[] x) {
   ByteBuffer b = stream.getWriter(x.length << 2);
   for (int i = 0; i < x.length; i++) {
     b.putInt((int) x[i]);
   }
 }
Exemplo n.º 3
0
 /**
  * Writes a long to the underlying stream. If the underlying stream does not contain enough of
  * free space to write it, it will be expanded before it is written to. A long takes up 8 bytes.
  *
  * @param value The value to write to the stream.
  */
 public void putLong(long value) {
   stream.getWriter(8).putLong(value);
 }
Exemplo n.º 4
0
 /**
  * Returns the byte order of the writer.
  *
  * @return The byte order of the writer.
  */
 public ByteOrder order() {
   return stream.order();
 }
Exemplo n.º 5
0
 /**
  * Writes an array of booleans 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.
  *
  * @param x The array to write to the stream.
  */
 public void putBooleans(boolean[] x) {
   ByteBuffer b = stream.getWriter(x.length);
   for (int i = 0; i < x.length; i++) {
     b.put((byte) (x[i] ? 1 : 0));
   }
 }
Exemplo n.º 6
0
 /**
  * Writes a double to the underlying stream. If the underlying stream does not contain enough of
  * free space to write it, it will be expanded before it is written to. A double takes up 8 bytes.
  *
  * @param value The value to write to the stream.
  */
 public void putDouble(double value) {
   stream.getWriter(8).putDouble(value);
 }
Exemplo n.º 7
0
 /**
  * Writes the remaining data in the given buffer 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.
  *
  * @param x The buffer to transfer data from.
  */
 public void putBuffer(ByteBuffer x) {
   stream.drain(x);
 }
Exemplo n.º 8
0
 /**
  * Writes an array of chars 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. A char takes up 2
  * bytes.
  *
  * @param x The array to write to the stream.
  */
 public void putChars(char[] x) {
   ByteBuffer b = stream.getWriter(x.length << 1);
   for (int i = 0; i < x.length; i++) {
     b.putChar(x[i]);
   }
 }
Exemplo n.º 9
0
 /**
  * Writes a short to the underlying stream. If the underlying stream does not contain enough of
  * free space to write it, it will be expanded before it is written to. A short takes up 2 bytes.
  *
  * @param value The value to write to the stream.
  */
 public void putShort(short value) {
   stream.getWriter(2).putShort(value);
 }
Exemplo n.º 10
0
 /**
  * Writes an array of unsigned bytes 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.
  *
  * @param x The array to write to the stream.
  */
 public void putUbytes(short[] x) {
   ByteBuffer b = stream.getWriter(x.length);
   for (int i = 0; i < x.length; i++) {
     b.put((byte) x[i]);
   }
 }
Exemplo n.º 11
0
 /**
  * Writes a char to the underlying stream. If the underlying stream does not contain enough of
  * free space to write it, it will be expanded before it is written to. A char takes up 2 bytes.
  *
  * @param value The value to write to the stream.
  */
 public void putChar(char value) {
   stream.getWriter(2).putChar(value);
 }
Exemplo n.º 12
0
 /**
  * Writes an unsigned byte to the underlying stream. If the underlying stream does not contain
  * enough of free space to write it, it will be expanded before it is written to.
  *
  * @param value The value to write to the stream.
  */
 public void putUbyte(short value) {
   stream.getWriter(1).put((byte) value);
 }
Exemplo n.º 13
0
 /**
  * Writes an array of bytes 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.
  *
  * @param x The array to write to the stream.
  */
 public void putBytes(byte[] x) {
   stream.getWriter(x.length).put(x);
 }
Exemplo n.º 14
0
 /**
  * Writes a byte to the underlying stream. If the underlying stream does not contain enough of
  * free space to write it, it will be expanded before it is written to.
  *
  * @param value The value to write to the stream.
  */
 public void putByte(byte value) {
   stream.getWriter(1).put(value);
 }
Exemplo n.º 15
0
 /**
  * Writes a float to the underlying stream. If the underlying stream does not contain enough of
  * free space to write it, it will be expanded before it is written to. A float takes up 4 bytes.
  *
  * @param value The value to write to the stream.
  */
 public void putFloat(float value) {
   stream.getWriter(4).putFloat(value);
 }
Exemplo n.º 16
0
 /**
  * Writes an array of shorts 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. A short takes up 2
  * bytes.
  *
  * @param x The array to write to the stream.
  */
 public void putShorts(short[] x) {
   ByteBuffer b = stream.getWriter(x.length << 1);
   for (int i = 0; i < x.length; i++) {
     b.putShort(x[i]);
   }
 }
Exemplo n.º 17
0
 /**
  * Writes an array of floats 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. A float takes up 4
  * bytes.
  *
  * @param x The array to write to the stream.
  */
 public void putFloats(float[] x) {
   ByteBuffer b = stream.getWriter(x.length << 2);
   for (int i = 0; i < x.length; i++) {
     b.putFloat(x[i]);
   }
 }
Exemplo n.º 18
0
 /**
  * Writes an unsigned short to the underlying stream. If the underlying stream does not contain
  * enough of free space to write it, it will be expanded before it is written to. An unsigned
  * short takes up 2 bytes.
  *
  * @param value The value to write to the stream.
  */
 public void putUshort(int value) {
   stream.getWriter(2).putShort((short) value);
 }
Exemplo n.º 19
0
 /**
  * Writes an array of doubles 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. A double takes up 8
  * bytes.
  *
  * @param x The array to write to the stream.
  */
 public void putDoubles(double[] x) {
   ByteBuffer b = stream.getWriter(x.length << 3);
   for (int i = 0; i < x.length; i++) {
     b.putDouble(x[i]);
   }
 }
Exemplo n.º 20
0
 /**
  * Writes an int to the underlying stream. If the underlying stream does not contain enough of
  * free space to write it, it will be expanded before it is written to. An int takes up 4 bytes.
  *
  * @param value The value to write to the stream.
  */
 public void putInt(int value) {
   stream.getWriter(4).putInt(value);
 }
Exemplo n.º 21
0
 /**
  * Returns the total number of bytes in the underlying stream which have been written.
  *
  * @return The number of bytes written.
  */
 public int size() {
   return stream.size();
 }
Exemplo n.º 22
0
 /**
  * Writes an unsigned int to the underlying stream. If the underlying stream does not contain
  * enough of free space to write it, it will be expanded before it is written to. An unsigned int
  * takes up 4 bytes.
  *
  * @param value The value to write to the stream.
  */
 public void putUint(long value) {
   stream.getWriter(4).putInt((int) value);
 }
Exemplo n.º 23
0
 /**
  * Sets the byte order of the reader.
  *
  * @param order The new byte order of the reader.
  */
 public void order(ByteOrder order) {
   stream.order(order);
 }
Exemplo n.º 24
0
 /**
  * Writes a boolean 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. A boolean takes up a single
  * byte, a 0 for false and every other number means true.
  *
  * @param value The value to write to the stream.
  */
 public void putBoolean(boolean value) {
   stream.getWriter(1).put((byte) (value ? 1 : 0));
 }