Write zero branch size.

@param out   the out
@param value the value
@param max   the max
@param bits  the bits
@throws IOException the io exception
346413
protected void writeZeroBranchSize(final BitOutputStream out,
    final long value, final long max, final Bits bits) throws IOException {
    assert 0 <= value;
    assert max >= value;
    if (SERIALIZATION_CHECKS) {
      out.write(SerializationChecks.BeforeCount);
    }
    if (this.useBinomials) {
      Gaussian.fromBinomial(0.5, max).encode(out, value, max);
    }
    else {
      out.writeBoundedLong(value, 1 + max);
    }
    if (SERIALIZATION_CHECKS) {
      out.write(SerializationChecks.AfterCount);
    }
  }
919407
public synchronized void write(final Bits bits) throws IOException {
    Bits newRemainder = this.remainder.concatenate(bits);
    final int newRemainingBits = newRemainder.bitLength % 8;
    int bitsToWrite = newRemainder.bitLength - newRemainingBits;
    if (bitsToWrite > 0) {
      assert (0 == bitsToWrite % 8);
      final Bits toWrite = newRemainder.range(0, bitsToWrite);
      this.inner.write(toWrite.getBytes());
      newRemainder = newRemainder.range(bitsToWrite);
    }
    this.remainder = newRemainder;
    this.totalBitsWritten += bits.bitLength;
  }
775518
public void write(int value, BitWriter bitwriter) throws JSONException {
        this.width = 0;
        write(this.symbols[value], bitwriter);
        tick(value);
        if (JSONzip.probe) {
            JSONzip.logchar(value, this.width);
        }
    }
1161967
public void writeRaw(byte[] value, int start, int len) throws IOException
    {
        startValue(TID_RAW);
        _writer.write(value, start, len);
        _patch.patchValue(len);
        closeValue();
    }
930348
private void setNumberHits(BitSet bits, String value, int min, int max) {
        String[] fields = StringUtils.delimitedListToStringArray(value, ",");
        for (String field : fields) {
            if (!field.contains("/")) {
                // Not an incrementer so it must be a range (possibly empty)
                int[] range = getRange(field, min, max);
                bits.set(range[0], range[1] + 1);
            } else {
                String[] split = StringUtils.delimitedListToStringArray(field, "/");
                if (split.length > 2) {
                    throw new IllegalArgumentException("Incrementer has more than two fields: '" + field
                            + "' in expression \"" + this.expression + "\"");
                }
                int[] range = getRange(split[0], min, max);
                if (!split[0].contains("-")) {
                    range[1] = max - 1;
                }
                int delta = Integer.valueOf(split[1]);
                for (int i = range[0]; i <= range[1]; i += delta) {
                    bits.set(i);
                }
            }
        }
    }
601407
public static int writeShorts(final BitOutput bitOutput, final int lengthSize, final int shortSize,
                                  final short[] value)
            throws IOException {
        if (bitOutput == null) {
            throw new NullPointerException("bitOutput is null");
        }
        requireValidSizeInt(true, lengthSize);
        requireValidSizeShort(false, shortSize);
        if (value == null) {
            throw new NullPointerException("value is null");
        }
        final int length = value.length & ((1 << lengthSize) - 1);
        bitOutput.writeInt(true, lengthSize, length);
        for (int i = 0; i < length; i++) {
            bitOutput.writeShort(false, shortSize, value[i]);
        }
        return length;
    }
1119840
public void write(int bits, int width) throws IOException {
        if (bits == 0 && width == 0) {
            return;
        }
        if (width <= 0 || width > 32) {
            throw new IOException("Bad write width.");
        }
        while (width > 0) {
            int actual = width;
            if (actual > this.vacant) {
                actual = this.vacant;
            }
            this.unwritten |= ((bits >>> (width - actual)) &
                    ((1 << actual) - 1)) << (this.vacant - actual);
            width -= actual;
            nrBits += actual;
            this.vacant -= actual;
            if (this.vacant == 0) {
                this.out.write(this.unwritten);
                this.unwritten = 0;
                this.vacant = 8;
            }
        }
    }
