Пример #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]);
   }
 }
Пример #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]);
   }
 }
Пример #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);
 }
Пример #4
0
 /**
  * Returns the byte order of the writer.
  *
  * @return The byte order of the writer.
  */
 public ByteOrder order() {
   return stream.order();
 }
Пример #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));
   }
 }
Пример #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);
 }
Пример #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);
 }
Пример #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]);
   }
 }
Пример #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);
 }
Пример #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]);
   }
 }
Пример #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);
 }
Пример #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);
 }
Пример #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);
 }
Пример #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);
 }
Пример #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);
 }
Пример #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]);
   }
 }
Пример #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]);
   }
 }
Пример #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);
 }
Пример #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]);
   }
 }
Пример #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);
 }
Пример #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();
 }
Пример #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);
 }
Пример #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);
 }
Пример #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));
 }