示例#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));
 }