979796
public void write(ByteCodeWriter out)
    throws IOException
  {
    out.writeUTF8Const(getName());
    out.writeInt(_value.length);
    out.write(_value, 0, _value.length);
  }
891608
public static void writeIntegerLittleEndian(IO.WritableByteStream io, int value) throws IOException {
		io.write((byte)(value & 0xFF));
		io.write((byte)((value >> 8) & 0xFF));
		io.write((byte)((value >> 16) & 0xFF));
		io.write((byte)((value >> 24) & 0xFF));
	}
638
static void writeShort(OutputStream out, int i) throws IOException {
        out.write((byte)i);
        out.write((byte)(i >> 8));
    }
1077532
public static void writeReverseInt(IoBuffer out, int value) {
        out.put((byte) (0xFF & value));
        out.put((byte) (0xFF & (value >> 8)));
        out.put((byte) (0xFF & (value >> 16)));
        out.put((byte) (0xFF & (value >> 24)));
    }
471458
public void writeTo(final OutputStream out) throws IOException
    {
        for (int i = 0; i <= index; i++)
        {
            Block block = blocks.get(i);
            out.write(block.data, 0, block.limit);
        }
    }
336034
public static int writeTo(final OutputStream out, LinkedBuffer node) throws IOException
    {
        int contentSize = 0, len;
        do
        {
            if ((len = node.offset - node.start) > 0)
            {
                out.write(node.buffer, node.start, len);
                contentSize += len;
            }
        } while ((node = node.next) != null);

        return contentSize;
    }
1284737
public static void writeBigInteger(BigInteger record, DataOutputView target) throws IOException {
		// null value support
		if (record == null) {
			target.writeInt(0);
			return;
		}
		// fast paths for 0, 1, 10
		// only reference equality is checked because equals would be too expensive
		else if (record == BigInteger.ZERO) {
			target.writeInt(1);
			return;
		}
		else if (record == BigInteger.ONE) {
			target.writeInt(2);
			return;
		}
		else if (record == BigInteger.TEN) {
			target.writeInt(3);
			return;
		}
		// default
		final byte[] bytes = record.toByteArray();
		// the length we write is offset by four, because null and short-paths for ZERO, ONE, and TEN
		target.writeInt(bytes.length + 4);
		target.write(bytes);
	}
493062
private static final void writeVarLengthInt(DataOutput out, int value) throws IOException {
		while (value >= MAX_BIT) {
			out.write(value | MAX_BIT);
			value >>= 7;
		}
		out.write(value);
	}
405955
public static int writeBytes(final BitOutput bitOutput, final int lengthSize, final boolean byteUnsigned,
                                 final int byteSize, final byte[] value)
            throws IOException {
        if (bitOutput == null) {
            throw new NullPointerException("bitOutput is null");
        }
        requireValidSizeInt(true, lengthSize);
        requireValidSizeByte(byteUnsigned, byteSize);
        if (value == null) {
            throw new NullPointerException("value is null");
        }
        final int length = value.length & ((1 << lengthSize) - 1);
        bitOutput.writeInt(true, lengthSize, length);
        for (int i = 0; i < length; i++) {
            bitOutput.writeByte(byteUnsigned, byteSize, value[i]);
        }
        return length;
    }
291931
public static void writeBigInteger(BigInteger integer, DataOutputStream out)
            throws IOException {
        if (integer.signum() == -1) {
            throw new IllegalStateException("Negative BigInteger!");
        }
        byte[] buf = integer.toByteArray();
        if (buf.length > Short.MAX_VALUE)
            throw new IllegalStateException("Too long: " + buf.length);
        out.writeShort((short) buf.length);
        out.write(buf);
    }